Package com.github.tnakamot.json.token
Class JSONTokenString
- java.lang.Object
-
- com.github.tnakamot.json.token.JSONToken
-
- com.github.tnakamot.json.token.JSONTokenString
-
public class JSONTokenString extends JSONToken
Represents one "string" type token in JSON text.A string token in a JSON text is surrounded by double quotations, and some special characters are unescaped. The method
value()
strips the surrounding double quotations, unescape the escaped characters and returns in accordance with RFC 8259 - 7. Strings.Instances of this class are immutable.
-
-
Field Summary
-
Fields inherited from class com.github.tnakamot.json.token.JSONToken
JSON_BEGIN_ARRAY, JSON_BEGIN_OBJECT, JSON_END_ARRAY, JSON_END_OBJECT, JSON_NAME_SEPARATOR, JSON_VALUE_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description JSONTokenString(String text, String value, StringLocation begin, StringLocation end, JSONText source)
Creates one "string" type token of a JSON text.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
value()
Returns the string value of this token represents.-
Methods inherited from class com.github.tnakamot.json.token.JSONToken
beginningLocation, endLocation, range, source, text, type
-
-
-
-
Constructor Detail
-
JSONTokenString
public JSONTokenString(String text, String value, StringLocation begin, StringLocation end, JSONText source)
Creates one "string" type token of a JSON text.It is the caller's responsibility to validate the token text as string before creating this instance.
- Parameters:
text
- text of this tokenvalue
- string value that this token represents (it is a caller's responsibility to parse the token text, strip surrounding double quotations and unescape escaped characters)begin
- 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
-
-
Method Detail
-
value
public String value()
Returns the string value of this token represents. All escapes characters in the original JSON text are unescaped.- Returns:
- The string value of this token represents. Never be null.
- See Also:
- RFC 8259 - 7. Strings
-
-