public class TextualPath
extends java.lang.Object
Unlike the standard Java Path class: This isn't just for file system paths and "." and ".." have no special meaning. A TextualPath has no concept of being absolute or relative; it's simplest to think about it as always being absolute and toString represents it that way (with a leading "/"), but if the caller wants to treat it as a relative path it can do that. Also, "/abc" and "/abc/" have the same representation in a TextualPath--they both are a list with one element, "abc", which toString will return as "/abc".
Constructor and Description |
---|
TextualPath()
Create a TextualPath that's empty (that is, points to the root).
|
TextualPath(java.lang.String pathElement1)
Create a TextualPath containing a single path element.
|
TextualPath(java.lang.String pathElement1,
java.lang.String pathElement2) |
TextualPath(java.lang.String pathElement1,
java.lang.String pathElement2,
java.lang.String pathElement3) |
TextualPath(TextualPath parent,
java.lang.String child)
Create a TextualPath that's the same as parent path, except with the new child added at the end.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String pathElement) |
boolean |
equals(java.lang.Object o) |
java.lang.String |
getFirstElement() |
java.lang.String |
getLastElement() |
int |
getLength()
Get the length of the path, the number of path elements contained in it.
|
TextualPath |
getParent()
Get the parent of this path, containing all elements except the last.
|
ArrayList<java.lang.String> |
getPathElements() |
int |
hashCode() |
boolean |
isEmpty()
Check if the path is empty, having no elements.
|
boolean |
startsWith(TextualPath prefixPath)
See if this path starts with another path.
|
java.lang.String |
toString()
Get a human friendly string representation of the path, using / as the delimiter.
|
public TextualPath()
public TextualPath(java.lang.String pathElement1)
pathElement1
- public TextualPath(java.lang.String pathElement1, java.lang.String pathElement2)
public TextualPath(java.lang.String pathElement1, java.lang.String pathElement2, java.lang.String pathElement3)
public TextualPath(TextualPath parent, java.lang.String child)
parent
- parent pathchild
- child element to add at endpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void add(java.lang.String pathElement)
public boolean startsWith(TextualPath prefixPath)
prefixPath
- path that potentially is at beginning of this pathpublic int getLength()
public boolean isEmpty()
public TextualPath getParent()
public ArrayList<java.lang.String> getPathElements()
public java.lang.String getFirstElement()
public java.lang.String getLastElement()
public java.lang.String toString()
toString
in class java.lang.Object