|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simantics.databoard.Bindings
public class Bindings
This ia a facade class for the binding services.
Constructor Summary | |
---|---|
Bindings()
|
Method Summary | ||
---|---|---|
static java.lang.Object |
adapt(java.lang.Object value,
Binding domain,
Binding range)
Adapt a value of one type to another. |
|
static java.lang.Object |
adaptUnchecked(java.lang.Object value,
Binding domain,
Binding range)
Adapt a value of one type to another |
|
static java.lang.Object |
clone(java.lang.Object value,
Binding domain,
Binding range)
Clone a value to another type to another. |
|
static java.lang.Object |
cloneUnchecked(java.lang.Object value,
Binding domain,
Binding range)
Clone a value of one binding to another. |
|
static int |
compare(Binding b1,
java.lang.Object o1,
Binding b2,
java.lang.Object o2)
Compares its two data values for order. |
|
static java.util.Comparator<java.lang.Object> |
createComparator(Binding b1,
Binding b2)
|
|
static boolean |
equals(Binding b1,
java.lang.Object o1,
Binding b2,
java.lang.Object o2)
Compare two data values for equality. |
|
static Adapter |
getAdapter(Binding domain,
Binding range)
Create an adapter that adapts two bindings of the same data type. |
|
static Adapter |
getAdapterUnchecked(Binding domain,
Binding range)
Create an adapter that adapts between two bindings of the same data type. |
|
static
|
getBinding(java.lang.Class<?> clazz)
Get a binding to a Java Class. |
|
static
|
getBinding(java.lang.Class<?> clazz,
java.lang.Class<?>... parameters)
Get a binding to a Java Class. |
|
static
|
getBinding(Datatype type)
Get a binding that uses default java classes, such as Integer.class, or byte[].class. |
|
static
|
getBindingUnchecked(java.lang.Class<?> clazz)
Read binding and type from a class. |
|
static
|
getMutableBinding(Datatype type)
Get a binding to a DataType that is completely mutable java class. |
|
static Serializer |
getSerializer(Binding binding)
Get serializer that follows Databoard serialization spec. |
|
static Serializer |
getSerializer(java.lang.Class<?> clazz)
Get serializer that follows Databoard serialization spec. |
|
static Serializer |
getSerializerUnchecked(Binding binding)
Get serializer that follows Databoard serialization spec. |
|
static Serializer |
getSerializerUnchecked(java.lang.Class<?> clazz)
Get serializer that follows Databoard serialization spec. |
|
static Adapter |
getTypeAdapter(Binding domain,
Binding range)
Create a type adapter that adapts instances from one DataType to another. |
|
static Adapter |
getTypeAdapterUnchecked(Binding domain,
Binding range)
Create a type adapter that adapts instances from one DataType to another. |
|
static java.lang.String |
toString(java.lang.Object o)
Print the content of an object as a structure. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.Map<Datatype,Binding> mutableBindingRepository
public static final java.util.Map<Datatype,Binding> defaultBindingRepository
public static final java.util.Map<BindingRequest,Binding> reflectionBindingRepository
public static final java.util.Map<Binding,Serializer> serializerRepository
public static final BindingFactory mutableBindingFactory
public static final BindingFactory defaultBindingFactory
public static final ReflectionBindingFactory reflectionBindingFactory
public static final SerializerFactory defaultSerializationFactory
public static final AdapterFactory adapterFactory
public static final StringBinding STRING
public static final IntegerBinding INTEGER
public static final BooleanBinding BOOLEAN
public static final ByteBinding BYTE
public static final LongBinding LONG
public static final DoubleBinding DOUBLE
public static final FloatBinding FLOAT
public static final ObjectVariantBinding OBJECT
public static final VariantBinding VARIANT
public static final VariantBinding STR_VARIANT
public static final ArrayBinding BOOLEAN_ARRAY
public static final ArrayBinding BYTE_ARRAY
public static final ArrayBinding INT_ARRAY
public static final ArrayBinding LONG_ARRAY
public static final ArrayBinding FLOAT_ARRAY
public static final ArrayBinding DOUBLE_ARRAY
public static final ArrayBinding STRING_ARRAY
public static final IntegerBinding UNSIGNED_INTEGER
public static final ByteBinding UNSIGNED_BYTE
public static final LongBinding UNSIGNED_LONG
public static final StringBinding MUTABLE_STRING
public static final IntegerBinding MUTABLE_INTEGER
public static final BooleanBinding MUTABLE_BOOLEAN
public static final ByteBinding MUTABLE_BYTE
public static final LongBinding MUTABLE_LONG
public static final FloatBinding MUTABLE_FLOAT
public static final DoubleBinding MUTABLE_DOUBLE
public static final VariantBinding MUTABLE_VARIANT
public static final IntegerBinding MUTABLE_UNSIGNED_INTEGER
public static final ByteBinding MUTABLE_UNSIGNED_BYTE
public static final LongBinding MUTABLE_UNSIGNED_LONG
Constructor Detail |
---|
public Bindings()
Method Detail |
---|
public static <T extends Binding> T getMutableBinding(Datatype type)
type
-
public static <T extends Binding> T getBinding(Datatype type)
type
-
public static <T extends Binding> T getBinding(java.lang.Class<?> clazz) throws BindingConstructionException
The whether the result binding is a completely mutable or not depends on the provided classes. For instance, fields such as Boolean, Integer, Long are not mutable, instead MutableBoolean, MutableInteger and MutableLong are. The length of Object[] is not mutable, but length of List
public static <T extends Binding> T getBinding(java.lang.Class<?> clazz, java.lang.Class<?>... parameters) throws BindingConstructionException
Example 1:
Binding binding = Bindings.getBinding(Map.class, String.class, Integer.class);
Map
> list = (List
>) d.createRandom(5);
clazz
-
BindingConstructionException
ReflectionBindingFactory
public static <T extends Binding> T getBindingUnchecked(java.lang.Class<?> clazz) throws RuntimeBindingConstructionException
As an exception, in the subclasses of Throwable
, the fields of
Throwable are omited.
This method is used when the caller is 100% sure that binding will be constructed without exceptions. Such classes are all primitive types (Double, Integer, etc, arrays, DataType, ...) This method is unchecked if binding construction to the clazz cannot be trusted. If construction fails, a RuntimeException is thrown.
clazz
-
RuntimeBindingConstructionException
public static Serializer getSerializer(Binding binding) throws SerializerConstructionException
binding
-
SerializerConstructionException
public static Serializer getSerializerUnchecked(Binding binding) throws RuntimeSerializerConstructionException
binding
-
RuntimeSerializerConstructionException
public static Serializer getSerializer(java.lang.Class<?> clazz) throws SerializerConstructionException
clazz
-
SerializerConstructionException
public static Serializer getSerializerUnchecked(java.lang.Class<?> clazz) throws RuntimeSerializerConstructionException
clazz
-
RuntimeSerializerConstructionException
public static Adapter getAdapter(Binding domain, Binding range) throws AdapterConstructionException
domain
- binding of the source instancerange
- binding of the result instance
AdapterConstructionException
public static Adapter getAdapterUnchecked(Binding domain, Binding range) throws RuntimeAdapterConstructionException
domain
- binding of the source instancerange
- binding of the result instance
AdapterConstructionException
RuntimeAdapterConstructionException
public static Adapter getTypeAdapter(Binding domain, Binding range) throws AdapterConstructionException
AdaptException
is thrown at runtime, if number values are
not compatible, e.g. converting value 500 from Long to Byte.
Note, there is also a possibility of precision loss, e.g. when
converting from double to int.
domain
- binding of the source instancerange
- binding of the result instance
AdapterConstructionException
public static Adapter getTypeAdapterUnchecked(Binding domain, Binding range)
AdaptException
is thrown at runtime, if number values are
not compatible, e.g. converting value 500 from Long to Byte.
Note, there is also a possibility of precision loss, e.g. when
converting from double to int.
domain
- binding of the source instancerange
- binding of the result instance
AdapterConstructionException
public static java.lang.Object adapt(java.lang.Object value, Binding domain, Binding range) throws AdaptException
value
- domain
- range
-
AdapterConstructionException
AdaptException
public static java.lang.Object adaptUnchecked(java.lang.Object value, Binding domain, Binding range) throws RuntimeAdapterConstructionException, RuntimeAdaptException
value
- domain
- range
-
AdapterConstructionException
AdaptException
RuntimeAdapterConstructionException
RuntimeAdaptException
public static java.lang.Object clone(java.lang.Object value, Binding domain, Binding range) throws AdaptException
value
- domain
- range
-
AdapterConstructionException
AdaptException
public static java.lang.Object cloneUnchecked(java.lang.Object value, Binding domain, Binding range) throws RuntimeAdapterConstructionException, RuntimeAdaptException
value
- domain
- range
-
AdapterConstructionException
AdaptException
RuntimeAdapterConstructionException
RuntimeAdaptException
public static int compare(Binding b1, java.lang.Object o1, Binding b2, java.lang.Object o2) throws BindingException
DataTypes of b1 and b2 are not equal then data types are compared.
The comparison function is defined at http://dev.simantics.org/index.php/Org.simantics.datatype_Manual#CompareTo_and_Equals
Note, comparing 2 different number types will not result a value comparison. Instead values have the following type precedence ByteType, IntegerType, LongType, FloatType, and the highest DoubleType.
b1
- Binding of o1o1
- the first object to be compared.b2
- Binding of o2o2
- the second object to be compared.
BindingException
- if object cannot be handled by a bindingpublic static boolean equals(Binding b1, java.lang.Object o1, Binding b2, java.lang.Object o2) throws BindingException
Note, comparing 2 different number types will not result a value comparison. Instead values have the following type precedence ByteType, IntegerType, LongType, FloatType, and the highest DoubleType.
b1
- o1
- b2
- o2
-
BindingException
public static java.util.Comparator<java.lang.Object> createComparator(Binding b1, Binding b2)
public static java.lang.String toString(java.lang.Object o)
o
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |