Package dk.brics.automaton
Class AutomatonMatcher
java.lang.Object
dk.brics.automaton.AutomatonMatcher
- All Implemented Interfaces:
MatchResult
A tool that performs match operations on a given character sequence using
a compiled automaton.
- Author:
- John Gibson <jgibson@mitre.org>
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintend()Returns the offset after the last character matched.intend(int group) Returns the offset after the last character matched of the specified capturing group.booleanfind()Find the next matching subsequence of the input.group()Returns the subsequence of the input found by the previous match.group(int group) Returns the subsequence of the input found by the specified capturing group during the previous match operation.intReturns the number of capturing groups in the underlying automaton.intstart()Returns the offset of the first character matched.intstart(int group) Returns the offset of the first character matched of the specified capturing group.Returns the current state of thisAutomatonMatcheras aMatchResult.
-
Method Details
-
find
public boolean find()Find the next matching subsequence of the input.
This also updates the values for thestart,end, andgroupmethods.- Returns:
trueif there is a matching subsequence.
-
end
Returns the offset after the last character matched.- Specified by:
endin interfaceMatchResult- Returns:
- The offset after the last character matched.
- Throws:
IllegalStateException- if there has not been a match attempt or if the last attempt yielded no results.
-
end
Returns the offset after the last character matched of the specified capturing group.
Note that because the automaton does not support capturing groups the only valid group is 0 (the entire match).- Specified by:
endin interfaceMatchResult- Parameters:
group- the desired capturing group.- Returns:
- The offset after the last character matched of the specified capturing group.
- Throws:
IllegalStateException- if there has not been a match attempt or if the last attempt yielded no results.IndexOutOfBoundsException- if the specified capturing group does not exist in the underlying automaton.
-
group
Returns the subsequence of the input found by the previous match.- Specified by:
groupin interfaceMatchResult- Returns:
- The subsequence of the input found by the previous match.
- Throws:
IllegalStateException- if there has not been a match attempt or if the last attempt yielded no results.
-
group
Returns the subsequence of the input found by the specified capturing group during the previous match operation.
Note that because the automaton does not support capturing groups the only valid group is 0 (the entire match).- Specified by:
groupin interfaceMatchResult- Parameters:
group- the desired capturing group.- Returns:
- The subsequence of the input found by the specified capturing
group during the previous match operation the previous match. Or
nullif the given group did match. - Throws:
IllegalStateException- if there has not been a match attempt or if the last attempt yielded no results.IndexOutOfBoundsException- if the specified capturing group does not exist in the underlying automaton.
-
groupCount
public int groupCount()Returns the number of capturing groups in the underlying automaton.
Note that because the automaton does not support capturing groups this method will always return 0.- Specified by:
groupCountin interfaceMatchResult- Returns:
- The number of capturing groups in the underlying automaton.
-
start
Returns the offset of the first character matched.- Specified by:
startin interfaceMatchResult- Returns:
- The offset of the first character matched.
- Throws:
IllegalStateException- if there has not been a match attempt or if the last attempt yielded no results.
-
start
Returns the offset of the first character matched of the specified capturing group.
Note that because the automaton does not support capturing groups the only valid group is 0 (the entire match).- Specified by:
startin interfaceMatchResult- Parameters:
group- the desired capturing group.- Returns:
- The offset of the first character matched of the specified capturing group.
- Throws:
IllegalStateException- if there has not been a match attempt or if the last attempt yielded no results.IndexOutOfBoundsException- if the specified capturing group does not exist in the underlying automaton.
-
toMatchResult
Returns the current state of thisAutomatonMatcheras aMatchResult. The result is unaffected by subsequent operations on this object.- Returns:
- a
MatchResultwith the state of thisAutomatonMatcher.
-