4.1.1 Traversal Access

Traversal access typically begins with

Node Session.getRootNode().

From the returned root node, successive levels of child nodes can be accessed with

Node Node.getNode(String relPath),

which takes a relative path (so it can skip down or up multiple levels as well). There is also a similar method for accessing properties,

Property Node.getProperty(String relPath).

The data stored in the property can be accessed either directly with methods like

String Property.getString(),

or in the form of a type-neutral wrapper, the Value object, using

Value Property.getValue().

The actual data can then be retrieved with, for example,

String Value.getString().

Here is an example code snippet:

// Get the root node

Node root = mySession.getRootNode();

// Traverse to the node you want

Node myNode = root.getNode("a/e");

// Retrieve a property of myNode

Property myProperty = myNode.getProperty("k");

// Get the value of the property

Value myValue = myProperty.getValue();

// Convert the value to the desired type

double myDouble = myValue.getDouble();

// The variable myDouble will contain the

// value 6.022 x 10^23