Class ParagraphParser
java.lang.Object
net.apartium.cocoabeans.commands.parsers.ArgumentParser<String>
net.apartium.cocoabeans.commands.parsers.ParagraphParser
- All Implemented Interfaces:
Comparable<ArgumentParser<?>>
Parsers that let you press strings that are more than one word and are limited by using quotation marks and has support for new lines
Example
Input
Output
Example
Input
/test Hello\nWorld
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
ConstructorsConstructorDescriptionParagraphParser(int priority) Creates paragraph parserParagraphParser(int priority, String keyword) Creates paragraph 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
-
ParagraphParser
Creates paragraph parser- Parameters:
priority- priority of the parserkeyword- keyword that should be used
-
ParagraphParser
public ParagraphParser(int priority) Creates paragraph 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
-