Package org.openhab.core.voice.text
Class TokenList
java.lang.Object
org.openhab.core.voice.text.TokenList
A helper to parse a sequence of tokens. This class is immutable.
- Author:
- Tilman Kamp - Initial contribution
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanChecks for the first token of the list.booleanChecks for the last token of the list.booleaneof()Checks, if the list is empty.head()Gets the first token of the list.Retrieves the first token of the list, in case it is equal to one of the provided alternatives.Retrieves the last token of the list, in case it is equal to one of the provided alternatives.intsize()Retrieves the token count within the list.skipHead()Creates a new list without the first token.skipTail()Creates a new list without the last token.tail()Gets the last token of the list.
- 
Constructor Details- 
TokenListConstructs a new instance.- Parameters:
- list- of the initial tokens
 
 
- 
- 
Method Details- 
headGets the first token of the list.- Returns:
- the first token of the list
 
- 
tailGets the last token of the list.- Returns:
- the last token of the list
 
- 
eofpublic boolean eof()Checks, if the list is empty.- Returns:
- if the list is empty
 
- 
sizepublic int size()Retrieves the token count within the list.- Returns:
- token count
 
- 
checkHeadChecks for the first token of the list. If it is equal to one of the provided alternatives, it will succeed.- Parameters:
- alternatives- Allowed token values for the list's first token. If empty, all token values are allowed.
- Returns:
- True, if first token is equal to one of the alternatives or if no alternatives were provided. False otherwise. Always false, if there is no first token (if the list is empty).
 
- 
checkTailChecks for the last token of the list. If it is equal to one of the provided alternatives, it will succeed.- Parameters:
- alternatives- Allowed token values for the list's last token. If empty, all token values are allowed.
- Returns:
- True, if last token is equal to one of the alternatives or if no alternatives were provided. False otherwise. Always false, if there is no last token (if the list is empty).
 
- 
peekHeadRetrieves the first token of the list, in case it is equal to one of the provided alternatives.- Parameters:
- alternatives- Allowed token values for the list's first token. If empty, all token values are allowed.
- Returns:
- First token, if it is equal to one of the alternatives or if no alternatives were provided. Null otherwise. Always null, if there is no first token (if the list is empty).
 
- 
peekTailRetrieves the last token of the list, in case it is equal to one of the provided alternatives.- Parameters:
- alternatives- Allowed token values for the list's last token. If empty, all token values are allowed.
- Returns:
- Last token, if it is equal to one of the alternatives or if no alternatives were provided. Null otherwise. Always null, if there is no last token (if the list is empty).
 
- 
skipHeadCreates a new list without the first token.- Returns:
- a new list without the first token
 
- 
skipTailCreates a new list without the last token.- Returns:
- a new list without the last token
 
 
-