Package org.refcodes.matcher
Class PathMatcherImpl
- java.lang.Object
-
- org.refcodes.matcher.PathMatcherImpl
-
- All Implemented Interfaces:
Matcher<java.lang.String>
,PathMatcher
,org.refcodes.mixin.DelimiterAccessor
public class PathMatcherImpl extends java.lang.Object implements PathMatcher
Implements thePathMatcher
interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.DelimiterAccessor
org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
-
-
Constructor Summary
Constructors Constructor Description PathMatcherImpl(java.lang.String aPathPattern)
Constructs an ANT PathMatcher
, matching its ANT path pattern against the path provided to theisMatching(String)
method.PathMatcherImpl(java.lang.String aPathPattern, char aDelimiter)
Constructs an ANT PathMatcher
, matching its ANT path pattern against the path provided to theisMatching(String)
method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
char
getDelimiter()
java.lang.String
getPathPattern()
Returns the path pattern being used by thePathMatcher
.java.lang.String[]
getWildcardNames()
Retrieves the list of wildcard names identifying the wildcards as specified by the path pattern.int
hashCode()
boolean
isMatching(java.lang.String aPath)
The this method applies the following rules from the configured ANT path pattern to the path provided viaPathMatcher.isMatching(String)
method: A single asterisk ("*") matches zero or more characters within a path name.java.lang.String
toPattern()
For debugging purposes, retrieve the regex pattern created from the ANT path pattern.java.lang.String
toWildcardReplacement(java.lang.String aPath, java.lang.String aWildcardName)
Returns the wildcard substitute for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
).java.lang.String
toWildcardReplacementAt(java.lang.String aPath, int aIndex)
Returns the wildcard substitute for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
).java.lang.String[]
toWildcardReplacements(java.lang.String aPath)
Returns an array of the wildcard substitutes for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
).java.lang.String[]
toWildcardReplacements(java.lang.String aPath, java.lang.String... aWildcardNames)
Returns the wildcard substitutes for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
).java.lang.String[]
toWildcardReplacementsAt(java.lang.String aPath, int... aIndexes)
Returns the wildcard substitutes for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
).WildcardSubstitutes
toWildcardSubstitutes(java.lang.String aPath)
Returns all available wildcard substitutes as well as the named wildcard substitutes.
-
-
-
Constructor Detail
-
PathMatcherImpl
public PathMatcherImpl(java.lang.String aPathPattern)
Constructs an ANT PathMatcher
, matching its ANT path pattern against the path provided to theisMatching(String)
method. Theorg.refcodes.data.Delimiter#PATH
is used as default path delimiter. ThePathMatcherImpl
applies the following rules from the ANT path pattern to the path provided viaisMatching(String)
method: A single asterisk ("*") matches zero or more characters within a path name. A double asterisk ("**") matches zero or more characters across directory levels. A question mark ("?") matches exactly one character within a path name.- Parameters:
aPathPattern
- The pattern to be used when matching a path viaisMatching(String)
.
-
PathMatcherImpl
public PathMatcherImpl(java.lang.String aPathPattern, char aDelimiter)
Constructs an ANT PathMatcher
, matching its ANT path pattern against the path provided to theisMatching(String)
method. Theorg.refcodes.data.Delimiter#PATH
is used as default path delimiter. ThePathMatcherImpl
applies the following rules from the ANT path pattern to the path provided viaisMatching(String)
method: A single asterisk ("*") matches zero or more characters within a path name. A double asterisk ("**") matches zero or more characters across directory levels. A question mark ("?") matches exactly one character within a path name.- Parameters:
aPathPattern
- The pattern to be used when matching a path viaisMatching(String)
.aDelimiter
- The delimiter separating the path elements from each other and must not be one of the following chars: '?', '*', '|'.- Throws:
java.lang.IllegalArgumentException
- thrown in case the delimiter provided was one of the following chars: '?', '*', '|'.
-
-
Method Detail
-
getWildcardNames
public java.lang.String[] getWildcardNames()
Retrieves the list of wildcard names identifying the wildcards as specified by the path pattern.- Specified by:
getWildcardNames
in interfacePathMatcher
- Returns:
- The wild card names or null of no wild card names have been defined.
-
getPathPattern
public java.lang.String getPathPattern()
Returns the path pattern being used by thePathMatcher
.- Specified by:
getPathPattern
in interfacePathMatcher
- Returns:
- The path pattern being used.
-
isMatching
public boolean isMatching(java.lang.String aPath)
The this method applies the following rules from the configured ANT path pattern to the path provided viaPathMatcher.isMatching(String)
method: A single asterisk ("*") matches zero or more characters within a path name. A double asterisk ("**") matches zero or more characters across directory levels. A question mark ("?") matches exactly one character within a path name Tests whether the given event is matching the mathcer's criteria.- Specified by:
isMatching
in interfaceMatcher<java.lang.String>
- Specified by:
isMatching
in interfacePathMatcher
- Parameters:
aPath
- The matchee used for testing matchability.- Returns:
- True in case the matchee matches the matcher's criteria, else false.
-
toWildcardSubstitutes
public WildcardSubstitutes toWildcardSubstitutes(java.lang.String aPath)
Returns all available wildcard substitutes as well as the named wildcard substitutes.- Specified by:
toWildcardSubstitutes
in interfacePathMatcher
- Parameters:
aPath
- The path for which to retrieve the wildcard substitutes.- Returns:
- The
WildcardSubstitutes
of the wildcards being substituted.
-
toWildcardReplacements
public java.lang.String[] toWildcardReplacements(java.lang.String aPath)
Returns an array of the wildcard substitutes for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
). The order of the wildcard substitutes aligns to the order of the wildcards (from left to right) defined in your path pattern.- Specified by:
toWildcardReplacements
in interfacePathMatcher
- Parameters:
aPath
- The path for which to retrieve the wildcard substitutes.- Returns:
- The text substituting the wildcards in the order of the wildcards being substituted or null if there are none such substitutes.
-
toWildcardReplacementAt
public java.lang.String toWildcardReplacementAt(java.lang.String aPath, int aIndex)
Returns the wildcard substitute for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
). The text of the wildcard substitute aligns to the index of the wildcard (from left to right) as defined in your path pattern.- Specified by:
toWildcardReplacementAt
in interfacePathMatcher
- Parameters:
aPath
- The path for which to retrieve the wildcard substitutes.aIndex
- The index of the wildcard in question for which to retrieve the substitute.- Returns:
- The text substituting the wildcard at the given path pattern's wildcard index or null if there is none such substitute.
-
toWildcardReplacementsAt
public java.lang.String[] toWildcardReplacementsAt(java.lang.String aPath, int... aIndexes)
Returns the wildcard substitutes for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
). The text of the wildcard substitutes aligns to the indexes of the wildcard (from left to right) as defined in your path pattern.- Specified by:
toWildcardReplacementsAt
in interfacePathMatcher
- Parameters:
aPath
- The path for which to retrieve the wildcard substitutes.aIndexes
- The indexes of the wildcards in question for which to retrieve the substitutes.- Returns:
- The text substituting the wildcards at the given path pattern's wildcard indexes or null if there is none such substitute.
-
toWildcardReplacement
public java.lang.String toWildcardReplacement(java.lang.String aPath, java.lang.String aWildcardName)
Returns the wildcard substitute for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
). The text of the wildcard substitute aligns to the name of the wildcard (as defined in your path pattern).- Specified by:
toWildcardReplacement
in interfacePathMatcher
- Parameters:
aPath
- The path for which to retrieve the wildcard substitutes.aWildcardName
- The name of the wildcard in question for which to retrieve the substitute.- Returns:
- The text substituting the wildcard with the given path pattern's wildcard name or null if there is none such substitute.
-
toWildcardReplacements
public java.lang.String[] toWildcardReplacements(java.lang.String aPath, java.lang.String... aWildcardNames)
Returns the wildcard substitutes for the wildcards in your path pattern (seePathMatcher.getPathPattern()
) compared to the actual path (as ofPathMatcher.toWildcardSubstitutes(String)
). The text of the wildcard substitutes aligns to the order of the provided wildcard names (as defined in your path pattern).- Specified by:
toWildcardReplacements
in interfacePathMatcher
- Parameters:
aPath
- The path for which to retrieve the wildcard substitutes.aWildcardNames
- The names of the wildcards in question for which to retrieve the substitutes in the order of the provided names.- Returns:
- The text substituting the wildcard with the given path pattern's wildcard names or null if there are none such substitute.
-
toPattern
public java.lang.String toPattern()
For debugging purposes, retrieve the regex pattern created from the ANT path pattern.- Returns:
- Returns the regex created from the ANT path pattern.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getDelimiter
public char getDelimiter()
- Specified by:
getDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor
-
-