Contents
- Description
- Nested Class Summary
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- of(List, String, ParseResult)
- isOptionalArgumentToken(String)
- optionalArgumentName(String)
- optionalArgumentInlineValue(String)
- addNewOptionalArg(String)
- appendOptionalParameter(String, ParseResult)
- getInputString()
- getRawInput()
- getSubCommandIndex()
- isListToken(int)
- getNumPreOptSingleValueTokensBeforeListTokens()
- getNumPreOptionalTokens()
- getPreOptionalSingleValueToken(int)
- getPreOptionalListToken(int)
- getFirstToken()
- getOptionalArgs()
- isHelpSpecified()
- isConfirmationSpecified()
- convertToSubCommand()
Class ParserContext
java.lang.Object
com.hypixel.hytale.server.core.command.system.ParserContext
A ParserContext represents the basic tokens received from the
Tokenizer and gets
passed through the system to a command where it eventually becomes a CommandContext-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionParserContext(List<String> tokens, String rawInput, ParseResult parseResult) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNewOptionalArg(String name) Add a new optional argument name and create the optional arg context for itvoidappendOptionalParameter(String value, ParseResult parseResult) Append a parameter to the last-added optional arg contextvoidReturns the first token after the subcommand index, or null if noneintintgetPreOptionalListToken(int index) getPreOptionalSingleValueToken(int index) intbooleanDetermines whether the confirmation optional argument was specifiedbooleanbooleanisListToken(int index) static booleanisOptionalArgumentToken(String token) Whether a raw token begins an optional argument (a--nameor--name=valuetoken).static ParserContextof(List<String> tokens, String rawInput, ParseResult parseResult) Constructs a newParserContextstatic StringExtracts the inline value from a--name=valuetoken, ornullwhen the token carries no inline value.static StringoptionalArgumentName(String token) Extracts the name from a--nameor--name=valueoptional-argument token, sharing the same sentinel pattern asisOptionalArgumentToken(String)so the name and its value separator stay defined in one place.
-
Constructor Details
-
ParserContext
public ParserContext(@Nonnull List<String> tokens, @Nonnull String rawInput, @Nonnull ParseResult parseResult) - Parameters:
tokens- The List of String tokens from theTokenizerrawInput- The original unmodified command input string
-
-
Method Details
-
of
@Nonnull public static ParserContext of(@Nonnull List<String> tokens, @Nonnull String rawInput, @Nonnull ParseResult parseResult) Constructs a newParserContext- Parameters:
tokens- The List of String tokens from theTokenizerrawInput- The original unmodified command input string
-
isOptionalArgumentToken
Whether a raw token begins an optional argument (a--nameor--name=valuetoken). This is the single definition of the optional-argument sentinel, so command parsing and console tab completion classify tokens the same way and cannot drift if the syntax changes. -
optionalArgumentName
Extracts the name from a--nameor--name=valueoptional-argument token, sharing the same sentinel pattern asisOptionalArgumentToken(String)so the name and its value separator stay defined in one place. Returnsnullwhen the token is not an optional-argument token. -
optionalArgumentInlineValue
Extracts the inline value from a--name=valuetoken, ornullwhen the token carries no inline value. Uses the same pattern and quote stripping ascontextualizeTokens(List, ParseResult), so completion feeds an optional the same first parameter the parser does. -
addNewOptionalArg
Add a new optional argument name and create the optional arg context for it- Parameters:
name- the name of the optional arg that was found
-
appendOptionalParameter
Append a parameter to the last-added optional arg context- Parameters:
value- the parameter to add
-
getInputString
-
getRawInput
-
getSubCommandIndex
public int getSubCommandIndex() -
isListToken
public boolean isListToken(int index) -
getNumPreOptSingleValueTokensBeforeListTokens
public int getNumPreOptSingleValueTokensBeforeListTokens() -
getNumPreOptionalTokens
public int getNumPreOptionalTokens() -
getPreOptionalSingleValueToken
-
getPreOptionalListToken
-
getFirstToken
Returns the first token after the subcommand index, or null if none- Returns:
- the first token after the subcommand index, or null if none
-
getOptionalArgs
-
isHelpSpecified
public boolean isHelpSpecified() -
isConfirmationSpecified
public boolean isConfirmationSpecified()Determines whether the confirmation optional argument was specified- Returns:
trueif the confirmation argument was specified,falseotherwise
-
convertToSubCommand
public void convertToSubCommand()
-