getTextRange abstract method

String getTextRange(
  1. Token? start,
  2. Token? stop
)

Return the text of all tokens in this stream between start and stop (inclusive).

If the specified [start] or [stop] token was not provided by this stream, or if the [stop] occurred before the [start] token, the behavior is unspecified.

For streams which ensure that the {@link Token#getTokenIndex} method is accurate for all of its provided tokens, this method behaves like the following code. Other streams may implement this method in other ways provided the behavior is consistent with this at a high level.

TokenStream stream = ...;
String text = "";
for (int i = start.getTokenIndex(); i <= stop.getTokenIndex(); i++) {
  text += stream.get(i).getText();
}

@param start The first token in the interval to get text for. @param stop The last token in the interval to get text for (inclusive). @return The text of all tokens lying between the specified start and stop tokens.

@throws UnsupportedOperationException if this stream does not support this method for the specified tokens

Implementation

String getTextRange(Token? start, Token? stop);