PatternCompiler (Jakarta-ORO 2.0.8 API)
Keywords: org.apache.oro.text.regex.PatternCompiler interface

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.oro.text.regex
Interface PatternCompiler

All Known Implementing Classes:
  AwkCompiler, GlobCompiler, Perl5Compiler

public interface PatternCompiler

The PatternCompiler interface defines the operations a regular expression compiler must implement. However, the types of regular expressions recognized by a compiler and the Pattern implementations produced as a result of compilation are not restricted.

A PatternCompiler instance is used to compile the string representation (either as a String or char[]) of a regular expression into a Pattern instance. The Pattern can then be used in conjunction with the appropriate PatternMatcher instance to perform pattern searches. A form of use might be:

>      PatternCompiler compiler;
>      PatternMatcher matcher;
>      Pattern pattern;
>      String input;

>      // Initialization of compiler, matcher, and input omitted;

>      try {
>        pattern = compiler.compile("\\d+");
>      } catch(MalformedPatternException e) {
>        System.out.println("Bad pattern.");
>        System.out.println(e.getMessage());
>        System.exit(1);
>      }

>      if(matcher.matches(input, pattern))
>         System.out.println(input + " is a number");
>      else
>         System.out.println(input + " is not a number");

Specific PatternCompiler implementations such as Perl5Compiler may have variations of the compile() methods that take extra options affecting the compilation of a pattern. However, the PatternCompiler method implementations should provide the default behavior of the class.

Since:
  1.0
Version:
  2.0.8
See Also:
  `Pattern`, `PatternMatcher`, `MalformedPatternException`

Method Summary
`Pattern` | `compile(char[] pattern)` Compiles a regular expression into a data structure that can be used by a PatternMatcher implementation to perform pattern matching.
`Pattern` | `compile(char[] pattern, int options)` Compiles a regular expression into a data structure that can be used by a PatternMatcher implementation to perform pattern matching.
`Pattern` | `compile(java.lang.String pattern)` Compiles a regular expression into a data structure that can be used by a PatternMatcher implementation to perform pattern matching.
`Pattern` | `compile(java.lang.String pattern, int options)` Compiles a regular expression into a data structure that can be used by a PatternMatcher implementation to perform pattern matching.

Method Detail

### compile

    public Pattern compile(java.lang.String pattern)
                    throws MalformedPatternException

  Compiles a regular expression into a data structure that can be used by a PatternMatcher implementation to perform pattern matching.

  Parameters:
    `pattern` - A regular expression to compile.
  Returns:
    A Pattern instance constituting the compiled regular expression.
  Throws:
    `MalformedPatternException` - If the compiled expression does not conform to the grammar understood by the PatternCompiler or if some other error in the expression is encountered.

### compile

    public Pattern compile(java.lang.String pattern,
                           int options)
                    throws MalformedPatternException

  Compiles a regular expression into a data structure that can be used by a PatternMatcher implementation to perform pattern matching. Additional regular expression syntax specific options can be passed as a bitmask of options.

  Parameters:
    `pattern` - A regular expression to compile.
    `options` - 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 allowable constants permitted by the PatternCompiler implementation.
  Returns:
    A Pattern instance constituting the compiled regular expression.
  Throws:
    `MalformedPatternException` - If the compiled expression does not conform to the grammar understood by the PatternCompiler or if some other error in the expression is encountered.

### compile

    public Pattern compile(char[] pattern)
                    throws MalformedPatternException

  Compiles a regular expression into a data structure that can be used by a PatternMatcher implementation to perform pattern matching.

  Parameters:
    `pattern` - A regular expression to compile.
  Returns:
    A Pattern instance constituting the compiled regular expression.
  Throws:
    `MalformedPatternException` - If the compiled expression does not conform to the grammar understood by the PatternCompiler or if some other error in the expression is encountered.

### compile

    public Pattern compile(char[] pattern,
                           int options)
                    throws MalformedPatternException

  Compiles a regular expression into a data structure that can be used by a PatternMatcher implementation to perform pattern matching. Additional regular expression syntax specific options can be passed as a bitmask of options.

  Parameters:
    `pattern` - A regular expression to compile.
    `options` - 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 allowable constants permitted by the PatternCompiler implementation.
  Returns:
    A Pattern instance constituting the compiled regular expression.
  Throws:
    `MalformedPatternException` - If the compiled expression does not conform to the grammar understood by the PatternCompiler or if some other error in the expression is encountered.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ? 2000-2003 Apache Software Foundation. All Rights Reserved.