public class TokenPatternMatch extends java.lang.Object
TokenPattern
. Keeps track of any groups
that have been matched by parts of the pattern. A group is identified by an
arbitrary integer. See also TokenPattern.group(int)
.
Multiple segments of the tokenStream can be associated with the same group.
In this case, getMatchGroup(int)
will return multiple
MatchGroupElement
s for the group.Constructor and Description |
---|
TokenPatternMatch(java.util.List<IToken> tokenStream)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
appendToGroup(java.lang.Integer groupIndex,
int inclusiveStartIndex,
int exclusiveEndIndex)
Appends the given tokens to the group with the given index if the given
range contains at least one token.
|
static java.util.List<java.lang.String> |
getAllStrings(java.util.List<TokenPatternMatch> matches,
int groupIndex)
Returns a list of all group strings in all matches of the group with the
given index.
|
static java.util.List<IToken> |
getAllTokens(java.util.List<TokenPatternMatch> matches,
int groupIndex)
Returns a list of all group tokens in all matches of the group with the
given index.
|
java.util.List<MatchGroupElement> |
getMatchGroup(int groupIndex)
Returns the TokenStream parts matched in this group.
|
java.util.List<java.lang.Integer> |
groupIndices(int groupIndex)
Returns the indices into the token stream in the given group or an empty
list.
|
java.lang.String |
groupString(int groupIndex)
Returns the concatenated text of the tokens in the given group.
|
java.util.List<java.lang.String> |
groupTexts(int groupIndex)
Returns the text of the tokens in the given group.
|
java.util.List<IToken> |
groupTokens(int groupIndex)
Returns the tokens in the given group or an empty list.
|
boolean |
hasGroup(int groupIndex)
Returns
true if the match contains tokens in the given
group. |
void |
mergeFrom(TokenPatternMatch other)
Merges the group information from given match into this match.
|
public TokenPatternMatch(java.util.List<IToken> tokenStream)
public void appendToGroup(java.lang.Integer groupIndex, int inclusiveStartIndex, int exclusiveEndIndex)
public java.util.List<java.lang.String> groupTexts(int groupIndex)
MatchGroupElement
s for the given group will be concatenated.public java.util.List<java.lang.Integer> groupIndices(int groupIndex)
MatchGroupElement
s for the given group will be
concatenated.public java.util.List<IToken> groupTokens(int groupIndex)
MatchGroupElement
s for the given group will be concatenated.public java.util.List<MatchGroupElement> getMatchGroup(int groupIndex)
MatchGroupElement
and can contain multiple
IToken
s, depending on the used pattern.public java.lang.String groupString(int groupIndex)
MatchGroupElement
s for the given group will be concatenated.If
the group was not matched, returns the empty string.public boolean hasGroup(int groupIndex)
true
if the match contains tokens in the given
group.public void mergeFrom(TokenPatternMatch other)
public static java.util.List<java.lang.String> getAllStrings(java.util.List<TokenPatternMatch> matches, int groupIndex)
public static java.util.List<IToken> getAllTokens(java.util.List<TokenPatternMatch> matches, int groupIndex)