org.apache.oro.text.awk
Class AwkCompiler

java.lang.Object
  |
  +--org.apache.oro.text.awk.AwkCompiler
All Implemented Interfaces:
PatternCompiler

public final class AwkCompiler
extends java.lang.Object
implements PatternCompiler

The AwkCompiler class is used to create compiled regular expressions conforming to the Awk regular expression syntax. It generates AwkPattern instances upon compilation to be used in conjunction with an AwkMatcher instance. AwkMatcher finds true leftmost-longest matches, so you must take care with how you formulate your regular expression to avoid matching more than you really want.

The supported regular expression syntax is a superset of traditional AWK, but NOT to be confused with GNU AWK or other AWK variants. Additionally, this AWK implementation is DFA-based and only supports 8-bit ASCII. Consequently, these classes can perform very fast pattern matches in most cases.

This is the traditional Awk syntax that is supported:

This is the extended syntax that is supported:

Version:
$Id: AwkCompiler.java,v 1.2 2000/07/23 23:25:18 jon Exp $
Author:
Daniel F. Savarese
See Also:
PatternCompiler, MalformedPatternException, AwkPattern, AwkMatcher

Field Summary
static int CASE_INSENSITIVE_MASK
           
static int DEFAULT_MASK
           
 
Constructor Summary
AwkCompiler()
           
 
Method Summary
 Pattern compile(char[] pattern)
          Same as calling compile(pattern, AwkCompiler.DEFAULT_MASK);
 Pattern compile(char[] pattern, int options)
          Compiles an Awk regular expression into an AwkPattern instance that can be used by an AwkMatcher object to perform pattern matching.
 Pattern compile(java.lang.String pattern)
          Same as calling compile(pattern, AwkCompiler.DEFAULT_MASK);
 Pattern compile(java.lang.String pattern, int options)
          Compiles an Awk regular expression into an AwkPattern instance that can be used by an AwkMatcher object to perform pattern matching.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MASK

public static final int DEFAULT_MASK

CASE_INSENSITIVE_MASK

public static final int CASE_INSENSITIVE_MASK
Constructor Detail

AwkCompiler

public AwkCompiler()
Method Detail

compile

public Pattern compile(char[] pattern,
                       int options)
                throws MalformedPatternException
Compiles an Awk regular expression into an AwkPattern instance that can be used by an AwkMatcher object to perform pattern matching.

Specified by:
compile in interface PatternCompiler
Parameters:
pattern - An Awk regular expression to compile.
options - A set of flags giving the compiler instructions on how to treat the regular expression. Currently the only meaningful flag is AwkCompiler.CASE_INSENSITIVE_MASK.
Returns:
A Pattern instance constituting the compiled regular expression. This instance will always be an AwkPattern and can be reliably be casted to an AwkPattern.
Throws:
MalformedPatternException - If the compiled expression is not a valid Awk regular expression.

compile

public Pattern compile(java.lang.String pattern,
                       int options)
                throws MalformedPatternException
Compiles an Awk regular expression into an AwkPattern instance that can be used by an AwkMatcher object to perform pattern matching.

Specified by:
compile in interface PatternCompiler
Parameters:
pattern - An Awk regular expression to compile.
options - A set of flags giving the compiler instructions on how to treat the regular expression. Currently the only meaningful flag is AwkCompiler.CASE_INSENSITIVE_MASK.
Returns:
A Pattern instance constituting the compiled regular expression. This instance will always be an AwkPattern and can be reliably be casted to an AwkPattern.
Throws:
MalformedPatternException - If the compiled expression is not a valid Awk regular expression.

compile

public Pattern compile(char[] pattern)
                throws MalformedPatternException
Same as calling compile(pattern, AwkCompiler.DEFAULT_MASK);

Specified by:
compile in interface PatternCompiler
Parameters:
pattern - A regular expression to compile.
Returns:
A Pattern instance constituting the compiled regular expression. This instance will always be an AwkPattern and can be reliably be casted to an AwkPattern.
Throws:
MalformedPatternException - If the compiled expression is not a valid Awk regular expression.

compile

public Pattern compile(java.lang.String pattern)
                throws MalformedPatternException
Same as calling compile(pattern, AwkCompiler.DEFAULT_MASK);

Specified by:
compile in interface PatternCompiler
Parameters:
pattern - A regular expression to compile.
Returns:
A Pattern instance constituting the compiled regular expression. This instance will always be an AwkPattern and can be reliably be casted to an AwkPattern.
Throws:
MalformedPatternException - If the compiled expression is not a valid Awk regular expression.


Copyright © 2000 Apache Software Foundation. All Rights Reserved.