Package com.j3d.engine.interact.cmd
Class CmdToken
java.lang.Object
com.j3d.engine.interact.cmd.CmdToken
Represents a token parsed from a command string.
Each token holds its original string input and, once parsed,
its interpreted type and value.
- Author:
- Lehlogonolo Poole
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines the possible types a command token can represent. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetInput()Returns the original raw string input of this token.Returns the parsed value of this token.getType()Returns the interpreted type of this token.voidparsedAs(Object o, CmdToken.Type t) Sets the parsed value and type of this token.static StringConverts a list of objects back into a single space-separated string.static StringConverts a list of CmdToken objects back into a single space-separated string.toString()Returns the original input string of this token.
-
Field Details
-
input
-
type
-
parsedValue
-
-
Constructor Details
-
CmdToken
Constructs a new CmdToken with the given input string.- Parameters:
input- The raw string input for this token.
-
-
Method Details
-
toStr
Converts a list of CmdToken objects back into a single space-separated string.- Parameters:
tokens- An ArrayList of CmdToken objects.- Returns:
- A string representation of the tokens, joined by spaces.
-
toStr
Converts a list of objects back into a single space-separated string.- Parameters:
arr- An array objects.- Returns:
- A string representation of the objects, joined by spaces.
-
parsedAs
Sets the parsed value and type of this token. This method is typically called after the token's input string has been successfully interpreted into a specific data type.- Parameters:
o- The parsed object value.t- The type of the parsed value.
-
getParsedValue
Returns the parsed value of this token. The caller is responsible for casting this Object to the correct type based ongetType().- Returns:
- The parsed value as an Object, or null if not yet parsed.
-
getInput
Returns the original raw string input of this token.- Returns:
- The original input string.
-
getType
Returns the interpreted type of this token.- Returns:
- The
CmdToken.Typeenum constant representing the token's type, or null if not yet parsed.
-
toString
Returns the original input string of this token. This is a convenience method, equivalent togetInput().
-