public final class JsonString extends Object implements JsonValue
It represents the string as a String
, which is the same as Embulk's STRING
column type.
JsonValue.EntityType
Modifier and Type | Method and Description |
---|---|
JsonString |
asJsonString()
Returns this value as
JsonString . |
boolean |
equals(Object otherObject)
Compares the specified object with this JSON string for equality.
|
CharSequence |
getChars()
Returns this JSON string as
CharSequence . |
JsonValue.EntityType |
getEntityType()
Returns
JsonValue.EntityType.STRING , which is the entity type of JsonString . |
String |
getString()
Returns this JSON string as
String . |
int |
hashCode()
Returns the hash code value for this JSON string.
|
static JsonString |
of(String value)
Returns a JSON string that is represented by the specified
String . |
int |
presumeReferenceSizeInBytes()
Returns the approximate size of this JSON string in bytes presumed to occupy in
Page as a reference. |
String |
toJson()
Returns the stringified JSON representation of this JSON string.
|
Value |
toMsgpack()
Deprecated.
Do not use this method. It is to be removed at some point after Embulk v1.0.0.
It is here only to ensure a migration period from MessagePack-based JSON values to new
JSON values of
JsonValue . |
String |
toString()
Returns the string representation of this JSON string.
|
static JsonString |
withLiteral(String value,
String literal)
Returns a JSON string that is represented by the specified
String , with the specified JSON literal. |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asJsonArray, asJsonBoolean, asJsonDouble, asJsonLong, asJsonNull, asJsonObject, fromMsgpack, isJsonArray, isJsonBoolean, isJsonDouble, isJsonLong, isJsonNull, isJsonObject, isJsonString
public static JsonString of(String value)
String
.
This method does not automatically apply String.intern()
for value
.
value
- the string, not nullString
NullPointerException
- if the string is null
public static JsonString withLiteral(String value, String literal)
String
, with the specified JSON literal.
This method does not automatically apply String.intern()
for value
.
The literal is just subsidiary information used when stringifying this JSON string as JSON by toJson()
.
Note that the literal usually need to be quoted, for example, JsonString.withLiteral("foo\n", "\"foo\\n\"")
.
value
- the string, not nullliteral
- the JSON literal of the stringString
NullPointerException
- if the string is null
public JsonValue.EntityType getEntityType()
JsonValue.EntityType.STRING
, which is the entity type of JsonString
.getEntityType
in interface JsonValue
JsonValue.EntityType.STRING
, which is the entity type of JsonString
public JsonString asJsonString()
JsonString
.asJsonString
in interface JsonValue
JsonString
public int presumeReferenceSizeInBytes()
Page
as a reference.
This approximate size is used only as a threshold whether PageBuilder
is flushed, or not.
It is not accurate, it does not need to be accurate, and it is impossible in general to tell an accurate size that
a Java object occupies in the Java heap. But, a reasonable approximate would help to keep Page
performant in the Java heap.
It is better to flush more frequently for bigger JSON value objects, less often for smaller JSON value objects, but no infinite accumulation even for empty JSON value objects.
presumeReferenceSizeInBytes
in interface JsonValue
Page
as a referencepublic String getString()
String
.String
representation of this JSON stringpublic CharSequence getChars()
CharSequence
.CharSequence
representation of this JSON stringpublic String toJson()
If this JSON string is created with a literal by withLiteral(String, String)
, it returns the literal. Otherwise,
it returns an escaped and quoted representation, which is valid as JSON, of this JSON string.
@Deprecated public Value toMsgpack()
JsonValue
.toMsgpack
in interface JsonValue
public String toString()
It returns an escaped and quoted representation like "string"
, which is valid as JSON, of this JSON string.
It does not consider a literal by withLiteral(String, String)
unlike toJson()
.
public boolean equals(Object otherObject)