|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdk.brics.automaton.CustomAutomatonMatcher
public class CustomAutomatonMatcher
A tool that performs match operations on a given character sequence using a compiled automaton. Modified such that regular expressions can be assigned IDs that are used to differentiate joined automatons.
RunAutomaton.newMatcher(java.lang.CharSequence)
,
RunAutomaton.newMatcher(java.lang.CharSequence, int, int)
Field Summary | |
---|---|
private CustomRunAutomaton |
automaton
|
private java.lang.CharSequence |
chars
|
private int |
matchEnd
|
private java.util.ArrayList<java.lang.String> |
matchIDs
|
private int |
matchStart
|
Constructor Summary | |
---|---|
CustomAutomatonMatcher(java.lang.CharSequence chars,
CustomRunAutomaton automaton)
|
Method Summary | |
---|---|
int |
end()
Returns the offset after the last character matched. |
int |
end(int group)
Returns the offset after the last character matched of the specified capturing group. |
boolean |
find()
Find the next matching subsequence of the input. |
boolean |
findWithDelimitedID(char delimiter)
Equivalent to find(), but for automatons with IDs that have been separated from the regular expression by delimiter |
private java.lang.CharSequence |
getChars()
|
private java.util.ArrayList<java.lang.String> |
getIDs(int state)
|
private int |
getMatchEnd()
|
java.util.ArrayList<java.lang.String> |
getMatchIDs()
|
private int |
getMatchStart()
|
java.lang.String |
group()
Returns the subsequence of the input found by the previous match. |
java.lang.String |
group(int group)
Returns the subsequence of the input found by the specified capturing group during the previous match operation. |
int |
groupCount()
Returns the number of capturing groups in the underlying automaton. |
private void |
matchGood()
Helper method to check that the last match attempt was valid. |
private static void |
onlyZero(int group)
Helper method that requires the group argument to be 0. |
private void |
setMatch(int matchStart,
int matchEnd)
|
private void |
setMatch(int matchStart,
int matchEnd,
java.util.ArrayList<java.lang.String> matchIDs)
|
int |
start()
Returns the offset of the first character matched. |
int |
start(int group)
Returns the offset of the first character matched of the specified capturing group. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final CustomRunAutomaton automaton
private final java.lang.CharSequence chars
private int matchStart
private int matchEnd
private java.util.ArrayList<java.lang.String> matchIDs
Constructor Detail |
---|
CustomAutomatonMatcher(java.lang.CharSequence chars, CustomRunAutomaton automaton)
Method Detail |
---|
private java.util.ArrayList<java.lang.String> getIDs(int state)
public boolean findWithDelimitedID(char delimiter)
delimiter
-
public boolean find()
start
, end
, and
group
methods.
true
if there is a matching subsequence.private void setMatch(int matchStart, int matchEnd, java.util.ArrayList<java.lang.String> matchIDs) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
private void setMatch(int matchStart, int matchEnd) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
private int getMatchStart()
private int getMatchEnd()
private java.lang.CharSequence getChars()
public int end() throws java.lang.IllegalStateException
end
in interface java.util.regex.MatchResult
java.lang.IllegalStateException
- if there has not been a match attempt or
if the last attempt yielded no results.public int end(int group) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalStateException
end
in interface java.util.regex.MatchResult
group
- the desired capturing group.
java.lang.IllegalStateException
- if there has not been a match attempt or
if the last attempt yielded no results.
java.lang.IndexOutOfBoundsException
- if the specified capturing group does
not exist in the underlying automaton.public java.lang.String group() throws java.lang.IllegalStateException
group
in interface java.util.regex.MatchResult
java.lang.IllegalStateException
- if there has not been a match attempt or
if the last attempt yielded no results.public java.lang.String group(int group) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalStateException
group
in interface java.util.regex.MatchResult
group
- the desired capturing group.
null
if the given group did match.
java.lang.IllegalStateException
- if there has not been a match attempt or
if the last attempt yielded no results.
java.lang.IndexOutOfBoundsException
- if the specified capturing group does
not exist in the underlying automaton.public int groupCount()
groupCount
in interface java.util.regex.MatchResult
public int start() throws java.lang.IllegalStateException
start
in interface java.util.regex.MatchResult
java.lang.IllegalStateException
- if there has not been a match attempt or
if the last attempt yielded no results.public int start(int group) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalStateException
start
in interface java.util.regex.MatchResult
group
- the desired capturing group.
java.lang.IllegalStateException
- if there has not been a match attempt or
if the last attempt yielded no results.
java.lang.IndexOutOfBoundsException
- if the specified capturing group does
not exist in the underlying automaton.private static void onlyZero(int group) throws java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException
private void matchGood() throws java.lang.IllegalStateException
java.lang.IllegalStateException
public java.util.ArrayList<java.lang.String> getMatchIDs()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |