|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.fdsapi.RegularExpression
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));>
}
| 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 |
public RegularExpression(java.lang.String regularExpressionStr)
| Method Detail |
public static RegularExpression createInstance(java.lang.String regularExpressionStr)
public java.lang.String getParen(int parenNumber)
public void setSourceString(java.lang.String sourceString)
public boolean next()
public java.lang.String[] split(java.lang.String stringToSplit)
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||