Package io.debezium.document
Interface Path
- All Known Implementing Classes:
Paths.ChildPath,Paths.MultiSegmentPath,Paths.RootPath,Paths.SingleSegmentPath
A representation of multiple name segments that together form a path within
Document.- Author:
- Randall Hauch
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionCreate a new path consisting of this path appended with the given path that will be treated as a relative path.default PathCreate a new path consisting of this path with one or more additional segments given by the relative path.default voidCall the consumer with the path of every ancestor (except root) down to this path.default booleanReturn whether this path has more than one segment.default booleanisRoot()Return whether this path is the root path with no segments.default booleanisSingle()Return whether this path has a single segment.Get the last segment, if there is one.Get anOptionalreference to the root path.parent()Get the optional parent path.static PathParse a JSON Path expression.static PathParse a JSON Path expression.static Pathroot()Get the zero-length path.segment(int index) Get the segment at the given index.intsize()Get the number of segments in the path.subpath(int length) Get a portion of this path that has a specified number of segments.Obtain the representation of this path as a relative path without the leading '/'.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
root
Get the zero-length path.- Returns:
- the shared root path; never null
-
optionalRoot
Get anOptionalreference to the root path. The resulting Optional will alwaysbe present.- Returns:
- the shared optional root path; never null
-
parse
Parse a JSON Path expression. Segments are separated by a single forward slash ('/'); any '~' or '/' literals must be escaped. Trailing slashes are ignored.- Parameters:
path- the path as a string; may not be null, but may be an empty string or "/" for a root path- Returns:
- the path object; never null
-
parse
Parse a JSON Path expression. Segments are separated by a single forward slash ('/'); any '~' or '/' literals must be escaped. Trailing slashes are ignored.- Parameters:
path- the path as a string; may not be null, but may be an empty string or "/" for a root pathresolveJsonPointerEscapes-trueif '~' and '/' literals are to be escaped as '~0' and '~1', respectively, orfalseif they are not to be escaped- Returns:
- the path object; never null
-
isRoot
default boolean isRoot()Return whether this path is the root path with no segments. This method is equivalent tosize() == 0.- Returns:
- true if this path contains exactly one segment, or false otherwise
-
isSingle
default boolean isSingle()Return whether this path has a single segment. This method is equivalent tosize() == 1.- Returns:
- true if this path contains exactly one segment, or false otherwise
-
isMultiple
default boolean isMultiple()Return whether this path has more than one segment. This method is equivalent tosize() > 1.- Returns:
- true if this path contains exactly one segment, or false otherwise
-
size
int size()Get the number of segments in the path.- Returns:
- the size of the path; never negative
-
parent
Get the optional parent path.- Returns:
- an optional containing the parent (if this is not the root path), or an empty optional if this is the root path.
-
lastSegment
Get the last segment, if there is one.- Returns:
- an optional containing the last segment of this path (if this is not the root path), or an empty optional if this is the root path.
-
subpath
Get a portion of this path that has a specified number of segments.- Parameters:
length- the number of segments- Returns:
- the subpath, or this path if the supplied length is equal to
this.size()
-
segment
Get the segment at the given index.- Parameters:
index- the index of the segment- Returns:
- the segment
- Throws:
IllegalArgumentException- if the index value is equal to or greater than #size()
-
append
Create a new path consisting of this path with one or more additional segments given by the relative path.- Parameters:
relPath- the relative path to be appended to this path; may not be null- Returns:
- the new path
-
append
Create a new path consisting of this path appended with the given path that will be treated as a relative path.- Parameters:
relPath- the relative path to be appended to this path; may not be null- Returns:
- the new path
-
toRelativePath
String toRelativePath()Obtain the representation of this path as a relative path without the leading '/'.- Returns:
- the relative path; never null but may be empty
-
fromRoot
Call the consumer with the path of every ancestor (except root) down to this path.- Parameters:
consumer- the function to call on each path segment
-