org.simantics.databoard.binding
Class NumberBinding

java.lang.Object
  extended by org.simantics.databoard.binding.Binding
      extended by org.simantics.databoard.binding.NumberBinding
All Implemented Interfaces:
java.util.Comparator<java.lang.Object>
Direct Known Subclasses:
ByteBinding, DoubleBinding, FloatBinding, IntegerBinding, LongBinding

public abstract class NumberBinding
extends Binding

Super class for number types.

Author:
Toni Kalajainen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.simantics.databoard.binding.Binding
Binding.Visitor<T>, Binding.Visitor1
 
Constructor Summary
NumberBinding()
           
 
Method Summary
 void assertInstaceIsValid(java.lang.Object obj, java.util.Set<java.lang.Object> validInstances)
          Assert the obj is a valid number.
abstract  java.lang.Object create(java.lang.Number value)
          Create value by converting it from any Number instance to a Number instance of this Binding type.
abstract  java.lang.Object create(java.lang.String value)
          Creates a value from its string representation
 java.lang.Object createUnchecked(java.lang.Number value)
           
 java.lang.Object createUnchecked(java.lang.String value)
           
 java.lang.Number getValue(java.lang.Object obj)
          Get numeric value of an object
abstract  void setValue(java.lang.Object obj, java.lang.Number value)
           
 NumberType type()
          Get Data type
 
Methods inherited from class org.simantics.databoard.binding.Binding
accept, accept, assertInstaceIsValid, clone, cloneUnchecked, compare, createDefault, createDefaultUnchecked, createRandom, createRandomUnchecked, deepCompare, deepHashValue, equals, hashValue, isImmutable, isInstance, main, parseValue, parseValue, parseValueDefinition, printValue, printValueDefinition, serializer, serializer, serializerUnchecked, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

NumberBinding

public NumberBinding()
Method Detail

create

public abstract java.lang.Object create(java.lang.Number value)
                                 throws BindingException
Create value by converting it from any Number instance to a Number instance of this Binding type. NOTE WARNING! Using this method may lose precision or value in the conversion. E.g. Double to Integer, or Long to Byte

Parameters:
value -
Returns:
the value in the format of the binding type
Throws:
BindingException

create

public abstract java.lang.Object create(java.lang.String value)
                                 throws BindingException
Creates a value from its string representation

Parameters:
value -
Returns:
number
Throws:
BindingException

type

public NumberType type()
Get Data type

Overrides:
type in class Binding
Returns:
data type

getValue

public java.lang.Number getValue(java.lang.Object obj)
                          throws BindingException
Get numeric value of an object

Parameters:
obj - object
Returns:
Number
Throws:
BindingException - thrown if obj is incorrect class

setValue

public abstract void setValue(java.lang.Object obj,
                              java.lang.Number value)
                       throws BindingException
Throws:
BindingException

assertInstaceIsValid

public void assertInstaceIsValid(java.lang.Object obj,
                                 java.util.Set<java.lang.Object> validInstances)
                          throws BindingException
Assert the obj is a valid number. This asserts 1. The value is within the range defined in the NumberType

Specified by:
assertInstaceIsValid in class Binding
Parameters:
obj - the instance
validInstances - optional set of already validated instances
Throws:
BindingException

createUnchecked

public java.lang.Object createUnchecked(java.lang.String value)
                                 throws RuntimeBindingException
Throws:
RuntimeBindingException

createUnchecked

public java.lang.Object createUnchecked(java.lang.Number value)
                                 throws RuntimeBindingException
Throws:
RuntimeBindingException