1 package org.simantics.databoard.binding.impl;
3 import org.simantics.databoard.binding.LongBinding;
4 import org.simantics.databoard.binding.error.BindingException;
5 import org.simantics.databoard.primitives.UnsignedLong;
6 import org.simantics.databoard.type.LongType;
9 * Binding of {@link UnsignedLong} to long type.
10 * This is bitwise binding, i.e. high values are negative.
12 * @author Toni Kalajainen <toni.kalajainen@iki.fi>
14 public abstract class UnsignedLongBinding extends LongBinding {
16 UnsignedLongBinding(LongType type) {
20 public static class Immutable extends UnsignedLongBinding {
22 public Immutable(LongType type) {
27 public Object create(Number value) throws BindingException {
28 return UnsignedLong.fromBits(value.longValue());
32 public Object create(String value) throws BindingException {
34 return new UnsignedLong.Immutable(value);
35 } catch (java.lang.IllegalArgumentException e) {
36 throw new BindingException( e );
41 public Object create(long value) throws BindingException {
42 return UnsignedLong.fromBits(value);
46 public Object create(Long value) throws BindingException {
47 return UnsignedLong.fromBits(value);
51 public void setValue(Object obj, long value) throws BindingException {
52 throw new BindingException("UnsignedLong is immutable class");
56 public void setValue(Object obj, Number value) throws BindingException {
57 throw new BindingException("UnsignedLong is immutable class");
61 public boolean isImmutable() {
66 public boolean isInstance(Object obj) {
67 return obj instanceof UnsignedLong.Immutable;
72 public static class Mutable extends UnsignedLongBinding {
74 public Mutable(LongType type) {
79 public Object create(Number value) throws BindingException {
80 return UnsignedLong.Mutable.fromBits(value.longValue());
84 public Object create(String value) throws BindingException {
85 return new UnsignedLong.Mutable(value);
89 public void setValue(Object obj, Number value) throws BindingException {
90 UnsignedLong.Mutable v = (UnsignedLong.Mutable) obj;
91 v.setValue(value.longValue());
95 public boolean isImmutable() {
100 public Object create(long value) throws BindingException {
101 return UnsignedLong.Mutable.fromBits(value);
105 public Object create(Long value) throws BindingException {
106 return UnsignedLong.Mutable.fromBits(value);
110 public void setValue(Object obj, long value) throws BindingException {
111 UnsignedLong.Mutable v = (UnsignedLong.Mutable) obj;
116 public boolean isInstance(Object obj) {
117 return obj instanceof UnsignedLong.Mutable;
123 public String toString(Object value) throws BindingException {
124 return value.toString();
128 public Long getValue(Object o) throws BindingException {
129 UnsignedLong v = (UnsignedLong) o;
134 public long getValue_(Object o) throws BindingException {
135 UnsignedLong v = (UnsignedLong) o;