org.simantics.databoard.binding
Class VariantBinding

java.lang.Object
  extended by org.simantics.databoard.binding.Binding
      extended by org.simantics.databoard.binding.VariantBinding
All Implemented Interfaces:
java.util.Comparator<java.lang.Object>
Direct Known Subclasses:
ImmutableVariantBinding, ObjectVariantBinding, StringVariantBinding

public abstract class VariantBinding
extends Binding

This is the abstract base class for bindings of VariantType Java Objects. Variant is a container that has value of any Datatype.

Author:
Toni Kalajainen
See Also:
The Datatype, Binds variant to {@link Variant}, Binds variant to {@link MutableVariant}, Binds variant to java.lang.Object, Binds variant to java.lang.String (Filename and URL compatible)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.simantics.databoard.binding.Binding
Binding.Visitor<T>, Binding.Visitor1
 
Constructor Summary
VariantBinding()
           
 
Method Summary
<T> T
accept(Binding.Visitor<T> v)
           
 void accept(Binding.Visitor1 v, java.lang.Object obj)
           
abstract  java.lang.Object create(Binding contentBinding, java.lang.Object content)
          Create a new variant object.
 java.lang.Object createUnchecked(Binding contentBinding, java.lang.Object content)
          Create a new variant object.
 int deepCompare(java.lang.Object o1, java.lang.Object o2, java.util.Set<IdentityPair<java.lang.Object,java.lang.Object>> compareHistory)
           
 int deepHashValue(java.lang.Object value, java.util.IdentityHashMap<java.lang.Object,java.lang.Object> hashedObjects)
          Calculate hash value
 Binding getComponentBinding(ChildReference path)
          Get component binding
 Binding getComponentBinding(int index)
          Get component binding
 int getComponentCount()
          Get component binding count
abstract  java.lang.Object getContent(java.lang.Object variant)
          Get the value of the variant.
abstract  java.lang.Object getContent(java.lang.Object variant, Binding contentBinding)
          Get the value in the variant.
abstract  Binding getContentBinding(java.lang.Object variant)
          Return a suggestion for the binding of the content of this variant.
abstract  Datatype getContentType(java.lang.Object variant)
          Get the data type of the content.
 void readFrom(Binding srcBinding, java.lang.Object src, java.lang.Object dst)
          Read values from another object.
abstract  void setContent(java.lang.Object variant, Binding contentBinding, java.lang.Object content)
          Set the content of an variant.
 
Methods inherited from class org.simantics.databoard.binding.Binding
assertInstaceIsValid, assertInstaceIsValid, clone, cloneUnchecked, compare, createDefault, createDefaultUnchecked, createRandom, createRandomUnchecked, equals, hashValue, isImmutable, isInstance, parseValue, parseValue, parseValueDefinition, printValue, printValueDefinition, serializer, toString, type
 
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

VariantBinding

public VariantBinding()
Method Detail

getContent

public abstract java.lang.Object getContent(java.lang.Object variant,
                                            Binding contentBinding)
                                     throws BindingException
Get the value in the variant. The returned value may represent internal value of variant.

Parameters:
variant - the variant object to read the content from
contentBinding - the format of return value
Returns:
value variant's content
Throws:
BindingException

getContent

public abstract java.lang.Object getContent(java.lang.Object variant)
                                     throws BindingException
Get the value of the variant. The value is bound with the suggested binding, see getContentBinding(Object).

Parameters:
variant - the variant object
Returns:
value variant's content
Throws:
BindingException

getContentType

public abstract Datatype getContentType(java.lang.Object variant)
                                 throws BindingException
Get the data type of the content.

Parameters:
variant - the variant object
Returns:
the data type
Throws:
BindingException

getContentBinding

public abstract Binding getContentBinding(java.lang.Object variant)
                                   throws BindingException
Return a suggestion for the binding of the content of this variant.

Parameters:
variant - variant object
Returns:
binding a binding
Throws:
BindingException

create

public abstract java.lang.Object create(Binding contentBinding,
                                        java.lang.Object content)
                                 throws BindingException
Create a new variant object. The value argument may be included in the result.

Parameters:
contentBinding - the binding of the content
content - content
Returns:
new variant
Throws:
BindingException

createUnchecked

public java.lang.Object createUnchecked(Binding contentBinding,
                                        java.lang.Object content)
                                 throws RuntimeBindingException
Create a new variant object.

Parameters:
contentBinding - binding of the content
content - content
Returns:
new variant
Throws:
RuntimeBindingException

readFrom

public void readFrom(Binding srcBinding,
                     java.lang.Object src,
                     java.lang.Object dst)
              throws BindingException
Description copied from class: Binding
Read values from another object.

Specified by:
readFrom in class Binding
dst - valid object of this binding
Throws:
BindingException

setContent

public abstract void setContent(java.lang.Object variant,
                                Binding contentBinding,
                                java.lang.Object content)
                         throws BindingException
Set the content of an variant.

Parameters:
variant - variant object
contentBinding - content's binding
content - new content
Throws:
BindingException

accept

public void accept(Binding.Visitor1 v,
                   java.lang.Object obj)
Specified by:
accept in class Binding

accept

public <T> T accept(Binding.Visitor<T> v)
Specified by:
accept in class Binding

deepHashValue

public int deepHashValue(java.lang.Object value,
                         java.util.IdentityHashMap<java.lang.Object,java.lang.Object> hashedObjects)
                  throws BindingException
Description copied from class: Binding
Calculate hash value

Specified by:
deepHashValue in class Binding
hashedObjects - collection of already hashed object or optionally null
Returns:
hash value
Throws:
BindingException

deepCompare

public int deepCompare(java.lang.Object o1,
                       java.lang.Object o2,
                       java.util.Set<IdentityPair<java.lang.Object,java.lang.Object>> compareHistory)
                throws BindingException
Specified by:
deepCompare in class Binding
Throws:
BindingException

getComponentBinding

public Binding getComponentBinding(ChildReference path)
Description copied from class: Binding
Get component binding

Specified by:
getComponentBinding in class Binding
Parameters:
path - child path or null to return this.
Returns:
binding

getComponentCount

public int getComponentCount()
Description copied from class: Binding
Get component binding count

Specified by:
getComponentCount in class Binding
Returns:
component count

getComponentBinding

public Binding getComponentBinding(int index)
Description copied from class: Binding
Get component binding

Specified by:
getComponentBinding in class Binding
Returns:
binding