com.fdsapi
Class RegularExpression

java.lang.Object
  |
  +--com.fdsapi.RegularExpression

public class RegularExpression
extends java.lang.Object

This class is used to run Regular Expressions. It uses the jakarta projects ORO regular expression parser. Java 1.2 did not have regular expressions built into the language. By abstracting the concept of Regular Expressions into a class I control dependencies of ORO are not embedded throughtout my code and only this class needs to be changed if I want to go to the newer java 1.4 Regular Expression approach. If I do this the FormattedDataSet API will not work with java 1.2 (not desireable at this time).

This code requires jakartas ORO jar to be compiled: (http://jakarta.apache.org/oro/)

Sample usage from main method:

  final String RE="##(hello|world)"; 

    RegularExpression re=new RegularExpression(RE);
    re.setSourceString("##hello ##miscData1 ##steve ##souza ##world ##this ##rownum ##headerthis ##3");

    while (re.next()) {
        System.out.println(re.getParen(0));
        System.out.println(re.getParen(1));>
    }
 


View Code


Constructor Summary
RegularExpression(java.lang.String regularExpressionStr)
           
 
Method Summary
static RegularExpression createInstance(java.lang.String regularExpressionStr)
          Creates a RegularExpression object with the specified regular expression
 java.lang.String getParen(int parenNumber)
          Get contents of the passed paren number
static void main(java.lang.String[] args)
          Sample code for testing.
 boolean next()
          returns true while the input still has pattern matches.
 void setSourceString(java.lang.String sourceString)
          Set source string to be searched for the regular expression passed into the constructor
 java.lang.String[] split(java.lang.String stringToSplit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegularExpression

public RegularExpression(java.lang.String regularExpressionStr)
Method Detail

createInstance

public static RegularExpression createInstance(java.lang.String regularExpressionStr)
Creates a RegularExpression object with the specified regular expression


getParen

public java.lang.String getParen(int parenNumber)
Get contents of the passed paren number


setSourceString

public void setSourceString(java.lang.String sourceString)
Set source string to be searched for the regular expression passed into the constructor


next

public boolean next()
returns true while the input still has pattern matches.


split

public java.lang.String[] split(java.lang.String stringToSplit)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Sample code for testing.

java.lang.Exception