org.simantics.databoard.type
Class RecordType

java.lang.Object
  extended by org.simantics.databoard.type.Datatype
      extended by org.simantics.databoard.type.RecordType
All Implemented Interfaces:
java.lang.Cloneable

public class RecordType
extends Datatype


Nested Class Summary
 
Nested classes/interfaces inherited from class org.simantics.databoard.type.Datatype
Datatype.Visitor<T>, Datatype.Visitor1
 
Field Summary
static java.lang.String KEY_IDENTIFIER
           
static java.lang.String KEY_REFERABLE
           
static Datatype VOID_TYPE
           
 
Fields inherited from class org.simantics.databoard.type.Datatype
metadata
 
Constructor Summary
RecordType()
           
RecordType(boolean referable, Component... components)
           
 
Method Summary
<T> T
accept(Datatype.Visitor<T> v)
           
 void accept(Datatype.Visitor1 v, java.lang.Object obj)
           
 void addComponent(java.lang.String name, Datatype type)
           
 Component getComponent(int index)
          Get component by index.
 Component getComponent(java.lang.String fieldName)
          Get component by name.
 int getComponentCount()
          Get component type count
 java.lang.Integer getComponentIndex(java.lang.String fieldName)
          Get component by name.
 int getComponentIndex2(java.lang.String fieldName)
          Get component by name.
 Component[] getComponents()
           
 Datatype getComponentType(ChildReference path)
          Get component type
 Datatype getComponentType(int index)
          Get component type by index
 Datatype getComponentType(java.lang.String fieldName)
          Get component Datatype by field name
 int[] getIdentifiers()
          Get an array of indices that describe which fields compose the identifier of this record
 Datatype getIdentifierType()
          Get a datatype that describes the identifier of this type.
 int hashCode()
           
 boolean isIdentifier(int fieldIndex)
           
 boolean isReferable()
           
 boolean isTupleType()
          Return true if the record is a tuple.
 void removeComponent(java.lang.String name)
           
 void setComponents(Component[] components)
           
 void setIdentifiers(int... indices)
          Set which fields compose the identifier of this record
 void setIdentifiers(java.util.List<java.lang.Integer> indices)
          Set which fields compose the identifier of this record
 void setReferable(boolean referable)
           
 
Methods inherited from class org.simantics.databoard.type.Datatype
equals, metadataHashCode, toSingleLineString, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VOID_TYPE

public static final Datatype VOID_TYPE

KEY_REFERABLE

public static final java.lang.String KEY_REFERABLE
See Also:
Constant Field Values

KEY_IDENTIFIER

public static final java.lang.String KEY_IDENTIFIER
See Also:
Constant Field Values
Constructor Detail

RecordType

public RecordType()

RecordType

public RecordType(boolean referable,
                  Component... components)
Method Detail

isReferable

public boolean isReferable()

setReferable

public void setReferable(boolean referable)

setComponents

public void setComponents(Component[] components)

addComponent

public void addComponent(java.lang.String name,
                         Datatype type)

removeComponent

public void removeComponent(java.lang.String name)

getComponentCount

public int getComponentCount()
Description copied from class: Datatype
Get component type count

Specified by:
getComponentCount in class Datatype
Returns:
component count

hashCode

public int hashCode()
Overrides:
hashCode in class Datatype

accept

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

accept

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

isTupleType

public boolean isTupleType()
Return true if the record is a tuple. Tuple is a record with all components are named as a number, the index number of the field. Empty record is a tuple

Returns:
true if the record type is a tuple.

getComponentType

public Datatype getComponentType(int index)
Get component type by index

Specified by:
getComponentType in class Datatype
Parameters:
index - index
Returns:
componenet type or null if index was invalid

getComponentType

public Datatype getComponentType(ChildReference path)
                          throws java.lang.IllegalArgumentException
Description copied from class: Datatype
Get component type

Specified by:
getComponentType in class Datatype
Parameters:
path - child path or null to return this.
Returns:
datatype
Throws:
java.lang.IllegalArgumentException - if path cannot be applied to this type

getComponentIndex

public java.lang.Integer getComponentIndex(java.lang.String fieldName)
Get component by name.

Parameters:
fieldName - component name
Returns:
component index or null if one does not exist

getComponentIndex2

public int getComponentIndex2(java.lang.String fieldName)
Get component by name.

Parameters:
fieldName - component name
Returns:
component index or -1 if one does not exist

getComponentType

public Datatype getComponentType(java.lang.String fieldName)
Get component Datatype by field name

Parameters:
fieldName -
Returns:
datatype or null

getComponent

public Component getComponent(java.lang.String fieldName)
Get component by name.

Parameters:
fieldName - component name
Returns:
component or null if one does not exist

getComponent

public Component getComponent(int index)
Get component by index.

Parameters:
index - component index
Returns:
component or null if one does not exist

getComponents

public Component[] getComponents()

getIdentifiers

public int[] getIdentifiers()
Get an array of indices that describe which fields compose the identifier of this record

Returns:
indices

setIdentifiers

public void setIdentifiers(int... indices)
Set which fields compose the identifier of this record

Parameters:
indices -

setIdentifiers

public void setIdentifiers(java.util.List<java.lang.Integer> indices)
Set which fields compose the identifier of this record

Parameters:
indices -

isIdentifier

public boolean isIdentifier(int fieldIndex)

getIdentifierType

public Datatype getIdentifierType()
Get a datatype that describes the identifier of this type. If no field has Identifier annotation, the result is null. If more than one field is an identifier the type is a record with all composing fields.

Returns:
identifier type or null