com.raelity.text
Class RegExpFactory

java.lang.Object
  extended by com.raelity.text.RegExpFactory

public class RegExpFactory
extends Object

Factory class for vending RegExp instances. Most of the work is finding a regular expression implementation to use. Note: RegExpFactory has no public constructor.

See Also:
RegExp

Field Summary
protected static String reAdapted
          The class name of the regular expression handler that is being adapted by the vended class.
protected static Class reClass
          The reClass variable holds the Class which is vended.
protected static String reClassName
          The name of the class that is being vended.
protected static String reDisplayName
          Name of package being used.
protected static Vector<String> reImp
           
 
Method Summary
static void addImplementation(String imp)
          Append the argument to the list of known implementations.
static boolean builtinTest()
          Runs some tests using the known implementations.
static RegExp create()
          Create a new instance of a regular expresion handler.
static RegExp create(String pattern)
          Create a new instance of a regular expresion handler and compile pattern for the regular expression.
static RegExp createReport(String pattern)
          Create a new instance of a regular expression handler and compile the pattern.
static void dumpResult(RegExp result)
          Dump all the information about a match.
static void dumpResult(RegExpResult result)
          Same as dumpResult(RegExp) except it takes a RegExpResult.
static String[] getKnownImplementations()
           
static String getRegExpAdapted()
           
static String getRegExpClass()
           
static String getRegExpDisplayName()
           
static boolean initFactory()
          Look for the known implementations of RegExp.
static void load(String reClassName)
          Load reClassName and use it as the implementation of regular expression handling.
static void main(String[] args)
          Method declaration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reImp

protected static Vector<String> reImp

reClass

protected static Class reClass
The reClass variable holds the Class which is vended.


reClassName

protected static String reClassName
The name of the class that is being vended.


reAdapted

protected static String reAdapted
The class name of the regular expression handler that is being adapted by the vended class. This is the empty string for direct implementations.


reDisplayName

protected static String reDisplayName
Name of package being used.

Method Detail

create

public static RegExp create()
Create a new instance of a regular expresion handler.
A NoClassDefFoundError is thrown if the factory is inoporable.

Returns:
An instance of a regular expression handler.
See Also:
RegExp

create

public static RegExp create(String pattern)
Create a new instance of a regular expresion handler and compile pattern for the regular expression.
A NoClassDefFoundError is thrown if the factory is inoporable.

Returns:
An instance of a regular expression handler.
See Also:
RegExp

createReport

public static RegExp createReport(String pattern)
Create a new instance of a regular expression handler and compile the pattern. If a pattern error occurs dump the stack trace and rethrow the exception. Normall used from static initializers since it seems exception handling is funny in thows cases.

Returns:
An instance of RegExp with a pattern.
See Also:
RegExp

getKnownImplementations

public static String[] getKnownImplementations()
Returns:
The class names of the the know implementations.

addImplementation

public static void addImplementation(String imp)
Append the argument to the list of known implementations. Don't allow duplicates.


getRegExpClass

public static String getRegExpClass()
Returns:
The name of the implementation that is being vended or null if the factory is not operable.

getRegExpAdapted

public static String getRegExpAdapted()
Returns:
The name of the actual regular expression handler or null if the factory is not operable.

getRegExpDisplayName

public static String getRegExpDisplayName()
Returns:
the display name of the req exp handler or null if factory is not operable.

initFactory

public static boolean initFactory()
Look for the known implementations of RegExp. Set up the factory to use the first one found. If the factory is already initialized just return. This is called automatically, but calling it during application startup may make more sense.

Returns:
True if a the factory is usable, otherwise false.

load

public static void load(String reClassName)
                 throws ClassNotFoundException,
                        IllegalArgumentException,
                        ClassCastException,
                        NoSuchMethodException,
                        SecurityException
Load reClassName and use it as the implementation of regular expression handling. reClassName is the class name of the adaptor class; it must be a subclass of RegExp. If reClassName is legitimate then it replaces the current implementation, if any, being used. If the class can not be loaded for any reason then an exception or error is thrown. In other words, any return indicates success. In the event of an error or exception, a previously loaded RegExp continues in use by this factory.

Throws:
ClassNotFoundException
IllegalArgumentException
ClassCastException
NoSuchMethodException
SecurityException
See Also:
RegExp, RegExp.canInstantiate()

main

public static void main(String[] args)
Method declaration

Parameters:
args -
See Also:

builtinTest

public static boolean builtinTest()
Runs some tests using the known implementations. Print PASS or FAIL.


dumpResult

public static void dumpResult(RegExp result)
Dump all the information about a match. The general form of an output line is
 matched_string [start,stop) num_chars
 

This can be usefull for debugging.


dumpResult

public static void dumpResult(RegExpResult result)
Same as dumpResult(RegExp) except it takes a RegExpResult.