| Constructor and Description |
|---|
WordParser(Collection<String> words,
String description)
Constructor for when there's a fixed set of possibilities.
|
WordParser(String description)
Constructor when any word is acceptable.
|
| Modifier and Type | Method and Description |
|---|---|
protected Collection<String> |
getWords()
Get the set of valid words, if there is such a set.
|
String |
parse(ParseSession session,
ParseContext ctx,
boolean complete)
Parse text from the given parse context.
|
public WordParser(Collection<String> words, String description)
words - words to look fordescription - what to call words (e.g., "command")IllegalArgumentException - if words is nullIllegalArgumentException - if description is nullpublic WordParser(String description)
description - what to call words (e.g., "command")IllegalArgumentException - if words is nullIllegalArgumentException - if description is nullprotected Collection<String> getWords()
The implementation in WordParser returns the collection provided to the constructor, if any.
public String parse(ParseSession session, ParseContext ctx, boolean complete)
ParserGenerally speaking, this method may assume that any whitespace allowed before the item being parsed has already been skipped over (that's a matter for the containing parser).
Copyright © 2017. All rights reserved.