org.simantics.databoard.binding
Class RecordBinding

java.lang.Object
  extended by org.simantics.databoard.binding.Binding
      extended by org.simantics.databoard.binding.RecordBinding
All Implemented Interfaces:
java.util.Comparator<java.lang.Object>
Direct Known Subclasses:
ConstantBinding, VoidBinding

public abstract class RecordBinding
extends Binding

This is a binding of a Record Type and a Java Object.

Author:
Hannu Niemisto, Toni Kalajainen
See Also:
RecordType

Nested Class Summary
 
Nested classes/interfaces inherited from class org.simantics.databoard.binding.Binding
Binding.Visitor<T>, Binding.Visitor1
 
Field Summary
 Binding[] componentBindings
           
 
Constructor Summary
RecordBinding()
           
 
Method Summary
<T> T
accept(Binding.Visitor<T> v)
           
 void accept(Binding.Visitor1 v, java.lang.Object obj)
           
 void assertInstaceIsValid(java.lang.Object obj, java.util.Set<java.lang.Object> validInstances)
          Assert obj is valid Record Type This asserts all fields are valid.
abstract  java.lang.Object create(java.lang.Object... values)
          Create a record using values.
abstract  java.lang.Object createPartial()
          Creates partial and most likely invalid instance.
 java.lang.Object createUnchecked(java.lang.Object... values)
           
 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
abstract  java.lang.Object getComponent(java.lang.Object obj, int index)
           
 Binding getComponentBinding(ChildReference path)
          Get component binding
 Binding getComponentBinding(int fieldIndex)
          Get component binding
 Binding getComponentBinding(java.lang.String fieldName)
          Get binding by field name
 Binding[] getComponentBindings()
           
 int getComponentCount()
          Get component binding count
 void readFrom(Binding srcBinding, java.lang.Object src, java.lang.Object dst)
          Read values from another object.
abstract  void setComponent(java.lang.Object obj, int index, java.lang.Object value)
           
abstract  void setComponents(java.lang.Object obj, java.lang.Object... value)
           
 void setComponentsUnchecked(java.lang.Object obj, java.lang.Object... value)
           
 void setComponentUnchecked(java.lang.Object obj, int index, java.lang.Object value)
           
 RecordType type()
          Get Value Type
 
Methods inherited from class org.simantics.databoard.binding.Binding
assertInstaceIsValid, clone, cloneUnchecked, compare, createDefault, createDefaultUnchecked, createRandom, createRandomUnchecked, equals, hashValue, isImmutable, isInstance, parseValue, parseValue, parseValueDefinition, printValue, printValueDefinition, serializer, 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
 

Field Detail

componentBindings

public Binding[] componentBindings
Constructor Detail

RecordBinding

public RecordBinding()
Method Detail

getComponentBinding

public Binding getComponentBinding(java.lang.String fieldName)
Get binding by field name

Parameters:
fieldName -
Returns:
binding or null

getComponentBinding

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

Specified by:
getComponentBinding in class Binding
Returns:
binding

getComponentBindings

public Binding[] getComponentBindings()

type

public RecordType type()
Description copied from class: Binding
Get Value Type

Overrides:
type in class Binding
Returns:
value type

getComponentCount

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

Specified by:
getComponentCount in class Binding
Returns:
component count

getComponent

public abstract java.lang.Object getComponent(java.lang.Object obj,
                                              int index)
                                       throws BindingException
Throws:
BindingException

create

public abstract java.lang.Object create(java.lang.Object... values)
                                 throws BindingException
Create a record using values. Note! values may be consumed (used in the result)

Parameters:
values -
Returns:
new record
Throws:
BindingException

createPartial

public abstract java.lang.Object createPartial()
                                        throws BindingException
Creates partial and most likely invalid instance. This is used in two-phase construction of recursive instances.

Returns:
instance.
Throws:
BindingException

setComponents

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

setComponent

public abstract void setComponent(java.lang.Object obj,
                                  int index,
                                  java.lang.Object value)
                           throws BindingException
Throws:
BindingException

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

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

assertInstaceIsValid

public void assertInstaceIsValid(java.lang.Object obj,
                                 java.util.Set<java.lang.Object> validInstances)
                          throws BindingException
Assert obj is valid Record Type This asserts all fields are valid.

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

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

createUnchecked

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

setComponentsUnchecked

public void setComponentsUnchecked(java.lang.Object obj,
                                   java.lang.Object... value)
                            throws RuntimeBindingException
Throws:
RuntimeBindingException

setComponentUnchecked

public void setComponentUnchecked(java.lang.Object obj,
                                  int index,
                                  java.lang.Object value)
                           throws RuntimeBindingException
Throws:
RuntimeBindingException

getComponentBinding

public Binding getComponentBinding(ChildReference path)
                            throws java.lang.IllegalArgumentException
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
Throws:
java.lang.IllegalArgumentException - if path cannot be applied to this binding