|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simantics.databoard.Databoard
public class Databoard
Field Summary | |
---|---|
AdapterFactory |
adapterFactory
Adapter Factory |
Binding |
BEAN
|
BindingRepository |
bindingRepository
Repository of class Bindings |
ClassBindingFactory |
classBindingFactory
Reflection based Binding Factory, create binding to class |
TypeBindingFactory |
defaultBindingFactory
Default Bindings Factory |
java.util.Map<Datatype,Binding> |
defaultBindingRepository
Repository of default bindings |
TypeBindingFactory |
mutableBindingFactory
Mutable Bindings Factory |
java.util.Map<Datatype,Binding> |
mutableBindingRepository
Repository of mutable bindings |
VariantBinding |
OBJECT
|
SerializerFactory |
serializationFactory
Serializer Factory |
java.util.Map<Binding,Serializer> |
serializerRepository
Repository of serializers |
VariantBinding |
STR_VARIANT
|
TypeClassFactory |
typeClassFactory
Class Factory |
VariantBinding |
VARIANT
|
Constructor Summary | |
---|---|
Databoard()
|
Method Summary | ||
---|---|---|
java.lang.Object |
adapt(java.lang.Object value,
Binding domain,
Binding range)
Adapt a value of one type to another. |
|
java.lang.Object |
adaptUnchecked(java.lang.Object value,
Binding domain,
Binding range)
Adapt a value of one type to another. |
|
void |
addBinding(Binding binding,
java.lang.Class<?> clazz,
java.lang.Class<?>... parameters)
Add a simple binding to reflection binding factory. |
|
void |
addBindingFactory(BindingSubFactory factory)
Add binding factory for compositive bindings |
|
java.lang.Object |
clone(java.lang.Object value,
Binding domain,
Binding range)
Adapt and clone a value instance to another type. |
|
java.lang.Object |
cloneUnchecked(java.lang.Object value,
Binding domain,
Binding range)
Clone a value of one binding to another. |
|
int |
compare(Binding b1,
java.lang.Object o1,
Binding b2,
java.lang.Object o2)
Compares two data values for order. |
|
java.util.Comparator<java.lang.Object> |
createComparator(Binding b1,
Binding b2)
|
|
boolean |
equals(Binding b1,
java.lang.Object o1,
Binding b2,
java.lang.Object o2)
Compare two data values for equality. |
|
Adapter |
getAdapter(Binding domain,
Binding range)
Create an adapter that adapts two bindings of the same data type. |
|
Adapter |
getAdapterUnchecked(Binding domain,
Binding range)
Create an adapter that adapts between two bindings of the same data type. |
|
Binding |
getBeanBinding(Datatype type)
Create binding from datatype that instantiates java classes. |
|
BindingRequest |
getBeanBindingRequest(Datatype type)
Creates a bean class |
|
java.lang.Class<?> |
getBeanClass(Datatype type)
Creates a bean class |
|
|
getBinding(BindingRequest request)
|
|
|
getBinding(java.lang.Class<?> clazz)
Get a binding to a Java Class. |
|
|
getBinding(java.lang.Class<?> clazz,
java.lang.Class<?>... parameters)
Get a binding for a Java Class. |
|
|
getBinding(Datatype type)
Get or create a binding based on default java classes, such as Integer.class, or byte[].class. |
|
|
getBindingUnchecked(java.lang.Class<?> clazz)
Read binding and type from a class. |
|
|
getBindingUnchecked(java.lang.Class<?> clazz,
java.lang.Class<?>... parameters)
Get a binding for a Java Class. |
|
|
getMutableBinding(Datatype type)
Get or create a binding that is completely mutable java class. |
|
Serializer |
getSerializer(Binding binding)
Get serializer that follows Databoard serialization spec. |
|
Serializer |
getSerializer(java.lang.Class<?> clazz)
Get serializer that follows Databoard serialization spec. |
|
Serializer |
getSerializerUnchecked(Binding binding)
Get serializer that follows Databoard serialization spec. |
|
Serializer |
getSerializerUnchecked(java.lang.Class<?> clazz)
Get serializer that follows Databoard serialization spec. |
|
Adapter |
getTypeAdapter(Binding domain,
Binding range)
Create a type adapter that adapts instances from one Datatype to another. |
|
Adapter |
getTypeAdapterUnchecked(Binding domain,
Binding range)
Create a type adapter that adapts instances from one DataType to another. |
|
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 final java.util.Map<Datatype,Binding> mutableBindingRepository
public final java.util.Map<Datatype,Binding> defaultBindingRepository
public final BindingRepository bindingRepository
public final java.util.Map<Binding,Serializer> serializerRepository
public final TypeBindingFactory mutableBindingFactory
public final TypeBindingFactory defaultBindingFactory
public final ClassBindingFactory classBindingFactory
public final SerializerFactory serializationFactory
public final AdapterFactory adapterFactory
public final TypeClassFactory typeClassFactory
public final VariantBinding VARIANT
public final VariantBinding OBJECT
public final VariantBinding STR_VARIANT
public final Binding BEAN
Constructor Detail |
---|
public Databoard()
Method Detail |
---|
public <T extends Binding> T getMutableBinding(Datatype type)
type
- the type to create binding to
public <T extends Binding> T getBinding(Datatype type)
type
- the type to create binding to
public <T extends Binding> T getBinding(java.lang.Class<?> clazz) throws BindingConstructionException
Whether the result is a completely mutable or not depends on the requested class. 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 <T extends Binding> T getBinding(BindingRequest request) throws BindingConstructionException
BindingConstructionException
public <T extends Binding> T getBinding(java.lang.Class<?> clazz, java.lang.Class<?>... parameters) throws BindingConstructionException
Example 1:
Binding binding = getBinding(Map.class, String.class, Integer.class);
Map
> list = (List
>) d.createRandom(5);
clazz
-
BindingConstructionException
ClassBindingFactory
public <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 for well-known classes where the caller is 100% sure that a binding is construable without exception.
clazz
-
RuntimeBindingConstructionException
public <T extends Binding> T getBindingUnchecked(java.lang.Class<?> clazz, java.lang.Class<?>... parameters) throws RuntimeBindingConstructionException
Example 1:
Binding binding = getBinding(Map.class, String.class, Integer.class);
Map
> list = (List
>) d.createRandom(5);
clazz
-
BindingConstructionException
RuntimeBindingConstructionException
ClassBindingFactory
public void addBinding(Binding binding, java.lang.Class<?> clazz, java.lang.Class<?>... parameters)
binding
- clazz
- parameters
- parameter classespublic void addBindingFactory(BindingSubFactory factory)
factory
- public BindingRequest getBeanBindingRequest(Datatype type) throws RuntimeBindingConstructionException
type
-
RuntimeBindingConstructionException
public java.lang.Class<?> getBeanClass(Datatype type) throws BindingConstructionException
type
-
BindingConstructionException
public Binding getBeanBinding(Datatype type) throws RuntimeBindingConstructionException
type
-
RuntimeBindingConstructionException
public Serializer getSerializer(Binding binding) throws SerializerConstructionException
binding
-
SerializerConstructionException
public Serializer getSerializerUnchecked(Binding binding) throws RuntimeSerializerConstructionException
binding
-
RuntimeSerializerConstructionException
public Serializer getSerializer(java.lang.Class<?> clazz) throws SerializerConstructionException
clazz
-
SerializerConstructionException
public Serializer getSerializerUnchecked(java.lang.Class<?> clazz) throws RuntimeSerializerConstructionException
clazz
-
RuntimeSerializerConstructionException
public Adapter getAdapter(Binding domain, Binding range) throws AdapterConstructionException
domain
- binding of the source instancerange
- binding of the result instance
AdapterConstructionException
public Adapter getAdapterUnchecked(Binding domain, Binding range) throws RuntimeAdapterConstructionException
domain
- binding of the source instancerange
- binding of the result instance
AdapterConstructionException
RuntimeAdapterConstructionException
public Adapter getTypeAdapter(Binding domain, Binding range) throws AdapterConstructionException
AdaptException
is thrown at runtime, if number conversion is not
posible, e.g. converting value 500 from Integer to Byte.
Note, there is also a possibility of precision loss, in many conversions
e.g. from double to int.
domain
- binding of the source instancerange
- binding of the result instance
AdapterConstructionException
public 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 java.lang.Object adapt(java.lang.Object value, Binding domain, Binding range) throws AdaptException
value
- domain
- range
-
AdapterConstructionException
AdaptException
public java.lang.Object adaptUnchecked(java.lang.Object value, Binding domain, Binding range) throws RuntimeAdapterConstructionException, RuntimeAdaptException
value
- domain
- range
-
AdapterConstructionException
AdaptException
RuntimeAdapterConstructionException
RuntimeAdaptException
public java.lang.Object clone(java.lang.Object value, Binding domain, Binding range) throws AdaptException
value
- domain
- range
-
AdapterConstructionException
AdaptException
public java.lang.Object cloneUnchecked(java.lang.Object value, Binding domain, Binding range) throws RuntimeAdapterConstructionException, RuntimeAdaptException
value
- domain
- range
-
AdapterConstructionException
AdaptException
RuntimeAdapterConstructionException
RuntimeAdaptException
public 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 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 java.util.Comparator<java.lang.Object> createComparator(Binding b1, Binding b2)
public 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 |