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:
ClassBinding, ConstantBinding, ThrowableBinding, 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
 boolean getBoolean(java.lang.Object r, int index)
           
 byte getByte(java.lang.Object r, int index)
           
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
 int getComponentIndex(java.lang.String fieldName)
           
 double getDouble(java.lang.Object r, int index)
           
 float getFloat(java.lang.Object r, int index)
           
 int getInt(java.lang.Object r, int index)
           
 long getLong(java.lang.Object r, int index)
           
 boolean isImmutable()
          Return true if the value is immutable.
 void readFrom(Binding srcBinding, java.lang.Object src, java.lang.Object dst)
          Read values from one object to another.
 void setBoolean(java.lang.Object r, int index, boolean z)
           
 void setByte(java.lang.Object r, int index, byte x)
           
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)
           
 void setDouble(java.lang.Object r, int index, double x)
           
 void setFloat(java.lang.Object r, int index, float x)
           
 void setInt(java.lang.Object r, int index, int x)
           
 void setLong(java.lang.Object r, int index, long x)
           
 RecordType type()
          Get Value Type
 
Methods inherited from class org.simantics.databoard.binding.Binding
assertInstaceIsValid, clone, cloneUnchecked, compare, createDefault, createDefaultUnchecked, createRandom, createRandom, createRandom, createRandomUnchecked, equals, hashValue, isInstance, parseValue, parseValue, parseValueDefinition, printValue, printValueDefinition, readFromTry, readFromTryUnchecked, readFromUnchecked, serializer, toString, 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

getComponentIndex

public int getComponentIndex(java.lang.String fieldName)

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 one object to another.

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

isImmutable

public boolean isImmutable()
Description copied from class: Binding
Return true if the value is immutable. This question excludes the immutability of the component types.

Overrides:
isImmutable in class Binding
Returns:
true value if immutable

setBoolean

public void setBoolean(java.lang.Object r,
                       int index,
                       boolean z)
                throws BindingException
Throws:
BindingException

getBoolean

public boolean getBoolean(java.lang.Object r,
                          int index)
                   throws BindingException
Throws:
BindingException

setByte

public void setByte(java.lang.Object r,
                    int index,
                    byte x)
             throws BindingException
Throws:
BindingException

getByte

public byte getByte(java.lang.Object r,
                    int index)
             throws BindingException
Throws:
BindingException

setInt

public void setInt(java.lang.Object r,
                   int index,
                   int x)
            throws BindingException
Throws:
BindingException

getInt

public int getInt(java.lang.Object r,
                  int index)
           throws BindingException
Throws:
BindingException

setLong

public void setLong(java.lang.Object r,
                    int index,
                    long x)
             throws BindingException
Throws:
BindingException

getLong

public long getLong(java.lang.Object r,
                    int index)
             throws BindingException
Throws:
BindingException

setFloat

public void setFloat(java.lang.Object r,
                     int index,
                     float x)
              throws BindingException
Throws:
BindingException

getFloat

public float getFloat(java.lang.Object r,
                      int index)
               throws BindingException
Throws:
BindingException

setDouble

public void setDouble(java.lang.Object r,
                      int index,
                      double x)
               throws BindingException
Throws:
BindingException

getDouble

public double getDouble(java.lang.Object r,
                        int index)
                 throws BindingException
Throws:
BindingException