Package com.github.tnakamot.json.token
Class JSONToken
- java.lang.Object
-
- com.github.tnakamot.json.token.JSONToken
-
- Direct Known Subclasses:
JSONTokenBoolean
,JSONTokenNull
,JSONTokenNumber
,JSONTokenString
public class JSONToken extends Object
Represents one token in JSON text.Instances of this class are immutable.
-
-
Field Summary
Fields Modifier and Type Field Description static String
JSON_BEGIN_ARRAY
static String
JSON_BEGIN_OBJECT
static String
JSON_END_ARRAY
static String
JSON_END_OBJECT
static String
JSON_NAME_SEPARATOR
static String
JSON_VALUE_SEPARATOR
-
Constructor Summary
Constructors Constructor Description JSONToken(@NotNull JSONTokenType type, @NotNull String text, @NotNull StringLocation location, @NotNull JSONText source)
Create one JSON text token.JSONToken(@NotNull JSONTokenType type, @NotNull String text, @NotNull StringLocation begin, @NotNull StringLocation end, @NotNull JSONText source)
Create one JSON text token.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull StringLocation
beginningLocation()
Location of the beginning of the token within the source JSON text.@NotNull StringLocation
endLocation()
Location of the end of the token within the source JSON text.@NotNull StringRange
range()
Location of this token within the source JSON text.@NotNull JSONText
source()
Source JSON text where this token was extracted from.@NotNull String
text()
Text representation of this token as it appears in the source JSON text.@NotNull JSONTokenType
type()
Type of this token.
-
-
-
Field Detail
-
JSON_BEGIN_ARRAY
public static final String JSON_BEGIN_ARRAY
- See Also:
- Constant Field Values
-
JSON_END_ARRAY
public static final String JSON_END_ARRAY
- See Also:
- Constant Field Values
-
JSON_BEGIN_OBJECT
public static final String JSON_BEGIN_OBJECT
- See Also:
- Constant Field Values
-
JSON_END_OBJECT
public static final String JSON_END_OBJECT
- See Also:
- Constant Field Values
-
JSON_NAME_SEPARATOR
public static final String JSON_NAME_SEPARATOR
- See Also:
- Constant Field Values
-
JSON_VALUE_SEPARATOR
public static final String JSON_VALUE_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JSONToken
public JSONToken(@NotNull @NotNull JSONTokenType type, @NotNull @NotNull String text, @NotNull @NotNull StringLocation begin, @NotNull @NotNull StringLocation end, @NotNull @NotNull JSONText source)
Create one JSON text token.- Parameters:
type
- type of this tokentext
- text of this tokenbegin
- beginning location of this token within the source JSON textend
- end location of this token within the source JSON textsource
- source JSON text where this token was extracted from
-
JSONToken
public JSONToken(@NotNull @NotNull JSONTokenType type, @NotNull @NotNull String text, @NotNull @NotNull StringLocation location, @NotNull @NotNull JSONText source)
Create one JSON text token.- Parameters:
type
- type of this tokentext
- text of this tokenlocation
- location of this token within the source JSON textsource
- source JSON text where this token was extracted from
-
-
Method Detail
-
type
@NotNull public @NotNull JSONTokenType type()
Type of this token.- Returns:
- type of this token
-
text
@NotNull public @NotNull String text()
Text representation of this token as it appears in the source JSON text.- Returns:
- text representation of this token as it appears in the source JSON text.
-
range
@NotNull public @NotNull StringRange range()
Location of this token within the source JSON text.- Returns:
- location of this token within the source JSON text.
-
beginningLocation
@NotNull public @NotNull StringLocation beginningLocation()
Location of the beginning of the token within the source JSON text.- Returns:
- location of the beginning of the token within the source JSON text.
-
endLocation
@NotNull public @NotNull StringLocation endLocation()
Location of the end of the token within the source JSON text.- Returns:
- location of the end of the token within the source JSON text.
-
source
@NotNull public @NotNull JSONText source()
Source JSON text where this token was extracted from.- Returns:
- source JSON text where this token was extracted from.
-
-