X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fsrc%2Forg%2Fsimantics%2Fdataboard%2Fbinding%2Fimpl%2FUnsignedShortBinding.java;h=1a9e4935c7685a65b4887de0617eb64ef7bf02ea;hp=907384d47e4cc8f283edb18b0fc5d4c22ce3caa7;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/UnsignedShortBinding.java b/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/UnsignedShortBinding.java index 907384d47..1a9e4935c 100644 --- a/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/UnsignedShortBinding.java +++ b/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/UnsignedShortBinding.java @@ -1,166 +1,166 @@ -package org.simantics.databoard.binding.impl; - -import org.simantics.databoard.binding.IntegerBinding; -import org.simantics.databoard.binding.error.BindingException; -import org.simantics.databoard.primitives.UnsignedShort; -import org.simantics.databoard.type.IntegerType; - -/** - * Binding of {@link UnsignedShort} to integer type. - * - * @author Toni Kalajainen - */ -public abstract class UnsignedShortBinding extends IntegerBinding { - - UnsignedShortBinding(IntegerType type) { - super(type); - } - - public static class Immutable extends UnsignedShortBinding { - - public Immutable(IntegerType type) { - super(type); - } - - @Override - public Object create(int value) throws BindingException { - try { - return UnsignedShort.fromBits(value); - } catch (java.lang.IllegalArgumentException e) { - throw new BindingException( e ); - } - } - - @Override - public Object create(Integer value) throws BindingException { - try { - return UnsignedShort.valueOf(value.intValue()); - } catch (java.lang.IllegalArgumentException e) { - throw new BindingException( e ); - } - } - - @Override - public Object create(Number value) throws BindingException { - try { - return UnsignedShort.valueOf(value.longValue()); - } catch (java.lang.IllegalArgumentException e) { - throw new BindingException( e ); - } - } - - @Override - public Object create(String value) throws BindingException { - try { - return UnsignedShort.valueOf( Long.valueOf(value) ); - } catch (java.lang.IllegalArgumentException e) { - throw new BindingException( e ); - } - } - - @Override - public void setValue(Object obj, Number value) throws BindingException { - throw new BindingException("UnsignedShort is immutable class"); - } - - @Override - public void setValue(Object obj, int value) throws BindingException { - throw new BindingException("UnsignedShort is immutable class"); - } - - @Override - public boolean isImmutable() { - return true; - } - - @Override - public boolean isInstance(Object obj) { - return obj instanceof UnsignedShort.Immutable; - } - - } - - - public static class Mutable extends UnsignedShortBinding { - - public Mutable(IntegerType type) { - super(type); - } - - @Override - public Object create(int value) throws BindingException { - try { - return new UnsignedShort.Mutable(value); - } catch (java.lang.IllegalArgumentException e) { - throw new BindingException( e ); - } - } - - @Override - public Object create(Integer value) throws BindingException { - try { - return new UnsignedShort.Mutable(value); - } catch (java.lang.IllegalArgumentException e) { - throw new BindingException( e ); - } - } - - @Override - public Object create(Number value) throws BindingException { - try { - return UnsignedShort.Mutable.fromBits(value.intValue()); - } catch (java.lang.IllegalArgumentException e) { - throw new BindingException( e ); - } - } - - @Override - public Object create(String value) throws BindingException { - try { - return new UnsignedShort.Mutable(value); - } catch (java.lang.IllegalArgumentException e) { - throw new BindingException( e ); - } - } - - @Override - public void setValue(Object obj, Number value) throws BindingException { - UnsignedShort.Mutable mi = (UnsignedShort.Mutable) obj; - mi.setBits(value.intValue()); - } - - @Override - public void setValue(Object obj, int value) throws BindingException { - UnsignedShort.Mutable mi = (UnsignedShort.Mutable) obj; - mi.setBits(value); - } - - @Override - public boolean isImmutable() { - return false; - } - - @Override - public boolean isInstance(Object obj) { - return obj instanceof UnsignedShort.Mutable; - } - - } - - @Override - public Integer getValue(Object obj) throws BindingException { - return ((UnsignedShort)obj).toBits(); - } - - @Override - public int getValue_(Object obj) throws BindingException { - return ((UnsignedShort)obj).toBits(); - } - - @Override - public String toString(Object value) throws BindingException { - return value.toString(); - } - - -} +package org.simantics.databoard.binding.impl; + +import org.simantics.databoard.binding.IntegerBinding; +import org.simantics.databoard.binding.error.BindingException; +import org.simantics.databoard.primitives.UnsignedShort; +import org.simantics.databoard.type.IntegerType; + +/** + * Binding of {@link UnsignedShort} to integer type. + * + * @author Toni Kalajainen + */ +public abstract class UnsignedShortBinding extends IntegerBinding { + + UnsignedShortBinding(IntegerType type) { + super(type); + } + + public static class Immutable extends UnsignedShortBinding { + + public Immutable(IntegerType type) { + super(type); + } + + @Override + public Object create(int value) throws BindingException { + try { + return UnsignedShort.fromBits(value); + } catch (java.lang.IllegalArgumentException e) { + throw new BindingException( e ); + } + } + + @Override + public Object create(Integer value) throws BindingException { + try { + return UnsignedShort.valueOf(value.intValue()); + } catch (java.lang.IllegalArgumentException e) { + throw new BindingException( e ); + } + } + + @Override + public Object create(Number value) throws BindingException { + try { + return UnsignedShort.valueOf(value.longValue()); + } catch (java.lang.IllegalArgumentException e) { + throw new BindingException( e ); + } + } + + @Override + public Object create(String value) throws BindingException { + try { + return UnsignedShort.valueOf( Long.valueOf(value) ); + } catch (java.lang.IllegalArgumentException e) { + throw new BindingException( e ); + } + } + + @Override + public void setValue(Object obj, Number value) throws BindingException { + throw new BindingException("UnsignedShort is immutable class"); + } + + @Override + public void setValue(Object obj, int value) throws BindingException { + throw new BindingException("UnsignedShort is immutable class"); + } + + @Override + public boolean isImmutable() { + return true; + } + + @Override + public boolean isInstance(Object obj) { + return obj instanceof UnsignedShort.Immutable; + } + + } + + + public static class Mutable extends UnsignedShortBinding { + + public Mutable(IntegerType type) { + super(type); + } + + @Override + public Object create(int value) throws BindingException { + try { + return new UnsignedShort.Mutable(value); + } catch (java.lang.IllegalArgumentException e) { + throw new BindingException( e ); + } + } + + @Override + public Object create(Integer value) throws BindingException { + try { + return new UnsignedShort.Mutable(value); + } catch (java.lang.IllegalArgumentException e) { + throw new BindingException( e ); + } + } + + @Override + public Object create(Number value) throws BindingException { + try { + return UnsignedShort.Mutable.fromBits(value.intValue()); + } catch (java.lang.IllegalArgumentException e) { + throw new BindingException( e ); + } + } + + @Override + public Object create(String value) throws BindingException { + try { + return new UnsignedShort.Mutable(value); + } catch (java.lang.IllegalArgumentException e) { + throw new BindingException( e ); + } + } + + @Override + public void setValue(Object obj, Number value) throws BindingException { + UnsignedShort.Mutable mi = (UnsignedShort.Mutable) obj; + mi.setBits(value.intValue()); + } + + @Override + public void setValue(Object obj, int value) throws BindingException { + UnsignedShort.Mutable mi = (UnsignedShort.Mutable) obj; + mi.setBits(value); + } + + @Override + public boolean isImmutable() { + return false; + } + + @Override + public boolean isInstance(Object obj) { + return obj instanceof UnsignedShort.Mutable; + } + + } + + @Override + public Integer getValue(Object obj) throws BindingException { + return ((UnsignedShort)obj).toBits(); + } + + @Override + public int getValue_(Object obj) throws BindingException { + return ((UnsignedShort)obj).toBits(); + } + + @Override + public String toString(Object value) throws BindingException { + return value.toString(); + } + + +}