- All Implemented Interfaces:
Serializable
,IClusterable
- Direct Known Subclasses:
Group
,OptionalMetaPattern
MetaPatterns can be constructed from a simple regular expression String, from other MetaPatterns (copy constructor), from a list of MetaPatterns or from an array of MetaPatterns. In this way, it is easy to build up larger patterns while transparently binding the capturing groups of each MetaPattern for easy object oriented access to capturing group matches.
A given MetaPattern can be converted to a Matcher or Pattern. Groups within the MetaPattern can be used to automatically reference capturing group values when a match is made with a Matcher object.
A variety of static constants are provided for use in constructing compound MetaPatterns. Also, a number of simple parsers have been constructed using MetaPatterns in the parsers subpackage.
- Author:
- Jonathan Locke
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MetaPattern
Constant for ampersand.static final MetaPattern
Constant for anything (string).static final MetaPattern
Constant for anything non-empty (string).static final MetaPattern
Constant for at.static final MetaPattern
Constant for backslash.static final MetaPattern
Constant for colon.static final MetaPattern
Constant for comma.static final MetaPattern
Constant for dash.static final MetaPattern
Constant for digit.static final MetaPattern
Constant for digits.static final MetaPattern
Constant for dollar.static final MetaPattern
Constant for dot.static final MetaPattern
Constant for a double quoted string.static final MetaPattern
Constant for equals.static final MetaPattern
Constant for excl.static final MetaPattern
Constant for a floating point number.static final MetaPattern
Constant for hex digit.static final MetaPattern
Constant for hex digits.static final MetaPattern
Constant for an integer (of any size).static final MetaPattern
Constant for left curly braces.static final MetaPattern
Constant for left paren.static final MetaPattern
Constant for left square bracket.static final MetaPattern
Constant for minus.static final MetaPattern
Constant for non-word.static final MetaPattern
Constant for an optional string.static final MetaPattern
Constant for optional whitespace.static final MetaPattern
Constant for an optional word.static final MetaPattern
Constant for percent.static final MetaPattern
Constant for perl interpolation.static final MetaPattern
Constant for pipe.static final MetaPattern
Constant for plus.static final MetaPattern
Constant for a positive integer.static final MetaPattern
Constant for pound.static final MetaPattern
Constant for right curly braces.static final MetaPattern
Constant for right paren.static final MetaPattern
Constant for right square bracket.static final MetaPattern
Constant for semicolon.static final MetaPattern
Constant for slash.static final MetaPattern
Constant for star.static final MetaPattern
Constant for a string.static final MetaPattern
Constant for tilde.static final MetaPattern
Constant for underscore.static final MetaPattern
Constant for a variable name.static final MetaPattern
Constant for whitespace.static final MetaPattern
Constant for a word.static final MetaPattern
Constant for an XML attribute name.static final MetaPattern
Constant for an XML element name. -
Constructor Summary
ConstructorDescriptionMetaPattern
(String pattern) Constructor for a simple pattern.MetaPattern
(List<MetaPattern> patterns) Constructs from a list of MetaPatternsMetaPattern
(MetaPattern pattern) Copy constructor.MetaPattern
(MetaPattern... patterns) Constructs from an array of MetaPatterns. -
Method Summary
Modifier and TypeMethodDescriptionfinal Matcher
matcher
(CharSequence input) Creates a matcher against a given input character sequence.final Matcher
matcher
(CharSequence input, int flags) Creates a matcher with the given regexp compile flags.final Pattern
pattern()
Gets the regular expression Pattern for this MetaPattern by compiling it.final Pattern
pattern
(int flags) Gets the regular expression Pattern for this MetaPattern by compiling it using the given flags.toString()
Converts this MetaPattern to a String.
-
Field Details
-
WHITESPACE
Constant for whitespace. -
OPTIONAL_WHITESPACE
Constant for optional whitespace. -
NON_WORD
Constant for non-word. -
COMMA
Constant for comma. -
COLON
Constant for colon. -
SEMICOLON
Constant for semicolon. -
SLASH
Constant for slash. -
BACKSLASH
Constant for backslash. -
DOT
Constant for dot. -
PLUS
Constant for plus. -
MINUS
Constant for minus. -
DASH
Constant for dash. -
UNDERSCORE
Constant for underscore. -
AMPERSAND
Constant for ampersand. -
PERCENT
Constant for percent. -
DOLLAR_SIGN
Constant for dollar. -
POUND_SIGN
Constant for pound. -
AT_SIGN
Constant for at. -
EXCLAMATION_POINT
Constant for excl. -
TILDE
Constant for tilde. -
EQUALS
Constant for equals. -
STAR
Constant for star. -
PIPE
Constant for pipe. -
LEFT_PAREN
Constant for left paren. -
RIGHT_PAREN
Constant for right paren. -
LEFT_CURLY
Constant for left curly braces. -
RIGHT_CURLY
Constant for right curly braces. -
LEFT_SQUARE
Constant for left square bracket. -
RIGHT_SQUARE
Constant for right square bracket. -
DIGIT
Constant for digit. -
DIGITS
Constant for digits. -
INTEGER
Constant for an integer (of any size). -
FLOATING_POINT_NUMBER
Constant for a floating point number. -
POSITIVE_INTEGER
Constant for a positive integer. -
HEXADECIMAL_DIGIT
Constant for hex digit. -
HEXADECIMAL_DIGITS
Constant for hex digits. -
ANYTHING
Constant for anything (string). -
ANYTHING_NON_EMPTY
Constant for anything non-empty (string). -
WORD
Constant for a word. -
OPTIONAL_WORD
Constant for an optional word. -
VARIABLE_NAME
Constant for a variable name. -
XML_ELEMENT_NAME
Constant for an XML element name. -
XML_ATTRIBUTE_NAME
Constant for an XML attribute name. -
PERL_INTERPOLATION
Constant for perl interpolation. -
DOUBLE_QUOTED_STRING
Constant for a double quoted string. -
STRING
Constant for a string. -
OPTIONAL_STRING
Constant for an optional string.
-
-
Constructor Details
-
MetaPattern
Constructor for a simple pattern.- Parameters:
pattern
- The regular expression pattern to compile
-
MetaPattern
Copy constructor.- Parameters:
pattern
- The meta pattern to copy
-
MetaPattern
Constructs from an array of MetaPatterns.- Parameters:
patterns
- Array of MetaPatterns
-
MetaPattern
Constructs from a list of MetaPatterns- Parameters:
patterns
- List of MetaPatterns
-
-
Method Details
-
matcher
Creates a matcher against a given input character sequence.- Parameters:
input
- The input to match against- Returns:
- The matcher
-
matcher
Creates a matcher with the given regexp compile flags. Once you call this method with a given regexp compile flag value, the pattern will be compiled. Calling it again with a different value for flags will not recompile the pattern.- Parameters:
input
- The input to matchflags
- One or more of the standard Java regular expression compile flags (seePattern.compile(String, int)
)- Returns:
- The matcher
-
pattern
Gets the regular expression Pattern for this MetaPattern by compiling it.- Returns:
- Pattern compiled with default Java regular expression compile flags
-
pattern
Gets the regular expression Pattern for this MetaPattern by compiling it using the given flags.- Parameters:
flags
- One or more of the standard Java regular expression compile flags (seePattern.compile(String, int)
)- Returns:
- Equivalent Java regular expression Pattern compiled with the given flags
-
toString
Converts this MetaPattern to a String.
-