de.unkrig.commons.text.scanner
Class StatelessScanner<TT extends java.lang.Enum<TT>>
java.lang.Object
de.unkrig.commons.text.scanner.AbstractScanner<TT>
de.unkrig.commons.text.scanner.StatelessScanner<TT>
- Type Parameters:
TT - Enumerates the scanner-specific token types
- All Implemented Interfaces:
- ProducerWhichThrows<AbstractScanner.Token<TT>,ScanException>, StringScanner<TT>
public class StatelessScanner<TT extends java.lang.Enum<TT>>
- extends AbstractScanner<TT>
A scanner that produces AbstractScanner.Tokens. Before produce() is called, the scanner must be
configured by invoking its addRule(String, Enum) methods. These define how character sequences are
converted into AbstractScanner.Tokens.
For an example usage, see the source code of Scanner
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
StatelessScanner
public StatelessScanner()
addRule
public void addRule(java.lang.String regex,
TT tokenType)
- Adds a rule that produces the given
tokenType if the next characters of the input match the given
regex.
produce
@Nullable
public AbstractScanner.Token<TT> produce()
throws ScanException
- Description copied from class:
AbstractScanner
- Before
AbstractScanner.setInput(CharSequence) is called, this method returns null. After AbstractScanner.setInput(CharSequence) was called, this method breaks the input char character sequence up into tokens and
returns them one by one. When the input char sequence is exhausted, null is returned until AbstractScanner.setInput(CharSequence) is called again.
- Specified by:
produce in interface ProducerWhichThrows<AbstractScanner.Token<TT extends java.lang.Enum<TT>>,ScanException>- Specified by:
produce in class AbstractScanner<TT extends java.lang.Enum<TT>>
- Returns:
null iff the input string is exhausted
- Throws:
ScanException