org.simantics.databoard.accessor.reference
Class ChildReference

java.lang.Object
  extended by org.simantics.databoard.accessor.reference.ChildReference
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
ComponentReference, IndexReference, KeyReference, LabelReference, NameReference

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

Path is a single or multi-level reference to a child node in the tree representation of data value.

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
 ChildReference childReference
           
static java.util.regex.Pattern INDEX_PATTERN
           
static java.util.regex.Pattern MAP_PATTERN
           
static java.util.regex.Pattern NAME_PATTERN
           
 
Method Summary
abstract  ChildReference clone()
           
static ChildReference compile(ChildReference... refs)
          Creates a compilation of individual a references into a one refence.
static ChildReference concatenate(ChildReference pathToBeCloned, ChildReference ref)
          Create a concatenation of two references.
 ChildReference getChildReference()
           
 boolean hasChildReference()
           
static ChildReference parseBinary(byte[] binaryRef)
           
static ChildReference parsePath(java.lang.String path)
          Get reference path from AccessorReference path.
 void setChildReference(ChildReference childReference)
           
 ChildReference 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.
static ChildReference toTypeReference(ChildReference vref, Datatype type)
          Attempt to convert value reference to type reference.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INDEX_PATTERN

public static final java.util.regex.Pattern INDEX_PATTERN

MAP_PATTERN

public static final java.util.regex.Pattern MAP_PATTERN

NAME_PATTERN

public static final java.util.regex.Pattern NAME_PATTERN

childReference

public ChildReference childReference
Method Detail

concatenate

public static ChildReference concatenate(ChildReference pathToBeCloned,
                                         ChildReference 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 ChildReference compile(ChildReference... refs)
Creates a compilation of individual a references into a one refence.

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

parsePath

public static ChildReference parsePath(java.lang.String path)
Get reference path from AccessorReference path. Path Notation

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

toTypeReference

public static ChildReference toTypeReference(ChildReference vref,
                                             Datatype type)
                                      throws java.lang.IllegalArgumentException
Attempt to convert value reference to type reference.

Parameters:
vref -
type -
Returns:
type reference or null
Throws:
java.lang.IllegalArgumentException - if conversion fails.

parseBinary

public static ChildReference parseBinary(byte[] binaryRef)
                                  throws java.io.IOException
Throws:
java.io.IOException

getChildReference

public ChildReference getChildReference()

hasChildReference

public boolean hasChildReference()

setChildReference

public void setChildReference(ChildReference 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 ChildReference clone()
Overrides:
clone in class java.lang.Object

tail

public ChildReference tail()