-package org.simantics.databoard.binding.impl;\r
-\r
-import org.simantics.databoard.binding.LongBinding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.primitives.UnsignedLong;\r
-import org.simantics.databoard.type.LongType;\r
-\r
-/**\r
- * Binding of {@link UnsignedLong} to long type.\r
- * This is bitwise binding, i.e. high values are negative.\r
- * \r
- * @author Toni Kalajainen <toni.kalajainen@iki.fi>\r
- */\r
-public abstract class UnsignedLongBinding extends LongBinding {\r
-\r
- UnsignedLongBinding(LongType type) {\r
- super(type);\r
- }\r
- \r
- public static class Immutable extends UnsignedLongBinding {\r
-\r
- public Immutable(LongType type) {\r
- super(type);\r
- }\r
-\r
- @Override\r
- public Object create(Number value) throws BindingException {\r
- return UnsignedLong.fromBits(value.longValue());\r
- }\r
-\r
- @Override\r
- public Object create(String value) throws BindingException {\r
- try {\r
- return new UnsignedLong.Immutable(value);\r
- } catch (java.lang.IllegalArgumentException e) {\r
- throw new BindingException( e );\r
- }\r
- }\r
-\r
- @Override\r
- public Object create(long value) throws BindingException {\r
- return UnsignedLong.fromBits(value);\r
- }\r
-\r
- @Override\r
- public Object create(Long value) throws BindingException {\r
- return UnsignedLong.fromBits(value);\r
- }\r
-\r
- @Override\r
- public void setValue(Object obj, long value) throws BindingException {\r
- throw new BindingException("UnsignedLong is immutable class");\r
- }\r
-\r
- @Override\r
- public void setValue(Object obj, Number value) throws BindingException {\r
- throw new BindingException("UnsignedLong is immutable class");\r
- }\r
- \r
- @Override\r
- public boolean isImmutable() {\r
- return true;\r
- }\r
- \r
- @Override\r
- public boolean isInstance(Object obj) {\r
- return obj instanceof UnsignedLong.Immutable;\r
- }\r
- \r
- }\r
-\r
- public static class Mutable extends UnsignedLongBinding {\r
-\r
- public Mutable(LongType type) {\r
- super(type);\r
- }\r
-\r
- @Override\r
- public Object create(Number value) throws BindingException {\r
- return UnsignedLong.Mutable.fromBits(value.longValue());\r
- }\r
-\r
- @Override\r
- public Object create(String value) throws BindingException {\r
- return new UnsignedLong.Mutable(value);\r
- }\r
-\r
- @Override\r
- public void setValue(Object obj, Number value) throws BindingException {\r
- UnsignedLong.Mutable v = (UnsignedLong.Mutable) obj;\r
- v.setValue(value.longValue());\r
- }\r
- \r
- @Override\r
- public boolean isImmutable() {\r
- return false;\r
- }\r
-\r
- @Override\r
- public Object create(long value) throws BindingException {\r
- return UnsignedLong.Mutable.fromBits(value);\r
- }\r
-\r
- @Override\r
- public Object create(Long value) throws BindingException {\r
- return UnsignedLong.Mutable.fromBits(value);\r
- }\r
-\r
- @Override\r
- public void setValue(Object obj, long value) throws BindingException {\r
- UnsignedLong.Mutable v = (UnsignedLong.Mutable) obj;\r
- v.setValue(value);\r
- }\r
-\r
- @Override\r
- public boolean isInstance(Object obj) {\r
- return obj instanceof UnsignedLong.Mutable;\r
- }\r
- \r
- } \r
- \r
- @Override\r
- public String toString(Object value) throws BindingException {\r
- return value.toString();\r
- }\r
-\r
- @Override\r
- public Long getValue(Object o) throws BindingException {\r
- UnsignedLong v = (UnsignedLong) o;\r
- return v.toBits();\r
- }\r
-\r
- @Override\r
- public long getValue_(Object o) throws BindingException {\r
- UnsignedLong v = (UnsignedLong) o;\r
- return v.toBits();\r
- }\r
-\r
-}\r
+package org.simantics.databoard.binding.impl;
+
+import org.simantics.databoard.binding.LongBinding;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.primitives.UnsignedLong;
+import org.simantics.databoard.type.LongType;
+
+/**
+ * Binding of {@link UnsignedLong} to long type.
+ * This is bitwise binding, i.e. high values are negative.
+ *
+ * @author Toni Kalajainen <toni.kalajainen@iki.fi>
+ */
+public abstract class UnsignedLongBinding extends LongBinding {
+
+ UnsignedLongBinding(LongType type) {
+ super(type);
+ }
+
+ public static class Immutable extends UnsignedLongBinding {
+
+ public Immutable(LongType type) {
+ super(type);
+ }
+
+ @Override
+ public Object create(Number value) throws BindingException {
+ return UnsignedLong.fromBits(value.longValue());
+ }
+
+ @Override
+ public Object create(String value) throws BindingException {
+ try {
+ return new UnsignedLong.Immutable(value);
+ } catch (java.lang.IllegalArgumentException e) {
+ throw new BindingException( e );
+ }
+ }
+
+ @Override
+ public Object create(long value) throws BindingException {
+ return UnsignedLong.fromBits(value);
+ }
+
+ @Override
+ public Object create(Long value) throws BindingException {
+ return UnsignedLong.fromBits(value);
+ }
+
+ @Override
+ public void setValue(Object obj, long value) throws BindingException {
+ throw new BindingException("UnsignedLong is immutable class");
+ }
+
+ @Override
+ public void setValue(Object obj, Number value) throws BindingException {
+ throw new BindingException("UnsignedLong is immutable class");
+ }
+
+ @Override
+ public boolean isImmutable() {
+ return true;
+ }
+
+ @Override
+ public boolean isInstance(Object obj) {
+ return obj instanceof UnsignedLong.Immutable;
+ }
+
+ }
+
+ public static class Mutable extends UnsignedLongBinding {
+
+ public Mutable(LongType type) {
+ super(type);
+ }
+
+ @Override
+ public Object create(Number value) throws BindingException {
+ return UnsignedLong.Mutable.fromBits(value.longValue());
+ }
+
+ @Override
+ public Object create(String value) throws BindingException {
+ return new UnsignedLong.Mutable(value);
+ }
+
+ @Override
+ public void setValue(Object obj, Number value) throws BindingException {
+ UnsignedLong.Mutable v = (UnsignedLong.Mutable) obj;
+ v.setValue(value.longValue());
+ }
+
+ @Override
+ public boolean isImmutable() {
+ return false;
+ }
+
+ @Override
+ public Object create(long value) throws BindingException {
+ return UnsignedLong.Mutable.fromBits(value);
+ }
+
+ @Override
+ public Object create(Long value) throws BindingException {
+ return UnsignedLong.Mutable.fromBits(value);
+ }
+
+ @Override
+ public void setValue(Object obj, long value) throws BindingException {
+ UnsignedLong.Mutable v = (UnsignedLong.Mutable) obj;
+ v.setValue(value);
+ }
+
+ @Override
+ public boolean isInstance(Object obj) {
+ return obj instanceof UnsignedLong.Mutable;
+ }
+
+ }
+
+ @Override
+ public String toString(Object value) throws BindingException {
+ return value.toString();
+ }
+
+ @Override
+ public Long getValue(Object o) throws BindingException {
+ UnsignedLong v = (UnsignedLong) o;
+ return v.toBits();
+ }
+
+ @Override
+ public long getValue_(Object o) throws BindingException {
+ UnsignedLong v = (UnsignedLong) o;
+ return v.toBits();
+ }
+
+}