Interface ZPath
-
- All Superinterfaces:
Resolvable
- All Known Implementing Classes:
ZPathImpl
public interface ZPath extends Resolvable
Abstracts a ZooKeeper ZNode path
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ZPathchild(java.lang.Object child)Return a ZPath that represents a child ZNode of this ZPath.static ZPathfrom(java.lang.String... names)Convert individual path names into a ZPath.static ZPathfrom(java.util.List<java.lang.String> names)Convert individual path names into a ZPath.static ZPathfrom(ZPath base, java.lang.String... names)Convert individual path names into a ZPath starting at the given base.static ZPathfrom(ZPath base, java.util.List<java.lang.String> names)Convert individual path names into a ZPath starting at the given base.java.lang.StringfullPath()The string full path that this ZPath representsstatic booleanisId(java.lang.String s)Return true if the given string conforms to the "{XXXX}" ID patternbooleanisResolved()Return true if this path is fully resolved (i.e.booleanisRoot()Return true/false if this is the root ZPathjava.lang.StringnodeName()The node name at this ZPathstatic java.lang.Stringparameter()Returns the special node name that can be used for replacements at runtime viaresolved(Object...)when passed via the variousfrom()methodsstatic java.lang.Stringparameter(java.lang.String name)Same asparameter()but allows you to specify an alternate code/name.ZPathparent()Return this ZPath's parentstatic ZPathparse(java.lang.String fullPath)Take a string path and return a ZPathstatic ZPathparse(java.lang.String fullPath, java.util.function.UnaryOperator<java.lang.String> nameFilter)Take a ZNode string path and return a ZPathstatic ZPathparseWithIds(java.lang.String fullPath)Take a string path and return a ZPath.default ZPathresolved(java.lang.Object... parameters)When creating paths, any node in the path can be set toparameter().ZPathresolved(java.util.List<java.lang.Object> parameters)When creating paths, any node in the path can be set toparameter().booleanstartsWith(ZPath path)Return true if this path starts with the given path.java.util.regex.PatterntoSchemaPathPattern()Return a regex Pattern useful for using inSchema
-
-
-
Field Detail
-
root
static final ZPath root
The root path: "/"
-
-
Method Detail
-
parameter
static java.lang.String parameter()
Returns the special node name that can be used for replacements at runtime viaresolved(Object...)when passed via the variousfrom()methods
-
parameter
static java.lang.String parameter(java.lang.String name)
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
static ZPath parse(java.lang.String fullPath)
Take a string path and return a ZPath- Parameters:
fullPath- the path to parse- Returns:
- ZPath
- Throws:
java.lang.IllegalArgumentException- if the path is invalid
-
parseWithIds
static ZPath parseWithIds(java.lang.String fullPath)
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:
java.lang.IllegalArgumentException- if the path is invalid
-
isId
static boolean isId(java.lang.String s)
Return true if the given string conforms to the "{XXXX}" ID pattern- Parameters:
s- string to check- Returns:
- true/false
-
parse
static ZPath parse(java.lang.String fullPath, java.util.function.UnaryOperator<java.lang.String> nameFilter)
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:
java.lang.IllegalArgumentException- if the path is invalid
-
from
static ZPath from(java.lang.String... names)
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:
java.lang.IllegalArgumentException- if any of the names is invalid
-
from
static ZPath from(java.util.List<java.lang.String> names)
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:
java.lang.IllegalArgumentException- if any of the names is invalid
-
from
static ZPath from(ZPath base, java.lang.String... names)
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:
java.lang.IllegalArgumentException- if any of the names is invalid
-
from
static ZPath from(ZPath base, java.util.List<java.lang.String> names)
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:
java.lang.IllegalArgumentException- if any of the names is invalid
-
resolved
default ZPath resolved(java.lang.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 implementsNodeName, the value ofnodeName().- Specified by:
resolvedin 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
ZPath resolved(java.util.List<java.lang.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 implementsNodeName, the value ofnodeName().- Specified by:
resolvedin 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
ZPath child(java.lang.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 implementsNodeName, the value ofnodeName().- Parameters:
child- child node name- Returns:
- ZPath
-
parent
ZPath parent()
Return this ZPath's parent- Returns:
- parent ZPath
- Throws:
java.util.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 unresoled parameters)- Returns:
- true/false
-
startsWith
boolean startsWith(ZPath path)
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
java.lang.String fullPath()
The string full path that this ZPath represents- Returns:
- full path
-
nodeName
java.lang.String nodeName()
The node name at this ZPath- Returns:
- name
-
toSchemaPathPattern
java.util.regex.Pattern toSchemaPathPattern()
Return a regex Pattern useful for using inSchema- Returns:
- pattern for this path
-
-