com.github.shyiko.mysql.binlog.event.deserialization.json
Class JsonStringFormatter

java.lang.Object
  extended by com.github.shyiko.mysql.binlog.event.deserialization.json.JsonStringFormatter
All Implemented Interfaces:
JsonFormatter

public class JsonStringFormatter
extends Object
implements JsonFormatter

A JsonFormatter implementation that creates a JSON string representation.

Author:
Randall Hauch

Constructor Summary
JsonStringFormatter()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonStringFormatter

public JsonStringFormatter()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getString

public String getString()

beginObject

public void beginObject(int numElements)
Description copied from interface: JsonFormatter
Prepare to receive the name-value pairs in a JSON object.

Specified by:
beginObject in interface JsonFormatter
Parameters:
numElements - the number of name-value pairs (or elements)

beginArray

public void beginArray(int numElements)
Description copied from interface: JsonFormatter
Prepare to receive the value pairs that in a JSON array.

Specified by:
beginArray in interface JsonFormatter
Parameters:
numElements - the number of array elements

endObject

public void endObject()
Description copied from interface: JsonFormatter
Complete the previously-started JSON object.

Specified by:
endObject in interface JsonFormatter

endArray

public void endArray()
Description copied from interface: JsonFormatter
Complete the previously-started JSON array.

Specified by:
endArray in interface JsonFormatter

name

public void name(String name)
Description copied from interface: JsonFormatter
Receive the name of an element in a JSON object.

Specified by:
name in interface JsonFormatter
Parameters:
name - the element's name; never null

value

public void value(String value)
Description copied from interface: JsonFormatter
Receive the string value of an element in a JSON object.

Specified by:
value in interface JsonFormatter
Parameters:
value - the element's value; never null

value

public void value(int value)
Description copied from interface: JsonFormatter
Receive the integer value of an element in a JSON object.

Specified by:
value in interface JsonFormatter
Parameters:
value - the element's value

value

public void value(long value)
Description copied from interface: JsonFormatter
Receive the long value of an element in a JSON object.

Specified by:
value in interface JsonFormatter
Parameters:
value - the element's value

value

public void value(double value)
Description copied from interface: JsonFormatter
Receive the double value of an element in a JSON object.

Specified by:
value in interface JsonFormatter
Parameters:
value - the element's value

value

public void value(BigInteger value)
Description copied from interface: JsonFormatter
Receive the BigInteger value of an element in a JSON object.

Specified by:
value in interface JsonFormatter
Parameters:
value - the element's value; never null

value

public void value(BigDecimal value)
Description copied from interface: JsonFormatter
Receive the BigDecimal value of an element in a JSON object.

Specified by:
value in interface JsonFormatter
Parameters:
value - the element's value; never null

value

public void value(boolean value)
Description copied from interface: JsonFormatter
Receive the boolean value of an element in a JSON object.

Specified by:
value in interface JsonFormatter
Parameters:
value - the element's value

valueNull

public void valueNull()
Description copied from interface: JsonFormatter
Receive a null value of an element in a JSON object.

Specified by:
valueNull in interface JsonFormatter

valueYear

public void valueYear(int year)
Description copied from interface: JsonFormatter
Receive the year value of an element in a JSON object.

Specified by:
valueYear in interface JsonFormatter
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: JsonFormatter
Receive the date value of an element in a JSON object.

Specified by:
valueDate in interface JsonFormatter
Parameters:
year - the positive or negative year in the element's date value
month - the month (0-12) in the element's date value
day - 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: JsonFormatter
Receive the date and time value of an element in a JSON object.

Specified by:
valueDatetime in interface JsonFormatter
Parameters:
year - the positive or negative year in the element's date value
month - the month (0-12) in the element's date value
day - the day of the month (0-31) in the element's date value
hour - the hour of the day (0-24) in the element's time value
min - the minutes of the hour (0-60) in the element's time value
sec - the seconds of the minute (0-60) in the element's time value
microSeconds - 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: JsonFormatter
Receive the time value of an element in a JSON object.

Specified by:
valueTime in interface JsonFormatter
Parameters:
hour - the hour of the day (0-24) in the element's time value
min - the minutes of the hour (0-60) in the element's time value
sec - the seconds of the minute (0-60) in the element's time value
microSeconds - the number of microseconds in the element's time value

valueTimestamp

public void valueTimestamp(long secondsPastEpoch,
                           int microSeconds)
Description copied from interface: JsonFormatter
Receive the timestamp value of an element in a JSON object.

Specified by:
valueTimestamp in interface JsonFormatter
Parameters:
secondsPastEpoch - the number of seconds past epoch (January 1, 1970) in the element's timestamp value
microSeconds - the number of microseconds in the element's time value

valueOpaque

public void valueOpaque(ColumnType type,
                        byte[] value)
Description copied from interface: JsonFormatter
Receive an opaque value of an element in a JSON object.

Specified by:
valueOpaque in interface JsonFormatter
Parameters:
type - the column type for the value; may not be null
value - the binary representation for the element's value

nextEntry

public void nextEntry()
Description copied from interface: JsonFormatter
Called after an entry signaling that another entry will be signaled.

Specified by:
nextEntry in interface JsonFormatter

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)


Copyright © 2016. All Rights Reserved.