public class QualifiedPath extends java.lang.Object implements java.io.Serializable, Path
Modifier and Type | Class and Description |
---|---|
static class |
QualifiedPath.Builder
A builder to assist in constructing
QualifiedPath s. |
static class |
QualifiedPath.Part |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
COMPONENTID_SEPERATOR |
protected static java.lang.String |
PART_SEPERATOR |
protected static java.lang.String |
SUBPART_SEPERATOR |
Constructor and Description |
---|
QualifiedPath() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
QualifiedPath |
extend(java.lang.String id,
java.lang.String value)
Returns a path with the provided component added on at the end.
|
java.lang.String |
getFirstPathComponent() |
java.lang.String |
getFirstPathComponentId() |
java.lang.String |
getLastPathComponent()
Convenience function to return the last path element.
|
java.lang.String |
getLastPathComponentId() |
QualifiedPath |
getParentPath()
Returns a path representing the element above the current path.
|
QualifiedPath.Part |
getPart(int i) |
protected QualifiedPath.Part[] |
getPartsFor(java.lang.String id)
Returns all of the sub parts for a specified id, or null if they don't
exist.
|
java.lang.String |
getPathComponent(int i)
Returns the path element at the specified location.
|
java.lang.String |
getPathComponent(java.lang.String id) |
int |
getPathLength()
Returns the number of elements in the path, which can be retrieved through getPathComponent().
|
int |
hashCode() |
boolean |
hasPathComponent(java.lang.String id) |
protected int |
indexOf(java.lang.String id) |
QualifiedPath |
insert(java.lang.String id,
java.lang.String value,
java.lang.String beforeComponentId)
Locates the component specified and inserts the new component before it.
|
boolean |
isAncestorOf(Path child)
Returns whether the provided path is a child path of this one.
|
static QualifiedPath |
of(java.lang.String... idValPairs)
Creates a path out of the specified id/value pairs.
|
static QualifiedPath |
parse(java.lang.String value)
Attempts to parse the string into an QualifiedPath.
|
static QualifiedPath |
parseSafe(java.lang.String value)
Same as parse(), but catches exceptions and returns null on bad paths.
|
protected static java.util.List<QualifiedPath.Part> |
parseSubParts(java.lang.String id,
java.lang.String value)
Returns at least one part for the root, with id.
|
QualifiedPath |
prepend(java.lang.String id,
java.lang.String value)
Returns a new path with the provided component added at the beginning.
|
QualifiedPath |
replace(java.lang.String id,
java.lang.String value)
If the component specified by the given id exists in the path, the value
will be replaced with the new value.
|
QualifiedPath |
strip()
Removes the last fully-qualified component from the path.
|
QualifiedPath |
subpath()
Removes the first path component and returns the rest as a new path.
|
java.lang.String |
toString() |
java.lang.String |
toStringSimple()
Returns the path in a friendlier to read form, without component ids.
|
protected static final java.lang.String SUBPART_SEPERATOR
protected static final java.lang.String PART_SEPERATOR
protected static final java.lang.String COMPONENTID_SEPERATOR
public static QualifiedPath of(java.lang.String... idValPairs)
idValPairs
- public QualifiedPath extend(java.lang.String id, java.lang.String value)
id
- value
- public QualifiedPath prepend(java.lang.String id, java.lang.String value)
id
- value
- public QualifiedPath insert(java.lang.String id, java.lang.String value, java.lang.String beforeComponentId)
id
- value
- beforeComponentId
- public int getPathLength()
Path
getPathLength
in interface Path
@Nullable public QualifiedPath.Part getPart(int i)
public java.lang.String getPathComponent(int i)
Path
getPathComponent
in interface Path
public java.lang.String getLastPathComponent()
Path
getLastPathComponent
in interface Path
@Nullable public java.lang.String getLastPathComponentId()
public java.lang.String getFirstPathComponent()
public java.lang.String getFirstPathComponentId()
public QualifiedPath subpath()
public QualifiedPath strip()
public QualifiedPath replace(java.lang.String id, java.lang.String value)
protected int indexOf(java.lang.String id)
@Nullable public java.lang.String getPathComponent(@Nullable java.lang.String id)
@Nullable protected QualifiedPath.Part[] getPartsFor(@Nullable java.lang.String id)
id
- public boolean hasPathComponent(java.lang.String id)
public QualifiedPath getParentPath()
Path
getParentPath
in interface Path
@Nonnull public java.lang.String toString()
toString
in class java.lang.Object
@Nonnull public java.lang.String toStringSimple()
public boolean isAncestorOf(Path child)
Path
isAncestorOf
in interface Path
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public static QualifiedPath parse(java.lang.String value) throws java.io.IOException
java.io.IOException
public static QualifiedPath parseSafe(java.lang.String value)
protected static java.util.List<QualifiedPath.Part> parseSubParts(java.lang.String id, java.lang.String value)
id
- value
-