public interface ZPath extends Resolvable
Modifier and Type | Method and Description |
---|---|
ZPath |
child(Object child)
Return a ZPath that represents a child ZNode of this ZPath.
|
static ZPath |
from(List<String> names)
Convert individual path names into a ZPath.
|
static ZPath |
from(String... names)
Convert individual path names into a ZPath.
|
static ZPath |
from(ZPath base,
List<String> names)
Convert individual path names into a ZPath starting at the given base.
|
static ZPath |
from(ZPath base,
String... names)
Convert individual path names into a ZPath starting at the given base.
|
String |
fullPath()
The string full path that this ZPath represents
|
static boolean |
isId(String s)
Return true if the given string conforms to the "{XXXX}" ID pattern
|
boolean |
isResolved()
Return true if this path is fully resolved (i.e.
|
boolean |
isRoot()
Return true/false if this is the root ZPath
|
String |
nodeName()
The node name at this ZPath
|
static String |
parameter()
Returns the special node name that can be used for replacements at runtime
via
resolved(Object...) when passed via the various from() methods |
static String |
parameter(String name)
Same as
parameter() but allows you to specify an alternate code/name. |
ZPath |
parent()
Return this ZPath's parent
|
static ZPath |
parse(String fullPath)
Take a string path and return a ZPath.
|
static ZPath |
parse(String fullPath,
UnaryOperator<String> nameFilter)
Take a ZNode string path and return a ZPath
|
static ZPath |
parseWithIds(String fullPath)
Take a string path and return a ZPath.
|
ZPath |
resolved(List<Object> parameters)
When creating paths, any node in the path can be set to
parameter() . |
default ZPath |
resolved(Object... parameters)
When creating paths, any node in the path can be set to
parameter() . |
boolean |
startsWith(ZPath path)
Return true if this path starts with the given path.
|
Pattern |
toSchemaPathPattern()
Return a regex Pattern useful for using in
Schema |
static final ZPath root
static String parameter()
resolved(Object...)
when passed via the various from()
methodsstatic String parameter(String name)
parameter()
but allows you to specify an alternate code/name. This name
has no effect and is only for debugging purposes. When toString()
is called
on ZPaths, this code shows.static ZPath parse(String fullPath)
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, use parseWithIds()
instead.
fullPath
- the path to parseIllegalArgumentException
- if the path is invalidstatic ZPath parseWithIds(String fullPath)
{XXXX}
is replaced with parameter()
.
E.g. parseWithIds("/one/two/{first}/three/{second}")
is the equivalent
of calling ZPath.from("one", "two", parameter(), "three", parameter())
fullPath
- the path to parseIllegalArgumentException
- if the path is invalidstatic boolean isId(String s)
s
- string to checkstatic ZPath parse(String fullPath, UnaryOperator<String> nameFilter)
fullPath
- the path to parsenameFilter
- each part of the path is passed through this filterIllegalArgumentException
- if the path is invalidstatic ZPath from(String... names)
ZPath.from("my", "full", "path")
. Any/all of the names can be passed as
parameter()
so that the path can be resolved later using
of the resolved()
methods.names
- path namesIllegalArgumentException
- if any of the names is invalidstatic ZPath from(List<String> names)
parameter()
so that the path can be resolved later using
of the resolved()
methods.names
- path namesIllegalArgumentException
- if any of the names is invalidstatic ZPath from(ZPath base, String... names)
ZPath.from(base, "my", "full", "path")
would be "/home/base/my/full/path". Any/all of the names can be passed as
parameter()
so that the path can be resolved later using
of the resolved()
methods.base
- base/starting pathnames
- path namesIllegalArgumentException
- if any of the names is invalidstatic ZPath from(ZPath base, List<String> names)
parameter()
so that the path can be resolved later using
of the resolved()
methods.base
- base/starting pathnames
- path namesIllegalArgumentException
- if any of the names is invaliddefault ZPath resolved(Object... parameters)
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 implements NodeName
,
the value of nodeName()
.
resolved
in interface Resolvable
parameters
- list of replacements. Must have be the same length as the number of
parameter nodes in the pathZPath resolved(List<Object> parameters)
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 implements NodeName
,
the value of nodeName()
.
resolved
in interface Resolvable
parameters
- list of replacements. Must have be the same length as the number of
parameter nodes in the pathZPath child(Object 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 implements NodeName
,
the value of nodeName()
.
child
- child node nameZPath parent()
NoSuchElementException
- if this is the root ZPathboolean isRoot()
boolean isResolved()
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.
boolean startsWith(ZPath path)
ZPath.from("/one/two/three").startsWith(ZPath.from("/one/two"))
returns truepath
- base pathString fullPath()
String nodeName()
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.