Class JsonStringFormatter
- java.lang.Object
-
- com.github.shyiko.mysql.binlog.event.deserialization.json.JsonStringFormatter
-
- All Implemented Interfaces:
JsonFormatter
public class JsonStringFormatter extends Object implements JsonFormatter
AJsonFormatterimplementation that creates a JSON string representation.- Author:
- Randall Hauch
-
-
Constructor Summary
Constructors Constructor Description JsonStringFormatter()JsonStringFormatter(int capacity)Constructs a JsonFormatter with the given initial capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendDate(int year, int month, int day)protected voidappendFourDigitUnsignedInt(int value)protected voidappendSixDigitUnsignedInt(int value, boolean trimTrailingZeros)protected voidappendString(String original)Append a string by escaping any characters that must be escaped.protected voidappendTime(int hour, int min, int sec, int microSeconds)protected voidappendTwoDigitUnsignedInt(int value)voidbeginArray(int numElements)Prepare to receive the value pairs that in a JSON array.voidbeginObject(int numElements)Prepare to receive the name-value pairs in a JSON object.voidendArray()Complete the previously-started JSON array.voidendObject()Complete the previously-started JSON object.StringgetString()voidname(String name)Receive the name of an element in a JSON object.voidnextEntry()Called after an entry signaling that another entry will be signaled.StringtoString()voidvalue(boolean value)Receive the boolean value of an element in a JSON object.voidvalue(double value)Receive the double value of an element in a JSON object.voidvalue(int value)Receive the integer value of an element in a JSON object.voidvalue(long value)Receive the long value of an element in a JSON object.voidvalue(String value)Receive the string value of an element in a JSON object.voidvalue(BigDecimal value)Receive theBigDecimalvalue of an element in a JSON object.voidvalue(BigInteger value)Receive theBigIntegervalue of an element in a JSON object.voidvalueDate(int year, int month, int day)Receive the date value of an element in a JSON object.voidvalueDatetime(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.voidvalueNull()Receive a null value of an element in a JSON object.voidvalueOpaque(ColumnType type, byte[] value)Receive an opaque value of an element in a JSON object.voidvalueTime(int hour, int min, int sec, int microSeconds)Receive the time value of an element in a JSON object.voidvalueTimestamp(long secondsPastEpoch, int microSeconds)Receive the timestamp value of an element in a JSON object.voidvalueYear(int year)Receive the year value of an element in a JSON object.
-
-
-
Method Detail
-
getString
public String getString()
-
beginObject
public void beginObject(int numElements)
Description copied from interface:JsonFormatterPrepare to receive the name-value pairs in a JSON object.- Specified by:
beginObjectin interfaceJsonFormatter- Parameters:
numElements- the number of name-value pairs (or elements)
-
beginArray
public void beginArray(int numElements)
Description copied from interface:JsonFormatterPrepare to receive the value pairs that in a JSON array.- Specified by:
beginArrayin interfaceJsonFormatter- Parameters:
numElements- the number of array elements
-
endObject
public void endObject()
Description copied from interface:JsonFormatterComplete the previously-started JSON object.- Specified by:
endObjectin interfaceJsonFormatter
-
endArray
public void endArray()
Description copied from interface:JsonFormatterComplete the previously-started JSON array.- Specified by:
endArrayin interfaceJsonFormatter
-
name
public void name(String name)
Description copied from interface:JsonFormatterReceive the name of an element in a JSON object.- Specified by:
namein interfaceJsonFormatter- Parameters:
name- the element's name; never null
-
value
public void value(String value)
Description copied from interface:JsonFormatterReceive the string value of an element in a JSON object.- Specified by:
valuein interfaceJsonFormatter- Parameters:
value- the element's value; never null
-
value
public void value(int value)
Description copied from interface:JsonFormatterReceive the integer value of an element in a JSON object.- Specified by:
valuein interfaceJsonFormatter- Parameters:
value- the element's value
-
value
public void value(long value)
Description copied from interface:JsonFormatterReceive the long value of an element in a JSON object.- Specified by:
valuein interfaceJsonFormatter- Parameters:
value- the element's value
-
value
public void value(double value)
Description copied from interface:JsonFormatterReceive the double value of an element in a JSON object.- Specified by:
valuein interfaceJsonFormatter- Parameters:
value- the element's value
-
value
public void value(BigInteger value)
Description copied from interface:JsonFormatterReceive theBigIntegervalue of an element in a JSON object.- Specified by:
valuein interfaceJsonFormatter- Parameters:
value- the element's value; never null
-
value
public void value(BigDecimal value)
Description copied from interface:JsonFormatterReceive theBigDecimalvalue of an element in a JSON object.- Specified by:
valuein interfaceJsonFormatter- Parameters:
value- the element's value; never null
-
value
public void value(boolean value)
Description copied from interface:JsonFormatterReceive the boolean value of an element in a JSON object.- Specified by:
valuein interfaceJsonFormatter- Parameters:
value- the element's value
-
valueNull
public void valueNull()
Description copied from interface:JsonFormatterReceive a null value of an element in a JSON object.- Specified by:
valueNullin interfaceJsonFormatter
-
valueYear
public void valueYear(int year)
Description copied from interface:JsonFormatterReceive the year value of an element in a JSON object.- Specified by:
valueYearin interfaceJsonFormatter- Parameters:
year- the year number that makes up the element's value
-
valueDate
public void valueDate(int year, int month, int day)Description copied from interface:JsonFormatterReceive the date value of an element in a JSON object.- Specified by:
valueDatein interfaceJsonFormatter- Parameters:
year- 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 value
-
valueDatetime
public void valueDatetime(int year, int month, int day, int hour, int min, int sec, int microSeconds)Description copied from interface:JsonFormatterReceive the date and time value of an element in a JSON object.- Specified by:
valueDatetimein interfaceJsonFormatter- Parameters:
year- 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 value
-
valueTime
public void valueTime(int hour, int min, int sec, int microSeconds)Description copied from interface:JsonFormatterReceive the time value of an element in a JSON object.- Specified by:
valueTimein interfaceJsonFormatter- Parameters:
hour- 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 value
-
valueTimestamp
public void valueTimestamp(long secondsPastEpoch, int microSeconds)Description copied from interface:JsonFormatterReceive the timestamp value of an element in a JSON object.- Specified by:
valueTimestampin interfaceJsonFormatter- Parameters:
secondsPastEpoch- the number of seconds past epoch (January 1, 1970) in the element's timestamp valuemicroSeconds- the number of microseconds in the element's time value
-
valueOpaque
public void valueOpaque(ColumnType type, byte[] value)
Description copied from interface:JsonFormatterReceive an opaque value of an element in a JSON object.- Specified by:
valueOpaquein interfaceJsonFormatter- Parameters:
type- the column type for the value; may not be nullvalue- the binary representation for the element's value
-
nextEntry
public void nextEntry()
Description copied from interface:JsonFormatterCalled after an entry signaling that another entry will be signaled.- Specified by:
nextEntryin interfaceJsonFormatter
-
appendString
protected void appendString(String original)
Append a string by escaping any characters that must be escaped.- Parameters:
original- the string to be written; may not be null
-
appendTwoDigitUnsignedInt
protected void appendTwoDigitUnsignedInt(int value)
-
appendFourDigitUnsignedInt
protected void appendFourDigitUnsignedInt(int value)
-
appendSixDigitUnsignedInt
protected void appendSixDigitUnsignedInt(int value, boolean trimTrailingZeros)
-
appendDate
protected void appendDate(int year, int month, int day)
-
appendTime
protected void appendTime(int hour, int min, int sec, int microSeconds)
-
-