Class Tokenizer
java.lang.Object
cz.zcu.fav.kiv.mjakubas.saf.parser.tokenizer.Tokenizer
Tokenizes command.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char
static final char
static final char
-
Constructor Summary
ConstructorsConstructorDescriptionTokenizer
(@NotNull Properties commandProperties) Instantiates newTokenizer
with commandProperties
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isClassValue
(@NotNull String arg) Checks if argument is expected to be ofClass
value.boolean
isFileTypeValue
(@NotNull String arg) Checks if argument is expected to be ofFileType
value.Class<?>
processClassValue
(@NotNull String arg) Tries to process a command argument as aClass
value.Class<?>
Processes a command as aFileType
.processStringValue
(@NotNull String arg) Process a command as aString
value either as a fixed command value or as an expected command value wrapped in curly brackets.Tokenizes array ofString
arguments.
-
Field Details
-
CLASS_TOKEN_IDENTIFIER
public static final char CLASS_TOKEN_IDENTIFIER- See Also:
-
COMMAND_STRING_TOKEN_IDENTIFIER
public static final char COMMAND_STRING_TOKEN_IDENTIFIER- See Also:
-
FILETYPE_CLASS_TOKEN_IDENTIFIER
public static final char FILETYPE_CLASS_TOKEN_IDENTIFIER- See Also:
-
-
Constructor Details
-
Tokenizer
Instantiates newTokenizer
with commandProperties
.- Parameters:
commandProperties
-Properties
containing list of accepted commands
-
-
Method Details
-
tokenize
Tokenizes array ofString
arguments.- Parameters:
args
- array ofString
arguments- Returns:
- tokenized array of
String
arguments - Throws:
TokenException
- if any argument fails to be tokenized
-
isClassValue
Checks if argument is expected to be ofClass
value.- Parameters:
arg
- argument- Returns:
- true or false
-
isFileTypeValue
Checks if argument is expected to be ofFileType
value.- Parameters:
arg
- argument- Returns:
- true or false
-
processClassValue
Tries to process a command argument as aClass
value. The argument should be wrapped in angle brackets.- Parameters:
arg
- command argument- Returns:
Class
of token- Throws:
ClassNotFoundException
- ifClass
is not found
-
processFileTypeValue
Processes a command as aFileType
. The argument should be wrapped in square brackets. -
processStringValue
Process a command as aString
value either as a fixed command value or as an expected command value wrapped in curly brackets.- Parameters:
arg
- command argument- Returns:
String
value- Throws:
IOException
- if expected command doesn't exist
-