Class QuotedStringParser
java.lang.Object
net.apartium.cocoabeans.commands.parsers.ArgumentParser<String>
net.apartium.cocoabeans.commands.parsers.QuotedStringParser
- All Implemented Interfaces:
Comparable<ArgumentParser<?>>
Quoted string parser
Parsers that let you press strings that are more than one word and are limited by using quotation marks
Examples
Input
Input
Examples
Input
/test hello
Output hello
Input
/test "hello world"
Output hello world - See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class net.apartium.cocoabeans.commands.parsers.ArgumentParser
ArgumentParser.ParseResult<T>, ArgumentParser.TabCompletionResult -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionQuotedStringParser(int priority) Creates quoted string parserQuotedStringParser(int priority, String keyword) Creates quoted string parser -
Method Summary
Modifier and TypeMethodDescriptionparse(CommandProcessingContext processingContext) Tries to parse next argument in the contexttabCompletion(CommandProcessingContext processingContext) Retrieves available options for tab completion of this argumenttryParse(CommandProcessingContext processingContext) Tries to lazily parse next argument in the contextMethods inherited from class net.apartium.cocoabeans.commands.parsers.ArgumentParser
compareTo, getArgumentType, getKeyword, getPriority
-
Field Details
-
DEFAULT_KEYWORD
- See Also:
-
ESCAPE_CHARACTER
public static final char ESCAPE_CHARACTER- See Also:
-
QUOTATION_CHARACTER
public static final char QUOTATION_CHARACTER- See Also:
-
NEW_LINE_CHARACTER
public static final char NEW_LINE_CHARACTER- See Also:
-
INVALID_QUOTATION_MESSAGE
- See Also:
-
-
Constructor Details
-
QuotedStringParser
Creates quoted string parser- Parameters:
priority- priority of the parserkeyword- keyword that should be used
-
QuotedStringParser
public QuotedStringParser(int priority) Creates quoted string parser- Parameters:
priority- priority of the parser
-
-
Method Details
-
parse
public Optional<ArgumentParser.ParseResult<String>> parse(CommandProcessingContext processingContext) Tries to parse next argument in the context- Specified by:
parsein classArgumentParser<String>- Parameters:
processingContext- cmd processing context- Returns:
- empty if failed, otherwise result
-
tryParse
Tries to lazily parse next argument in the context- Specified by:
tryParsein classArgumentParser<String>- Parameters:
processingContext- cmd processing context- Returns:
- new index int if success, empty if not
-
tabCompletion
public Optional<ArgumentParser.TabCompletionResult> tabCompletion(CommandProcessingContext processingContext) Retrieves available options for tab completion of this argument- Specified by:
tabCompletionin classArgumentParser<String>- Parameters:
processingContext- cmd processing context- Returns:
- tab completion result if success, otherwise empty option
-