Package com.github.tnakamot.json.value
Class JSONValueString
- java.lang.Object
-
- com.github.tnakamot.json.value.JSONValue
-
- com.github.tnakamot.json.value.JSONValuePrimitive
-
- com.github.tnakamot.json.value.JSONValueString
-
public class JSONValueString extends JSONValuePrimitive
Represents one JSON 'string' value.Instances of this class are immutable.
-
-
Constructor Summary
Constructors Constructor Description JSONValueString(JSONTokenString token)
Create an instance of a Java representation of a JSON string value from a JSON string token.JSONValueString(String value)
Create an instance of a Java representation of a JSON string value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
hashCode()
String
toString()
@NotNull String
toTokenString()
Convert this JSON value toString
which can be saved as a JSON text to a file or transmitted to network.@NotNull String
toTokenString(String newline, String indent)
Convert this JSON value toString
which can be saved as a JSON text to a file or transmitted to network.String
value()
Return the value represented by a JavaString
object of this JSON string value.-
Methods inherited from class com.github.tnakamot.json.value.JSONValuePrimitive
token
-
Methods inherited from class com.github.tnakamot.json.value.JSONValue
toTokenBytes, toTokenBytes, type
-
-
-
-
Constructor Detail
-
JSONValueString
public JSONValueString(String value)
Create an instance of a Java representation of a JSON string value.- Parameters:
value
- value represented by a JavaString
object of this JSON string value. Null is considered as an empty string.
-
JSONValueString
public JSONValueString(JSONTokenString token)
Create an instance of a Java representation of a JSON string value from a JSON string token.- Parameters:
token
- source token of this JSON string value.
-
-
Method Detail
-
value
public String value()
Return the value represented by a JavaString
object of this JSON string value.- Returns:
- value represented by a Java
String
object of this JSON string value. Never be null.
-
toTokenString
@NotNull public @NotNull String toTokenString()
Description copied from class:JSONValue
Convert this JSON value toString
which can be saved as a JSON text to a file or transmitted to network. The output text is optimized for machine, so no indent or new lines will be inserted.Note that, according to RFC 8259 - 8.1 Character Encoding, your application program must encode the returned String using UTF-8 without BOM before writing the returned
String
to a file or a network stream, or network datagram(s). It is caller's responsibility to correctly encode it.- Specified by:
toTokenString
in classJSONValue
- Returns:
- a string representation of this JSON value
-
toTokenString
@NotNull public @NotNull String toTokenString(String newline, String indent)
Description copied from class:JSONValue
Convert this JSON value toString
which can be saved as a JSON text to a file or transmitted to network. The output text is optimized for human. Indents and new line characters are inserted accordingly.Note that, according to RFC 8259 - 8.1 Character Encoding, your application program must encode the returned String using UTF-8 without BOM before writing the returned
String
to a file or a network stream, or network datagram(s). It is caller's responsibility to correctly encode it.- Specified by:
toTokenString
in classJSONValue
- Parameters:
newline
- line separator; "\r", "\n" or "\r\n"indent
- indent string. Must consist of " " and "\t".- Returns:
- a string representation of this JSON value
-
-