|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javatools.parsers.RegularExpression
public class RegularExpression
This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools).
It is licensed under the Creative Commons Attribution License
(see http://creativecommons.org/licenses/by/3.0) by
the YAGO-NAGA team (see http://mpii.de/yago-naga).
The class represents a regular expression. You can walk through the regular expression
by RegExStates. Each RegExState represents one position in the regular expression.
Each RegExState knows which other RegExStates are valid sucessors. The regular expression
itself knows which RegExStates are valid exit points. The regular expression can also be
inverted.
Example:
D.p(RegularExpression.compile("a|(b c+)+").describe()); --> 1(a) -> [] // From a, we're done 2(b) -> [3(c)] // From b, go to c 3(c) -> [3(c), 2(b)] // From c, go either to c or to b Valid exits: 1(a), 3(c), D.p(RegularExpression.compile("a|(b c+)+").inverse().describe()); --> 4(a) -> [] 6(c) -> [5(b), 6(c)] 5(b) -> [6(c)] Valid exits: 4(a), 5(b),
Nested Class Summary | |
---|---|
static class |
RegularExpression.RegExState
Represents one position in a regular expression |
Field Summary | |
---|---|
java.util.List<RegularExpression.RegExState> |
entries
RegExStates with which the RegularExpression starts |
java.util.List<RegularExpression.RegExState> |
exits
Valid exit states of this RegularExpression |
java.lang.String |
original
Holds the original regex |
Method Summary | |
---|---|
static RegularExpression |
compile(java.lang.String regex)
Returns a RegularExpression for a string |
java.lang.String |
describe()
returns a nice String description |
java.util.List<RegularExpression.RegExState> |
getEntries()
Returns the entry states of this RegularExpression |
java.lang.String |
getOrginal()
returns the original |
java.util.List<RegularExpression.RegExState> |
getStates()
Returns the set of States (expensive) |
RegularExpression |
inverse()
Returns the inverse of this Regular Expression (expensive) |
boolean |
isExit(RegularExpression.RegExState e)
Tells whether this RegExState is a valid exit |
PeekIterator<java.util.List<java.lang.String>> |
iterator()
Returns an iterator over incarnations of the expression |
static void |
main(java.lang.String[] args)
Test routine |
static RegularExpression |
parseSimple(java.util.StringTokenizer regex)
Parses a regex from a StringTokenizer |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.util.List<RegularExpression.RegExState> entries
public java.util.List<RegularExpression.RegExState> exits
public java.lang.String original
Method Detail |
---|
public java.lang.String getOrginal()
public static RegularExpression compile(java.lang.String regex)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isExit(RegularExpression.RegExState e)
public java.util.List<RegularExpression.RegExState> getEntries()
public static RegularExpression parseSimple(java.util.StringTokenizer regex)
public java.lang.String describe()
public java.util.List<RegularExpression.RegExState> getStates()
public RegularExpression inverse()
public PeekIterator<java.util.List<java.lang.String>> iterator()
iterator
in interface java.lang.Iterable<java.util.List<java.lang.String>>
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |