|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectconsciouscode.seedling.NodeReference
public class NodeReference
Identifies a Seedling node by a path relative to a base branch. This class also provides utility methods for finding nodes in a Seedling container.
Put simply, a NodeReference
points from one place in the tree to
another. It's essentially an installed branch ("one place") and a
NodePath
interpreted relative to that branch ("to another").
Unlike a NodePath
, a NodeReference
always denotes a
full path anchored at a root branch. That's true because the base
branch of the reference must have a full path itself.
NodeReferences are immutable and safe for use by multiple threads.
Method Summary | ||
---|---|---|
|
available()
Gets the referenced node, provisioning and installing it if possible. |
|
NodeReference |
child(String name)
Builds a reference to a child of this reference. |
|
boolean |
equals(Object object)
|
|
static NodeReference |
forBranch(BranchNode branch)
Builds a reference to a given branch and the identity path. |
|
static NodeLocation |
forChild(BranchNode branch,
String name)
Builds a reference to the child of a branch. |
|
static NodeReference |
forParts(BranchNode branch,
String... pathParts)
Builds a reference to a node from a base branch and a sequence of path parts. |
|
static NodeReference |
forPath(BranchNode branch,
NodePath path)
Builds a reference to a node from a base branch and a path relative to it. |
|
static NodeReference |
forPath(BranchNode branch,
String path)
Builds a node reference, parsing a given canonical path string into its '/' -separated parts. |
|
static NodeReference |
from(BranchNode branch)
Deprecated. Renamed to forBranch(BranchNode) . |
|
static NodeLocation |
fromChild(BranchNode branch,
String name)
Deprecated. Renamed to forChild(BranchNode, String) . |
|
static NodeReference |
fromParts(BranchNode branch,
String... pathParts)
Deprecated. Renamed to forParts(BranchNode, String...) . |
|
static NodeReference |
fromPath(BranchNode branch,
NodePath path)
Deprecated. Renamed to forPath(BranchNode, NodePath) . |
|
static NodeReference |
fromPath(BranchNode branch,
String path)
Deprecated. Renamed to forPath(BranchNode, String) . |
|
BranchNode |
getBaseBranch()
Returns the branch from which this reference starts its traversal. |
|
Object |
getInstalledNode()
Deprecated. Use installed() instead. |
|
String |
getLocalPath()
Deprecated. Use toLocalPath() instead. |
|
RootNode |
getLocalRoot()
|
|
Object |
getNode()
Deprecated. Use required() instead. |
|
String |
getNodeName()
Returns the name of the identified node. |
|
NodePath |
getNodePath()
Gets the path part of this reference, to be interpreted relative to the base branch. |
|
String |
getPath()
Deprecated. Use getNodePath() instead. |
|
|
installed()
Gets the referenced node, without provisioning it if it's not already installed. |
|
boolean |
isRoot()
Determines whether this is a reference to a RootNode . |
|
NodeReference |
parent()
Returns a reference to the parent branch of this reference. |
|
NodeReference |
parts(String... parts)
Builds a reference to a descendant node from a sequence of parts. |
|
NodeReference |
path(NodePath path)
Builds a reference to a descendant node, extending this with the given path. |
|
NodeReference |
path(String path)
Builds a reference to a descendant node, parsing the given path into its parts. |
|
|
required()
Gets the referenced node, provisioning and installing it if necessary. |
|
NodePath |
toLocalPath()
Returns this node reference as a full local path, valid within the scope of the parent branch. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static NodeReference forBranch(BranchNode branch)
@Deprecated public static NodeReference from(BranchNode branch)
forBranch(BranchNode)
.
public static NodeLocation forChild(BranchNode branch, String name)
branch
- must not be null.name
- must be a simple name, not a path. It must not contain
any slash ('/'
) characters. It must not be null or empty.@Deprecated public static NodeLocation fromChild(BranchNode branch, String name)
forChild(BranchNode, String)
.
public static NodeReference forParts(BranchNode branch, String... pathParts)
If the first part is "/"
then the resulting reference is
equivalent to one from the root of the given branch.
branch
- must not be null.pathParts
- the parts of the path.
None of the parts may be null or empty.NodePath.forParts(String...)
@Deprecated public static NodeReference fromParts(BranchNode branch, String... pathParts)
forParts(BranchNode, String...)
.
public static NodeReference forPath(BranchNode branch, String path)
'/'
-separated parts.
branch
- is the base for traversing the path. It must not be null.path
- is interpreted relative to the branch. It may also be a
full path.NodePath.forPath(String)
@Deprecated public static NodeReference fromPath(BranchNode branch, String path)
forPath(BranchNode, String)
.
public static NodeReference forPath(BranchNode branch, NodePath path)
If the path isFull()
then the resulting
reference is equivalent to one from the root of the given branch.
branch
- must not be null.path
- the path relative to the branch.@Deprecated public static NodeReference fromPath(BranchNode branch, NodePath path)
forPath(BranchNode, NodePath)
.
@Deprecated public String getLocalPath()
toLocalPath()
instead.
"/"
.public final NodeReference child(String name)
name
- the name of the child node.
public NodeReference parent()
public final NodeReference parts(String... parts)
parts
-
public final NodeReference path(NodePath path)
path
- the extension.
public final NodeReference path(String path)
path
-
public final BranchNode getBaseBranch()
public final NodePath getNodePath()
NodePath.isIdentity()
,
then the target of this reference is its
base branch
.getBaseBranch()
@Deprecated public final String getPath()
getNodePath()
instead.
base branch
.getBaseBranch()
public NodePath toLocalPath()
NodePath
, not null.public String getNodeName()
public RootNode getLocalRoot()
public boolean isRoot()
RootNode
.
@Deprecated public final Object getNode() throws NodeProvisioningException, NoSuchNodeException
required()
instead.
NodeProvisioningException
- if there was an error provisioning
the node.
NoSuchNodeException
- if the requested node doesn't exist and has
no configuration, or if the path traverses an intermediate node that's
not a BranchNode
.BranchNode.getChild(String)
public final <T> T available() throws NodeProvisioningException
This method will return null
if any node in the path is not
installed and cannot be provisioned.
NodeProvisioningException
- if there was an error provisioning
the node.required()
,
installed()
,
BranchNode.availableChild(String)
@Deprecated public final Object getInstalledNode()
installed()
instead.
BranchNode.installedChild(String)
public final <T> T installed()
available()
,
required()
,
BranchNode.installedChild(String)
public final <T> T required() throws NodeProvisioningException, NoSuchNodeException
This method will not return null
; see available()
and
installed()
for alternatives.
NoSuchNodeException
- if the node isn't installed and its parent
branch cannot provision it on demand. This usually means that there's
no applicable configuration for the node.
Also thrown if the path traverses an intermediate node that's
not a BranchNode
.
NodeProvisioningException
- if there was an error provisioning
the node.available()
,
installed()
public final boolean equals(Object object)
Two NodeReference
s are considered equal if they have the same
global path.
equals
in class Object
public final String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |