Interface ZPath
- All Superinterfaces:
Resolvable
- All Known Implementing Classes:
ZPathImpl
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn a ZPath that represents a child ZNode of this ZPath.static ZPath
Convert individual path names into a ZPath.static ZPath
Convert individual path names into a ZPath.static ZPath
Convert individual path names into a ZPath starting at the given base.static ZPath
Convert individual path names into a ZPath starting at the given base.fullPath()
The string full path that this ZPath representsstatic boolean
Return true if the given string conforms to the "{XXXX}" ID patternboolean
Return true if this path is fully resolved (i.e.boolean
isRoot()
Return true/false if this is the root ZPathnodeName()
The node name at this ZPathstatic String
Returns the special node name that can be used for replacements at runtime viaresolved(Object...)
when passed via the variousfrom()
methodsstatic String
Same asparameter()
but allows you to specify an alternate code/name.parent()
Return this ZPath's parentstatic ZPath
Take a string path and return a ZPath.static ZPath
parse
(String fullPath, UnaryOperator<String> nameFilter) Take a ZNode string path and return a ZPathstatic ZPath
parseWithIds
(String fullPath) Take a string path and return a ZPath.default ZPath
When creating paths, any node in the path can be set toparameter()
.When creating paths, any node in the path can be set toparameter()
.boolean
startsWith
(ZPath path) Return true if this path starts with the given path.Return a regex Pattern useful for using inSchema
-
Field Details
-
root
The root path: "/"
-
-
Method Details
-
parameter
Returns the special node name that can be used for replacements at runtime viaresolved(Object...)
when passed via the variousfrom()
methods -
parameter
Same asparameter()
but allows you to specify an alternate code/name. This name has no effect and is only for debugging purposes. WhentoString()
is called on ZPaths, this code shows. -
parse
Take a string path and return a ZPath.Note: This method always produces a fully resolved path despite the presence of any parameter-like elements (i.e,
{one}
). For substituting parameter elements and for proper parameter resolution status checks, useparseWithIds()
instead.- Parameters:
fullPath
- the path to parse- Returns:
- ZPath
- Throws:
IllegalArgumentException
- if the path is invalid
-
parseWithIds
Take a string path and return a ZPath. Each part of the path that is{XXXX}
is replaced withparameter()
. E.g.parseWithIds("/one/two/{first}/three/{second}")
is the equivalent of callingZPath.from("one", "two", parameter(), "three", parameter())
- Parameters:
fullPath
- the path to parse- Returns:
- ZPath
- Throws:
IllegalArgumentException
- if the path is invalid
-
isId
Return true if the given string conforms to the "{XXXX}" ID pattern- Parameters:
s
- string to check- Returns:
- true/false
-
parse
Take a ZNode string path and return a ZPath- Parameters:
fullPath
- the path to parsenameFilter
- each part of the path is passed through this filter- Returns:
- ZPath
- Throws:
IllegalArgumentException
- if the path is invalid
-
from
Convert individual path names into a ZPath. E.g.ZPath.from("my", "full", "path")
. Any/all of the names can be passed asparameter()
so that the path can be resolved later using of theresolved()
methods.- Parameters:
names
- path names- Returns:
- ZPath
- Throws:
IllegalArgumentException
- if any of the names is invalid
-
from
Convert individual path names into a ZPath. Any/all of the names can be passed asparameter()
so that the path can be resolved later using of theresolved()
methods.- Parameters:
names
- path names- Returns:
- ZPath
- Throws:
IllegalArgumentException
- if any of the names is invalid
-
from
Convert individual path names into a ZPath starting at the given base. E.g. if base is "/home/base"ZPath.from(base, "my", "full", "path")
would be "/home/base/my/full/path". Any/all of the names can be passed asparameter()
so that the path can be resolved later using of theresolved()
methods.- Parameters:
base
- base/starting pathnames
- path names- Returns:
- ZPath
- Throws:
IllegalArgumentException
- if any of the names is invalid
-
from
Convert individual path names into a ZPath starting at the given base. Any/all of the names can be passed asparameter()
so that the path can be resolved later using of theresolved()
methods.- Parameters:
base
- base/starting pathnames
- path names- Returns:
- ZPath
- Throws:
IllegalArgumentException
- if any of the names is invalid
-
resolved
When creating paths, any node in the path can be set to
parameter()
. At runtime, the ZPath can be "resolved" by replacing these nodes with values.The replacement is the
toString()
value of the parameter object or, if the object implementsNodeName
, the value ofnodeName()
.- Specified by:
resolved
in interfaceResolvable
- Parameters:
parameters
- list of replacements. Must have be the same length as the number of parameter nodes in the path- Returns:
- new resolved ZPath
-
resolved
When creating paths, any node in the path can be set to
parameter()
. At runtime, the ZPath can be "resolved" by replacing these nodes with values.The replacement is the
toString()
value of the parameter object or, if the object implementsNodeName
, the value ofnodeName()
.- Specified by:
resolved
in interfaceResolvable
- Parameters:
parameters
- list of replacements. Must have be the same length as the number of parameter nodes in the path- Returns:
- new resolved ZPath
-
child
Return a ZPath that represents a child ZNode of this ZPath. e.g.
ZPath.from("a", "b").at("c")
represents the path "/a/b/c"The replacement is the
toString()
value of child or, if it implementsNodeName
, the value ofnodeName()
.- Parameters:
child
- child node name- Returns:
- ZPath
-
parent
ZPath parent()Return this ZPath's parent- Returns:
- parent ZPath
- Throws:
NoSuchElementException
- if this is the root ZPath
-
isRoot
boolean isRoot()Return true/false if this is the root ZPath- Returns:
- true false
-
isResolved
boolean isResolved()Return true if this path is fully resolved (i.e. has no unresolved parameters).Note: ZPath's returned by the
parse()
method are always considered fully resolved, despite if there are remaining elements in the path which appear to be parameters (but are not, i.e.{one}
).When working with parameters, use the
parseWithIds()
method, which returns a ZPath with a resolved state based on the presence of unresolved parameter elements in the ZPath.- Returns:
- true/false
-
startsWith
Return true if this path starts with the given path. i.e.ZPath.from("/one/two/three").startsWith(ZPath.from("/one/two"))
returns true- Parameters:
path
- base path- Returns:
- true/false
-
fullPath
String fullPath()The string full path that this ZPath represents- Returns:
- full path
-
nodeName
String nodeName()The node name at this ZPath- Returns:
- name
-
toSchemaPathPattern
Pattern toSchemaPathPattern()Return a regex Pattern useful for using inSchema
- Returns:
- pattern for this path
-