Class com.oroinc.text.regex.Perl5Compiler
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.oroinc.text.regex.Perl5Compiler

java.lang.Object
   |
   +----com.oroinc.text.regex.Perl5Compiler

public final class Perl5Compiler
extends Object
implements PatternCompiler
The Perl5Compiler class is used to create compiled regular expressions conforming to the Perl5 regular expression syntax. It generates Perl5Pattern instances upon compilation to be used in conjunction with a Perl5Matcher instance. Please see the user's guide for more information about Perl5 regular expressions.

Copyright © 1997 Original Resuable Objects, Inc. All rights reserved.

Author:
Daniel F. Savarese
See Also:
PatternCompiler, MalformedPatternException, Perl5Pattern, Perl5Matcher

Variable Index

 o CASE_INSENSITIVE_MASK
A mask passed as an option to the compile methods to indicate a compiled regular expression should be case insensitive.
 o DEFAULT_MASK
The default mask for the compile methods.
 o EXTENDED_MASK
A mask passed as an option to the compile methods to indicate a compiled regular expression should be treated as a Perl5 extended pattern (i.e., a pattern using the /x modifier).
 o MULTILINE_MASK
A mask passed as an option to the compile methods to indicate a compiled regular expression should treat input as having multiple lines.
 o SINGLELINE_MASK
A mask passed as an option to the compile methods to indicate a compiled regular expression should treat input as being a single line.

Constructor Index

 o Perl5Compiler()

Method Index

 o compile(char[])
Same as calling compile(pattern, Perl5Compiler.DEFAULT_MASK);

 o compile(char[], int)
Compiles a Perl5 regular expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching.
 o compile(String)
Same as calling compile(pattern, Perl5Compiler.DEFAULT_MASK);

 o compile(String, int)
Compiles a Perl5 regular expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching.

Variables

 o DEFAULT_MASK
  public final static int DEFAULT_MASK
The default mask for the compile methods. It is equal to 0.
 o CASE_INSENSITIVE_MASK
  public final static int CASE_INSENSITIVE_MASK
A mask passed as an option to the compile methods to indicate a compiled regular expression should be case insensitive.
 o MULTILINE_MASK
  public final static int MULTILINE_MASK
A mask passed as an option to the compile methods to indicate a compiled regular expression should treat input as having multiple lines. This option only affects the interpretation of the ^ and $ metacharacters. When this mask is used, the ^ metacharacter matches at the beginning of every line, and the $ metacharacter matches at the end of every line. The SINGLELINE_MASK and MULTILINE_MASK should not be used together.
 o SINGLELINE_MASK
  public final static int SINGLELINE_MASK
A mask passed as an option to the compile methods to indicate a compiled regular expression should treat input as being a single line. This option only affects the interpretation of the ^ and $ metacharacters. When this mask is used, the ^ metacharacter matches at the beginning of the input, and the $ metacharacter matches at the end of the input. The ^ and $ metacharacters will not match at the beginning and end of lines occurring between the begnning and end of the input. The SINGLELINE_MASK and MULTILINE_MASK should not be used together.
 o EXTENDED_MASK
  public final static int EXTENDED_MASK
A mask passed as an option to the compile methods to indicate a compiled regular expression should be treated as a Perl5 extended pattern (i.e., a pattern using the /x modifier). This option tells the compiler to ignore whitespace that is not backslashed or within a character class. It also tells the compiler to treat the # character as a metacharacter introducing a comment as in Perl. In other words, the # character will comment out any text in the regular expression between it and the next newline. The intent of this option is to allow you to divide your patterns into more readable parts. It is provided to maintain compatibility with Perl5 regular expressions, although it will not often make sense to use it in Java.

Constructors

 o Perl5Compiler
  public Perl5Compiler()

Methods

 o compile
  public Pattern compile(char pattern[],
                         int options) throws MalformedPatternException
Compiles a Perl5 regular expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching. Please see the user's guide for more information about Perl5 regular expressions.

Parameters:
pattern - A Perl5 regular expression to compile.
option - A set of flags giving the compiler instructions on how to treat the regular expression. The flags are a logical OR of any number of the five MASK constants. For example:
regex =
  compiler.compile(pattern, Perl5Compiler.
                   CASE_INSENSITIVE_MASK |
                   Perl5Compiler.MULTILINE_MASK);
                
This says to compile the pattern so that it treats input as consisting of multiple lines and to perform matches in a case insensitive manner.
Returns:
A Pattern instance constituting the compiled regular expression. This instance will always be a Perl5Pattern and can be reliably be casted to a Perl5Pattern.
Throws: MalformedPatternException
If the compiled expression is not a valid Perl5 regular expression.
 o compile
  public Pattern compile(char pattern[]) throws MalformedPatternException
Same as calling compile(pattern, Perl5Compiler.DEFAULT_MASK);

Parameters:
pattern - A regular expression to compile.
Returns:
A Pattern instance constituting the compiled regular expression. This instance will always be a Perl5Pattern and can be reliably be casted to a Perl5Pattern.
Throws: MalformedPatternException
If the compiled expression is not a valid Perl5 regular expression.
 o compile
  public Pattern compile(String pattern) throws MalformedPatternException
Same as calling compile(pattern, Perl5Compiler.DEFAULT_MASK);

Parameters:
pattern - A regular expression to compile.
Returns:
A Pattern instance constituting the compiled regular expression. This instance will always be a Perl5Pattern and can be reliably be casted to a Perl5Pattern.
Throws: MalformedPatternException
If the compiled expression is not a valid Perl5 regular expression.
 o compile
  public Pattern compile(String pattern,
                         int options) throws MalformedPatternException
Compiles a Perl5 regular expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching. Please see the user's guide for more information about Perl5 regular expressions.

Parameters:
pattern - A Perl5 regular expression to compile.
option - A set of flags giving the compiler instructions on how to treat the regular expression. The flags are a logical OR of any number of the five MASK constants. For example:
regex =
  compiler.compile("^\\w+\\d+$",
                   Perl5Compiler.CASE_INSENSITIVE_MASK |
                   Perl5Compiler.MULTILINE_MASK);
                
This says to compile the pattern so that it treats input as consisting of multiple lines and to perform matches in a case insensitive manner.
Returns:
A Pattern instance constituting the compiled regular expression. This instance will always be a Perl5Pattern and can be reliably be casted to a Perl5Pattern.
Throws: MalformedPatternException
If the compiled expression is not a valid Perl5 regular expression.

All Packages  Class Hierarchy  This Package  Previous  Next  Index