- 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
FieldsModifier and TypeFieldDescriptionstatic final MetaPatternConstant for ampersand.static final MetaPatternConstant for anything (string).static final MetaPatternConstant for anything non-empty (string).static final MetaPatternConstant for at.static final MetaPatternConstant for backslash.static final MetaPatternConstant for colon.static final MetaPatternConstant for comma.static final MetaPatternConstant for dash.static final MetaPatternConstant for digit.static final MetaPatternConstant for digits.static final MetaPatternConstant for dollar.static final MetaPatternConstant for dot.static final MetaPatternConstant for a double quoted string.static final MetaPatternConstant for equals.static final MetaPatternConstant for excl.static final MetaPatternConstant for a floating point number.static final MetaPatternConstant for hex digit.static final MetaPatternConstant for hex digits.static final MetaPatternConstant for an integer (of any size).static final MetaPatternConstant for left curly braces.static final MetaPatternConstant for left paren.static final MetaPatternConstant for left square bracket.static final MetaPatternConstant for minus.static final MetaPatternConstant for non-word.static final MetaPatternConstant for an optional string.static final MetaPatternConstant for optional whitespace.static final MetaPatternConstant for an optional word.static final MetaPatternConstant for percent.static final MetaPatternConstant for perl interpolation.static final MetaPatternConstant for pipe.static final MetaPatternConstant for plus.static final MetaPatternConstant for a positive integer.static final MetaPatternConstant for pound.static final MetaPatternConstant for right curly braces.static final MetaPatternConstant for right paren.static final MetaPatternConstant for right square bracket.static final MetaPatternConstant for semicolon.static final MetaPatternConstant for slash.static final MetaPatternConstant for star.static final MetaPatternConstant for a string.static final MetaPatternConstant for tilde.static final MetaPatternConstant for underscore.static final MetaPatternConstant for a variable name.static final MetaPatternConstant for whitespace.static final MetaPatternConstant for a word.static final MetaPatternConstant for an XML attribute name.static final MetaPatternConstant for an XML element name. -
Constructor Summary
ConstructorsConstructorDescriptionMetaPattern(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 Matchermatcher(CharSequence input) Creates a matcher against a given input character sequence.final Matchermatcher(CharSequence input, int flags) Creates a matcher with the given regexp compile flags.final Patternpattern()Gets the regular expression Pattern for this MetaPattern by compiling it.final Patternpattern(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.
-