Package groovy.json
Enum Class JsonTokenType
- All Implemented Interfaces:
Serializable,Comparable<JsonTokenType>,Constable
The original slurper and lexer use this class.
This is kept around in case someone needs its exact behavior.
Enum listing all the possible JSON tokens that should be recognized by the lexer.
- Since:
- 1.8.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionClosing square bracket token.Closing curly brace token.Colon token.Comma token.falseliteral token.nullliteral token.Numeric literal token.Opening square bracket token.Opening curly brace token.String literal token.trueliteral token. -
Method Summary
Modifier and TypeMethodDescriptiongetLabel()Returns the human-readable description of this token type.Returns the validator used to recognize this token type.booleanTells if an input string matches a token.static JsonTokenTypestartingWith(char c) Find which JSON value might be starting with a given characterstatic JsonTokenTypeReturns the enum constant of this class with the specified name.static JsonTokenType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
OPEN_CURLY
Opening curly brace token. -
CLOSE_CURLY
Closing curly brace token. -
OPEN_BRACKET
Opening square bracket token. -
CLOSE_BRACKET
Closing square bracket token. -
COLON
Colon token. -
COMMA
Comma token. -
NULL
nullliteral token. -
TRUE
trueliteral token. -
FALSE
falseliteral token. -
NUMBER
Numeric literal token. -
STRING
String literal token.Original pattern throws the
StackOverflowErrorfor long strings with backslashes. It is therefore replaced by a 2-step approach inspired by json2.js sources: https://github.com/douglascrockford/JSON-js/blob/master/json2.js#L462 See JsonTokenTypeTest#testMatchingLongStringWithBackslashes() for details.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
matching
Tells if an input string matches a token.- Parameters:
input- the input string to match- Returns:
- a
Matchingenum value:YESif this is an exact match,POSSIBLEif more characters could turn the input string into a valid token, orNOif the string cannot possibly match the pattern even with more characters to read.
-
startingWith
Find which JSON value might be starting with a given character- Parameters:
c- the character- Returns:
- the possible token type found
-
getLabel
Returns the human-readable description of this token type.- Returns:
- the token label
-
getValidator
Returns the validator used to recognize this token type.- Returns:
- the token validator
-