Package org.h2.util.json
Class JSONStringTarget
JSON String target.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
(package private) static final byte
A JSON array.private final boolean
private final StringBuilder
(package private) static final char[]
The hex characters.private boolean
(package private) static final byte
A JSON object.private final ByteStack
-
Constructor Summary
ConstructorsConstructorDescriptionCreates new instance of JSON String target.JSONStringTarget
(boolean asciiPrintableOnly) Creates new instance of JSON String target. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
static StringBuilder
encodeString
(StringBuilder builder, String s, boolean asciiPrintableOnly) Encodes a JSON string and appends it to the specified string builder.void
endArray()
End of the current array.void
End of the current object.Returns the result.boolean
Returns whether member's name or the end of the current object is expected.boolean
Returns whether value separator expected before the next member or value.void
Name of a member.void
Start of an array.void
Start of an object.void
Parse "false".void
Parse "null".void
valueNumber
(BigDecimal number) A number value.void
valueString
(String string) A string value.void
Parse "true".
-
Field Details
-
HEX
static final char[] HEXThe hex characters. -
OBJECT
static final byte OBJECTA JSON object.- See Also:
-
ARRAY
static final byte ARRAYA JSON array.- See Also:
-
builder
-
stack
-
asciiPrintableOnly
private final boolean asciiPrintableOnly -
needSeparator
private boolean needSeparator -
afterName
private boolean afterName
-
-
Constructor Details
-
JSONStringTarget
public JSONStringTarget()Creates new instance of JSON String target. -
JSONStringTarget
public JSONStringTarget(boolean asciiPrintableOnly) Creates new instance of JSON String target.- Parameters:
asciiPrintableOnly
- whether all non-printable, non-ASCII characters, and'
(single quote) characters should be escaped
-
-
Method Details
-
encodeString
public static StringBuilder encodeString(StringBuilder builder, String s, boolean asciiPrintableOnly) Encodes a JSON string and appends it to the specified string builder.- Parameters:
builder
- the string builder to append tos
- the string to encodeasciiPrintableOnly
- whether all non-printable, non-ASCII characters, and'
(single quote) characters should be escaped- Returns:
- the specified string builder
-
startObject
public void startObject()Description copied from class:JSONTarget
Start of an object.- Specified by:
startObject
in classJSONTarget<String>
-
endObject
public void endObject()Description copied from class:JSONTarget
End of the current object.- Specified by:
endObject
in classJSONTarget<String>
-
startArray
public void startArray()Description copied from class:JSONTarget
Start of an array.- Specified by:
startArray
in classJSONTarget<String>
-
endArray
public void endArray()Description copied from class:JSONTarget
End of the current array.- Specified by:
endArray
in classJSONTarget<String>
-
member
Description copied from class:JSONTarget
Name of a member.- Specified by:
member
in classJSONTarget<String>
- Parameters:
name
- the name
-
valueNull
public void valueNull()Description copied from class:JSONTarget
Parse "null".null
value.- Specified by:
valueNull
in classJSONTarget<String>
-
valueFalse
public void valueFalse()Description copied from class:JSONTarget
Parse "false".false
value.- Specified by:
valueFalse
in classJSONTarget<String>
-
valueTrue
public void valueTrue()Description copied from class:JSONTarget
Parse "true".true
value.- Specified by:
valueTrue
in classJSONTarget<String>
-
valueNumber
Description copied from class:JSONTarget
A number value.- Specified by:
valueNumber
in classJSONTarget<String>
- Parameters:
number
- the number
-
valueString
Description copied from class:JSONTarget
A string value.- Specified by:
valueString
in classJSONTarget<String>
- Parameters:
string
- the string
-
beforeValue
private void beforeValue() -
afterValue
private void afterValue() -
isPropertyExpected
public boolean isPropertyExpected()Description copied from class:JSONTarget
Returns whether member's name or the end of the current object is expected.- Specified by:
isPropertyExpected
in classJSONTarget<String>
- Returns:
true
if it is,false
otherwise
-
isValueSeparatorExpected
public boolean isValueSeparatorExpected()Description copied from class:JSONTarget
Returns whether value separator expected before the next member or value.- Specified by:
isValueSeparatorExpected
in classJSONTarget<String>
- Returns:
true
if it is,false
otherwise
-
getResult
Description copied from class:JSONTarget
Returns the result.- Specified by:
getResult
in classJSONTarget<String>
- Returns:
- the result
-