org.simantics.databoard.accessor.reference
Class AccessorReference

java.lang.Object
  extended by org.simantics.databoard.accessor.reference.AccessorReference
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
ArrayIndexReference, FieldIndexReference, FieldNameReference, KeyReference, LabelReference, OptionalValueReference, TagIndexReference, TagNameReference, TagReference, VariantValueReference

public abstract class AccessorReference
extends java.lang.Object
implements java.lang.Cloneable

AccessorRef is a reference to a child node in the tree representation of a container.

ComponentReference[] is a path from a node to a child or decendent node in the tree representation of the container.

Reference has three serializable formats: Binary, URL compatible Path.

Author:
Toni Kalajainen

Field Summary
static java.util.regex.Pattern ARRAY_ELEMENT_PATTERN
           
 AccessorReference childReference
           
static java.util.regex.Pattern FIELD_INDEX_PATTERN
           
static java.util.regex.Pattern FIELD_NAME_PATTERN
           
static java.util.regex.Pattern MAP_PATTERN
           
static java.util.regex.Pattern UNION_INDEX_PATTERN
           
static java.util.regex.Pattern UNION_NAME_PATTERN
           
 
Method Summary
abstract  AccessorReference clone()
           
static AccessorReference compile(AccessorReference... refs)
          Creates a compilation of individual a references into a one refence.
static AccessorReference concatenate(AccessorReference pathToBeCloned, AccessorReference ref)
          Create a concatenation of two references.
 AccessorReference getChildReference()
           
 boolean hasChildReference()
           
static AccessorReference parseBinary(byte[] binaryRef)
           
static AccessorReference parseString(java.lang.String path)
          Get reference path from AccessorReference path.
 void setChildReference(AccessorReference childReference)
           
 AccessorReference tail()
           
 java.lang.String toPath()
           
 java.lang.String toPath(boolean labelReference)
          Converts the reference path into string representation.
 java.lang.String toString()
          Convert the reference into its string representation
abstract  java.lang.String toString(boolean labelReference)
          Convert the reference into string representation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ARRAY_ELEMENT_PATTERN

public static final java.util.regex.Pattern ARRAY_ELEMENT_PATTERN

MAP_PATTERN

public static final java.util.regex.Pattern MAP_PATTERN

FIELD_INDEX_PATTERN

public static final java.util.regex.Pattern FIELD_INDEX_PATTERN

FIELD_NAME_PATTERN

public static final java.util.regex.Pattern FIELD_NAME_PATTERN

UNION_INDEX_PATTERN

public static final java.util.regex.Pattern UNION_INDEX_PATTERN

UNION_NAME_PATTERN

public static final java.util.regex.Pattern UNION_NAME_PATTERN

childReference

public AccessorReference childReference
Method Detail

parseString

public static AccessorReference parseString(java.lang.String path)
Get reference path from AccessorReference path. Accessor Reference

Parameters:
path -
Returns:
reference path or null if there is no path

parseBinary

public static AccessorReference parseBinary(byte[] binaryRef)
                                     throws SerializationException
Throws:
SerializationException

getChildReference

public AccessorReference getChildReference()

hasChildReference

public boolean hasChildReference()

setChildReference

public void setChildReference(AccessorReference childReference)

toPath

public java.lang.String toPath()

toPath

public java.lang.String toPath(boolean labelReference)
Converts the reference path into string representation.

Parameters:
labelReference - if true return label references.
Returns:
path string representation

toString

public java.lang.String toString()
Convert the reference into its string representation

Overrides:
toString in class java.lang.Object
Returns:
reference string representation

toString

public abstract java.lang.String toString(boolean labelReference)
Convert the reference into string representation.

If labelReference is true, the string representation is more user readable but has weaker typing. It serializes into instances of LabelReference. For instance Record Field Reference is "n-Children", but label reference "Children". Some references cannot be converted into LabelReference. E.g. string representation of FieldNameReference("i-5") is ambiguous with ArrayIndexReference(5).

Parameters:
labelReference - if true returns
Returns:
string representation

clone

public abstract AccessorReference clone()
Overrides:
clone in class java.lang.Object

tail

public AccessorReference tail()

concatenate

public static AccessorReference concatenate(AccessorReference pathToBeCloned,
                                            AccessorReference ref)
Create a concatenation of two references. Prefix part is cloned, suffix is linked.

Parameters:
pathToBeCloned - prefix path, or null
ref - suffix path, or null
Returns:
path

compile

public static AccessorReference compile(AccessorReference... refs)
Creates a compilation of individual a references into a one refence.

Parameters:
refs -
Returns:
reference or null if there are no elements