Package org.codehaus.janino.util
Class StringPattern
java.lang.Object
org.codehaus.janino.util.StringPattern
Implementation of a UNIX shell-like string pattern algorithm.
Additionally, the concept of the "combined pattern" is supported (see
matches(StringPattern[], String).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final StringPattern[]static final StringPattern[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetMode()booleanMatch the giventextagainst the pattern represented by the current instance, as follows: A*in the pattern matches any sequence of zero or more characters in thetextA?in the pattern matches exactly one character in thetextAny other character in the pattern must appear exactly as it is in thetextNotice: Themodeflag of the current instance does not take any effect here.static booleanmatches(StringPattern[] patterns, String text) Match a giventextagainst an array ofStringPatterns (which was typically created byparseCombinedPattern(String).static StringPattern[]parseCombinedPattern(String combinedPattern) Parse a "combined pattern" into an array ofStringPatterns.toString()
-
Field Details
-
INCLUDE
public static final int INCLUDE- See Also:
-
EXCLUDE
public static final int EXCLUDE- See Also:
-
PATTERNS_ALL
-
PATTERNS_NONE
-
-
Constructor Details
-
Method Details
-
getMode
public int getMode() -
matches
Match the giventextagainst the pattern represented by the current instance, as follows:-
A
*in the pattern matches any sequence of zero or more characters in thetext -
A
?in the pattern matches exactly one character in thetext -
Any other character in the pattern must appear exactly as it is in the
text
modeflag of the current instance does not take any effect here. -
A
-
parseCombinedPattern
Parse a "combined pattern" into an array ofStringPatterns. A combined pattern string is structured as follows:combined-pattern := [ '+' | '-' ] pattern { ( '+' | '-' ) pattern }If a pattern is preceeded with a '-', then theStringPatternis created with modeEXCLUDE, otherwise with modeINCLUDE. -
matches
Match a giventextagainst an array ofStringPatterns (which was typically created byparseCombinedPattern(String).The last matching pattern takes effect; if its mode is
INCLUDE, thentrueis returned, if its mode isEXCLUDE, thenfalseis returned.If
patternsisPATTERNS_NONE, or empty, or none of its patterns matches, thenfalseis returned.If
patternsisPATTERNS_ALL, thentrueis returned.For backwards compatibility,
nullpatterns are treated likePATTERNS_NONE. -
toString
-