public class JsonStringFormatter extends Object implements JsonFormatter
JsonFormatter implementation that creates a JSON string representation.| Constructor and Description |
|---|
JsonStringFormatter() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
appendDate(int year,
int month,
int day) |
protected void |
appendFourDigitUnsignedInt(int value) |
protected void |
appendSixDigitUnsignedInt(int value,
boolean trimTrailingZeros) |
protected void |
appendString(String original)
Append a string by escaping any characters that must be escaped.
|
protected void |
appendTime(int hour,
int min,
int sec,
int microSeconds) |
protected void |
appendTwoDigitUnsignedInt(int value) |
void |
beginArray(int numElements)
Prepare to receive the value pairs that in a JSON array.
|
void |
beginObject(int numElements)
Prepare to receive the name-value pairs in a JSON object.
|
void |
endArray()
Complete the previously-started JSON array.
|
void |
endObject()
Complete the previously-started JSON object.
|
String |
getString() |
void |
name(String name)
Receive the name of an element in a JSON object.
|
void |
nextEntry()
Called after an entry signaling that another entry will be signaled.
|
String |
toString() |
void |
value(BigDecimal value)
Receive the
BigDecimal value of an element in a JSON object. |
void |
value(BigInteger value)
Receive the
BigInteger value of an element in a JSON object. |
void |
value(boolean value)
Receive the boolean value of an element in a JSON object.
|
void |
value(double value)
Receive the double value of an element in a JSON object.
|
void |
value(int value)
Receive the integer value of an element in a JSON object.
|
void |
value(long value)
Receive the long value of an element in a JSON object.
|
void |
value(String value)
Receive the string value of an element in a JSON object.
|
void |
valueDate(int year,
int month,
int day)
Receive the date value of an element in a JSON object.
|
void |
valueDatetime(int year,
int month,
int day,
int hour,
int min,
int sec,
int microSeconds)
Receive the date and time value of an element in a JSON object.
|
void |
valueNull()
Receive a null value of an element in a JSON object.
|
void |
valueOpaque(ColumnType type,
byte[] value)
Receive an opaque value of an element in a JSON object.
|
void |
valueTime(int hour,
int min,
int sec,
int microSeconds)
Receive the time value of an element in a JSON object.
|
void |
valueTimestamp(long secondsPastEpoch,
int microSeconds)
Receive the timestamp value of an element in a JSON object.
|
void |
valueYear(int year)
Receive the year value of an element in a JSON object.
|
public String getString()
public void beginObject(int numElements)
JsonFormatterbeginObject in interface JsonFormatternumElements - the number of name-value pairs (or elements)public void beginArray(int numElements)
JsonFormatterbeginArray in interface JsonFormatternumElements - the number of array elementspublic void endObject()
JsonFormatterendObject in interface JsonFormatterpublic void endArray()
JsonFormatterendArray in interface JsonFormatterpublic void name(String name)
JsonFormattername in interface JsonFormattername - the element's name; never nullpublic void value(String value)
JsonFormattervalue in interface JsonFormattervalue - the element's value; never nullpublic void value(int value)
JsonFormattervalue in interface JsonFormattervalue - the element's valuepublic void value(long value)
JsonFormattervalue in interface JsonFormattervalue - the element's valuepublic void value(double value)
JsonFormattervalue in interface JsonFormattervalue - the element's valuepublic void value(BigInteger value)
JsonFormatterBigInteger value of an element in a JSON object.value in interface JsonFormattervalue - the element's value; never nullpublic void value(BigDecimal value)
JsonFormatterBigDecimal value of an element in a JSON object.value in interface JsonFormattervalue - the element's value; never nullpublic void value(boolean value)
JsonFormattervalue in interface JsonFormattervalue - the element's valuepublic void valueNull()
JsonFormattervalueNull in interface JsonFormatterpublic void valueYear(int year)
JsonFormattervalueYear in interface JsonFormatteryear - the year number that makes up the element's valuepublic void valueDate(int year,
int month,
int day)
JsonFormattervalueDate in interface JsonFormatteryear - the positive or negative year in the element's date valuemonth - the month (0-12) in the element's date valueday - the day of the month (0-31) in the element's date valuepublic void valueDatetime(int year,
int month,
int day,
int hour,
int min,
int sec,
int microSeconds)
JsonFormattervalueDatetime in interface JsonFormatteryear - the positive or negative year in the element's date valuemonth - the month (0-12) in the element's date valueday - the day of the month (0-31) in the element's date valuehour - the hour of the day (0-24) in the element's time valuemin - the minutes of the hour (0-60) in the element's time valuesec - the seconds of the minute (0-60) in the element's time valuemicroSeconds - the number of microseconds in the element's time valuepublic void valueTime(int hour,
int min,
int sec,
int microSeconds)
JsonFormattervalueTime in interface JsonFormatterhour - the hour of the day (0-24) in the element's time valuemin - the minutes of the hour (0-60) in the element's time valuesec - the seconds of the minute (0-60) in the element's time valuemicroSeconds - the number of microseconds in the element's time valuepublic void valueTimestamp(long secondsPastEpoch,
int microSeconds)
JsonFormattervalueTimestamp in interface JsonFormattersecondsPastEpoch - the number of seconds past epoch (January 1, 1970) in the element's timestamp valuemicroSeconds - the number of microseconds in the element's time valuepublic void valueOpaque(ColumnType type, byte[] value)
JsonFormattervalueOpaque in interface JsonFormattertype - the column type for the value; may not be nullvalue - the binary representation for the element's valuepublic void nextEntry()
JsonFormatternextEntry in interface JsonFormatterprotected void appendString(String original)
original - the string to be written; may not be nullprotected void appendTwoDigitUnsignedInt(int value)
protected void appendFourDigitUnsignedInt(int value)
protected void appendSixDigitUnsignedInt(int value,
boolean trimTrailingZeros)
protected void appendDate(int year,
int month,
int day)
protected void appendTime(int hour,
int min,
int sec,
int microSeconds)
Copyright © 2019. All rights reserved.