User Tools

Site Tools


jrodos:technical_notes:dataitems:path

Data Path

Data Path is the sequence of dataitem names from the top the dataitem tree separated by IDataItem.separator1).

Data path can be obtained by function:

public String getDataPath()

Example

ComplexDataItem x = new ComplexDatItem ("x");
ComplexDataItem y = new ComplexDatItem ("y");
ComplexDataItem z = new ComplexDatItem ("z");
 
x.addDataItem (y);
y.addDataItem (z);
 
System.out.println (z.getDataPath()); // prints x=;=y=;=z

Dataitem can be obtained by its path by function:

public IDataItem getDataItemByPath (String path)

Function getDataItemByPath should be called from dataitem which is the first item in the path.

Example

ComplexDataItem x = new ComplexDatItem ("x");
ComplexDataItem y = new ComplexDatItem ("y");
ComplexDataItem z = new ComplexDatItem ("z");
 
x.addDataItem (y);
y.addDataItem (z);
 
String dis = IDataItem.separator; 
x.getDataItemByPath ("x" + dis + "y" + dis + "z"); // get z
y.getDataItemByPath ("x" + IDataItem.separator + "y" + IDataItem.separator + "z"); // error
y.getDataItemByPath ("y" + IDataItem.separator + "z"); // get z

For the moment every dataitem has one and only one data path. But one data path can specify sevral dataitems. Between two IDataItem.separator char sequences sevral names can be put separated by IDataItem.pathseparator2). Function getDataItemByPath find first correspondent dataitem if it exists.

Example

String dis = IDataItem.separator; 
String dips = IDataItem.pathseparator; 
 
ComplexDataItem x = new ComplexDatItem ("x");
ComplexDataItem y = new ComplexDatItem ("y");
ComplexDataItem z = new ComplexDatItem ("z");
 
x.addDataItem (y);
y.addDataItem (z);
 
String path = "x" + dis + "a" + dips + "y" + dis + "z"; // "x=;=a|y=;=z"
x.getDataItemByPath (path); // get z
1) =;=
2) |
jrodos/technical_notes/dataitems/path.txt · Last modified: 2015/03/24 15:32 (external edit)