java.lang.Object
com.aoapps.net.pathspace.Prefix
- All Implemented Interfaces:
Serializable
,Comparable<Prefix>
Path prefix for wildcard matching support.
- Author:
- AO Industries, Inc.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The set of supported multi-level nesting types. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
The natural ordering is such that an iterative call tomatches(com.aoapps.net.Path)
will return.boolean
conflictsWith
(Prefix other) Checks if two prefixes are conflicting.boolean
getBase()
Gets the base of this path space.Gets the multi-level type attached to the base and any wildcard levels.int
Gets the number of wildcard levels attached to the base.int
hashCode()
int
Checks if a given path matches this prefix.toString()
Gets the unambiguous string representation of this prefix.static Prefix
valueOf
(Path base, int wildcards, Prefix.MultiLevelType multiLevelType) Gets an instance of a prefix given the individual fields.static Prefix
Parses the unambiguous string representation of a prefix.
-
Field Details
-
WILDCARD_CHAR
public static final char WILDCARD_CHARThe character used for wildcards.- See Also:
-
WILDCARD_SUFFIX
-
UNBOUNDED_SUFFIX
-
GREEDY_SUFFIX
-
-
Method Details
-
valueOf
Gets an instance of a prefix given the individual fields.- Parameters:
base
- May not benull
. May not end in "/" unless it is the root "/". May not end in "/*", "/**", or "/***". May not contain "/*/", "/**/", or "/***/" to avoid any expectations of infix matching, which is not supported.wildcards
- Must be>= 0
. Must be>= 1
when multiLevelType isPrefix.MultiLevelType.NONE
multiLevelType
- May not benull
- See Also:
-
valueOf
Parses the unambiguous string representation of a prefix.This is the inverse function of
toString()
.- Parameters:
prefix
- The prefix to parse. Must adhere to all rules ofvalueOf(com.aoapps.net.Path, int, com.aoapps.net.pathspace.Prefix.MultiLevelType)
- See Also:
-
hashCode
public int hashCode() -
equals
-
toString
Gets the unambiguous string representation of this prefix.This is the inverse function of
valueOf(java.lang.String)
. -
compareTo
The natural ordering is such that an iterative call tomatches(com.aoapps.net.Path)
will return.true
on the most specific matching space. This match is consistent withPathSpace.get(com.aoapps.net.Path)
.This ordering is useful for human review, as it represents the path space conceptually in a top-to-bottom list.
The implementation of TODO: Link findSpace, should be much faster than an iterative search, however.
TODO: There are no ordering guarantees between prefixes that
conflict with one another
?- Specified by:
compareTo
in interfaceComparable<Prefix>
- See Also:
-
getBase
Gets the base of this path space. This does not include any trailing wildcard or multi-level suffixes. This will not end in a slash (/) unless this is the root "/" (Path.ROOT
) itself. -
getWildcards
public int getWildcards()Gets the number of wildcard levels attached to the base. This will be at least one whengetMultiLevelType()
isPrefix.MultiLevelType.NONE
. Otherwise, may also be zero. -
getMultiLevelType
Gets the multi-level type attached to the base and any wildcard levels. -
conflictsWith
Checks if two prefixes are conflicting. Conflicts include either occupying the same space or a subspace of another greedy space, with all wildcards considered. -
matches
Checks if a given path matches this prefix.- Returns:
- the number of characters in the path that match the prefix or
-1
for no match. When matches the root, returns0
.
-