Package com.day.cq.wcm.commons
Class GlobPattern
- java.lang.Object
-
- com.day.cq.wcm.commons.GlobPattern
-
public class GlobPattern extends java.lang.ObjectTheGlobPatternimplements matching operations that do a pattern globbing.
This class is copied fromday-commons-textand should not be used anymore. switch to regexp patterns if possible.
-
-
Constructor Summary
Constructors Constructor Description GlobPattern(java.lang.String pattern)Class constructor that create aGlobPatternwith the given pattern.GlobPattern(java.lang.String pattern, boolean isHandle)Class constructor that create aGlobPatternwith the given pattern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancontainsWildcards(java.lang.String s)Returnstrueif the string contains wildcards.booleanequals(java.lang.Object obj)ReturnstrueifthisGlobPatternis equal to objectobj.inthashCode()Returns the hashCode for thisGlobPattern.static intindexOfWildcard(java.lang.String s)Returns the index of the first wildcard character in the string or-1if the string does not contain a wild card character.booleanmatches(java.lang.String s)Returns a flag indicating whether a string matches this pattern.static booleanmatches(java.lang.String pattern, java.lang.String s)Returns a flag indicating whether a string matches a pattern.static booleanmatches(java.lang.String pattern, java.lang.String s, boolean isHandle)Returns a flag indicating whether a string matches a pattern.booleanshellMatches(java.lang.String s)Returns a flag indicating whether a string matches a pattern.booleanshellMatches(java.lang.String s, char c)Returns a flag indicating whether a string matches a pattern.java.lang.StringtoString()Returns the pattern of thisGlobPattern
-
-
-
Constructor Detail
-
GlobPattern
public GlobPattern(java.lang.String pattern, boolean isHandle)Class constructor that create aGlobPatternwith the given pattern. If theisHandleflag istruethis will construct a hierarchy matcher.- Parameters:
pattern- pattern stringisHandle- iftrueand the pattern contains no wildcards, thematches(String)returns true, if the compared string is equal or starts with the pattern+"/" (i.e. is a child page)
-
GlobPattern
public GlobPattern(java.lang.String pattern)
Class constructor that create aGlobPatternwith the given pattern.- Parameters:
pattern- pattern string
-
-
Method Detail
-
matches
public final boolean matches(java.lang.String s)
Returns a flag indicating whether a string matches this pattern.- Parameters:
s- string to be checked- Returns:
trueif s matches this pattern, elsefalse.
-
matches
public static boolean matches(java.lang.String pattern, java.lang.String s)Returns a flag indicating whether a string matches a pattern.- Parameters:
pattern- pattern used for comparisons- string to be checked- Returns:
trueif s matches pattern, elsefalse.
-
matches
public static boolean matches(java.lang.String pattern, java.lang.String s, boolean isHandle)Returns a flag indicating whether a string matches a pattern. if the ishHandle istrueand the pattern contains no wildcards, the method returns true, if the pattern is a hierarchical father of the string.- Parameters:
pattern- pattern used for comparisons- string to be checkedisHandle- flag, indicating, if a handle comparison has to be performed- Returns:
trueif s matches pattern, elsefalse.
-
shellMatches
public boolean shellMatches(java.lang.String s)
Returns a flag indicating whether a string matches a pattern. unlike thematchesmethods, this matching is done shell-like.- Parameters:
s- string to be checked- Returns:
trueif the string matches shell-like;falseotherwise.
-
shellMatches
public boolean shellMatches(java.lang.String s, char c)Returns a flag indicating whether a string matches a pattern. unlike thematchesmethods, this matching is done shell-like.- Parameters:
s- string to be checkedc- character to be used as path delimiter- Returns:
trueif the string matches shell-like;falseotherwise.
-
containsWildcards
public static boolean containsWildcards(java.lang.String s)
Returnstrueif the string contains wildcards.- Parameters:
s- string to be checked- Returns:
trueif s contains wildcards, elsefalse.
-
indexOfWildcard
public static int indexOfWildcard(java.lang.String s)
Returns the index of the first wildcard character in the string or-1if the string does not contain a wild card character.- Parameters:
s- string to be checked- Returns:
- the index of the first wildcard.
-
toString
public java.lang.String toString()
Returns the pattern of thisGlobPattern- Overrides:
toStringin classjava.lang.Object- Returns:
- the pattern.
-
equals
public boolean equals(java.lang.Object obj)
ReturnstrueifthisGlobPatternis equal to objectobj.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to compare for equality.- Returns:
trueifthisGlobPatternis equal to objectobj.
-
hashCode
public int hashCode()
Returns the hashCode for thisGlobPattern.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashCode for this
GlobPattern.
-
-