public class DocumentPath extends Object implements Comparable<DocumentPath>
DocumentTree.| Constructor and Description |
|---|
DocumentPath(String nodeName,
DocumentPath parentPath)
Constructs a new document path.
|
| Modifier and Type | Method and Description |
|---|---|
DocumentPath |
childPath()
Returns the relative path to the given node.
|
int |
compareTo(DocumentPath that) |
boolean |
equals(Object obj) |
static DocumentPath |
from(String path)
Creates a new
DocumentPath from a period delimited path string. |
int |
hashCode() |
boolean |
isAncestorOf(DocumentPath other)
Returns if the specified path belongs to a direct ancestor of the node pointed at by this path.
|
boolean |
isDescendentOf(DocumentPath other)
Returns if the specified path is belongs to a subtree rooted this path.
|
static DocumentPath |
leastCommonAncestor(Collection<DocumentPath> paths)
Returns the path that points to the least common ancestor of the specified
collection of paths.
|
DocumentPath |
parent()
Returns a path for the parent of this node.
|
List<String> |
pathElements()
Returns the list of path elements representing this path in correct
order.
|
String |
toString() |
public DocumentPath(String nodeName, DocumentPath parentPath)
New paths must contain at least one name and string names may NOT contain any period characters.
If one field is null that field will be ignored.
nodeName - the name of the last level of this pathparentPath - the path representing the parent leading up to this
node, in the case of the root this should be nullIllegalDocumentNameException - if both parameters are null or name contains an illegal character ('.')public static DocumentPath from(String path)
DocumentPath from a period delimited path string.path - path stringDocumentPath instancepublic DocumentPath childPath()
public DocumentPath parent()
null.public List<String> pathElements()
public boolean isAncestorOf(DocumentPath other)
Example: root.a is a direct ancestor of r.a.b.c; while r.a.x is not.
other - other pathtrue is yes; false otherwise.public boolean isDescendentOf(DocumentPath other)
Example: root.a.b and root.a.b.c.d.e are descendants of r.a.b;
while r.a.x.c is not.
other - other pathtrue is yes; false otherwise.public static DocumentPath leastCommonAncestor(Collection<DocumentPath> paths)
paths - collection of pathpublic int compareTo(DocumentPath that)
compareTo in interface Comparable<DocumentPath>