Package com.day.text
Class GlobPattern
- java.lang.Object
-
- com.day.text.GlobPattern
-
public class GlobPattern extends Object
TheGlobPattern
implements matching operations that do a pattern globbing.
-
-
Constructor Summary
Constructors Constructor Description GlobPattern(String pattern)
Class constructor that create aGlobPattern
with the given pattern.GlobPattern(String pattern, boolean ishandle)
Class constructor that create aGlobPattern
with the given pattern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
containsWildcards(String s)
Returnstrue
if the string contains wildcards.boolean
equals(Object obj)
Returnstrue
ifthis
GlobPattern
is equal to objectobj
.int
hashCode()
Returns the hashCode for thisGlobPattern
.static int
indexOfWildcard(String s)
Returns the index of the first wildcard character in the string or-1
if the string does not contain a wild card character.boolean
matches(String s)
Returns a flag indicating whether a string matches this pattern.static boolean
matches(String pattern, String s)
Returns a flag indicating whether a string matches a pattern.static boolean
matches(String pattern, String s, boolean ishandle)
Returns a flag indicating whether a string matches a pattern.boolean
shellMatches(String s)
Returns a flag indicating whether a string matches a pattern.boolean
shellMatches(String s, char c)
Returns a flag indicating whether a string matches a pattern.String
toString()
Returns the pattern of thisGlobPattern
-
-
-
Constructor Detail
-
GlobPattern
public GlobPattern(String pattern, boolean ishandle)
Class constructor that create aGlobPattern
with the given pattern. If theishandle
flag istrue
this will construct a hierarchy matcher.- Parameters:
pattern
- pattern stringishandle
- iftrue
and 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(String pattern)
Class constructor that create aGlobPattern
with the given pattern.- Parameters:
pattern
- pattern string
-
-
Method Detail
-
matches
public final boolean matches(String s)
Returns a flag indicating whether a string matches this pattern.- Parameters:
s
- string to be checked- Returns:
true
if s matches this pattern, elsefalse
.
-
matches
public static final boolean matches(String pattern, String s)
Returns a flag indicating whether a string matches a pattern.- Parameters:
pattern
- pattern used for comparisons
- string to be checked- Returns:
true
if s matches pattern, elsefalse
.
-
matches
public static final boolean matches(String pattern, String s, boolean ishandle)
Returns a flag indicating whether a string matches a pattern. if the ishandle istrue
and 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:
true
if s matches pattern, elsefalse
.
-
shellMatches
public boolean shellMatches(String s)
Returns a flag indicating whether a string matches a pattern. unlike thematches
methods, this matching is done shell-like.- Parameters:
s
- string to be checked- Returns:
true
if the string matches shell-like;false
otherwise.
-
shellMatches
public boolean shellMatches(String s, char c)
Returns a flag indicating whether a string matches a pattern. unlike thematches
methods, this matching is done shell-like.- Parameters:
s
- string to be checkedc
- character to be used as path delimiter- Returns:
true
if the string matches shell-like;false
otherwise.
-
containsWildcards
public static final boolean containsWildcards(String s)
Returnstrue
if the string contains wildcards.- Parameters:
s
- string to be checked- Returns:
true
if s contains wildcards, elsefalse
.
-
indexOfWildcard
public static final int indexOfWildcard(String s)
Returns the index of the first wildcard character in the string or-1
if the string does not contain a wild card character.- Parameters:
s
- string to be checked
-
toString
public String toString()
Returns the pattern of thisGlobPattern
-
equals
public boolean equals(Object obj)
Returnstrue
ifthis
GlobPattern
is equal to objectobj
.
-
-