Package org.wiremock.url
Interface Path
- All Superinterfaces:
Normalisable<Path>,org.wiremock.stringparser.ParsedString,PercentEncoded<Path>
Represents the path component of a URI as defined in RFC 3986 Section 3.3.
A path consists of a sequence of segments separated by forward slashes. Paths can be absolute
(starting with /) or relative. Path segments may contain percent-encoded characters.
Implementations must be immutable and thread-safe.
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault Pathstatic PathEncodes a string into a valid path with proper percent-encoding.default Segmentdefault SegmentReturns the segments of this path.booleanReturnstrueif this path is absolute (starts with/).default booleanisBase()Returnstrueif this path is a base path (empty, or ends with/).default booleanisEmpty()Returnstrueif this path is empty (has no segments).default booleanisLeaf()Returnstrueif this path is a leaf path (last segment is not empty).default booleanReturnstrueif this path is not absolute (does not start with/).Returns a normalised form of this path with dot segments removed.static Pathstatic Pathstatic PathParses a string into a path.default PathremovePrefix(Path prefix) Resolves the given path against this path using reference resolution rules.default PathReturns this path with a leading slash added if not presentdefault PathReturns this path with a trailing slash added if not present and not emptydefault PathReturns this path with any trailing slash removeddefault PathReturns this path with any leading slash removedMethods inherited from interface org.wiremock.url.Normalisable
isNormalFormMethods inherited from interface org.wiremock.stringparser.ParsedString
toStringMethods inherited from interface org.wiremock.url.PercentEncoded
decode, length
-
Field Details
-
EMPTY
An empty path with no segments. -
ROOT
A root path consisting of a single forward slash.
-
-
Method Details
-
isAbsolute
boolean isAbsolute()Returnstrueif this path is absolute (starts with/).- Returns:
trueif this is an absolute path
-
isRelative
default boolean isRelative()Returnstrueif this path is not absolute (does not start with/).- Returns:
trueif this is a relative path
-
isBase
default boolean isBase()Returnstrueif this path is a base path (empty, or ends with/). e.g./base/- Returns:
trueif this is a base path
-
isLeaf
default boolean isLeaf()Returnstrueif this path is a leaf path (last segment is not empty). e.g./segment/leaf- Returns:
trueif this is a leaf path
-
getSegments
Returns the segments of this path.- Returns:
- the list of path segments, never
null
-
getFirstSegment
-
getLastSegment
-
normalise
Path normalise()Returns a normalised form of this path with dot segments removed.- Specified by:
normalisein interfaceNormalisable<Path>- Returns:
- a normalised path
- See Also:
-
resolve
Resolves the given path against this path using reference resolution rules.- Parameters:
other- the path to resolve- Returns:
- the resolved path
- See Also:
-
isEmpty
default boolean isEmpty()Returnstrueif this path is empty (has no segments).- Specified by:
isEmptyin interfacePercentEncoded<Path>- Returns:
trueif this path is empty
-
toAbsolutePath
Returns this path with a leading slash added if not present -
toRelativePath
Returns this path with any leading slash removed -
toBasePath
Returns this path with a trailing slash added if not present and not empty -
toLeafPath
Returns this path with any trailing slash removed -
parse
Parses a string into a path.- Parameters:
path- the string to parse- Returns:
- the parsed path
- Throws:
IllegalPath- if the string is not a valid path
-
encode
Encodes a string into a valid path with proper percent-encoding.- Parameters:
unencoded- the unencoded string- Returns:
- the encoded path
-
of
-
of
-
removePrefix
-
append
-