org.gridkit.jvmtool.stacktrace.codec.json
Class JsonStreamHandler

java.lang.Object
  extended by org.gridkit.jvmtool.stacktrace.codec.json.JsonStreamHandler
All Implemented Interfaces:
JsonStreamWriter

public class JsonStreamHandler
extends Object
implements JsonStreamWriter

Utility class for parsing JSON event stream.

Author:
Alexey Ragozin (alexey.ragozin@gmail.com)

Nested Class Summary
static interface JsonStreamHandler.JsonEntityHandler
           
static interface JsonStreamHandler.JsonListHandler
           
static class JsonStreamHandler.JsonNullHandler
           
static interface JsonStreamHandler.JsonObjectHandler
           
 
Field Summary
static JsonStreamHandler.JsonNullHandler NULL_HANDLER
           
static boolean TRACE
           
 
Constructor Summary
JsonStreamHandler()
           
 
Method Summary
 boolean isAcomplished()
           
protected  void onValue(Object val)
           
protected  void pop()
           
protected  void push(JsonStreamHandler.JsonEntityHandler handler)
           
 void reset(JsonStreamHandler.JsonEntityHandler handler)
           
protected  JsonStreamHandler.JsonEntityHandler top()
           
protected  JsonStreamHandler.JsonListHandler topListHandler()
           
protected  JsonStreamHandler.JsonObjectHandler topObjectHandler()
           
 void writeArrayFieldStart(String fieldName)
           
 void writeBoolean(boolean state)
           
 void writeBooleanField(String fieldName, boolean value)
           
 void writeEndArray()
           
 void writeEndObject()
           
 void writeFieldName(String name)
           
 void writeNull()
           
 void writeNullField(String fieldName)
           
 void writeNumber(BigDecimal dec)
           
 void writeNumber(BigInteger v)
           
 void writeNumber(double d)
           
 void writeNumber(float f)
           
 void writeNumber(int v)
           
 void writeNumber(long v)
           
 void writeNumber(String encodedValue)
           
 void writeNumberField(String fieldName, BigDecimal value)
           
 void writeNumberField(String fieldName, double value)
           
 void writeNumberField(String fieldName, float value)
           
 void writeNumberField(String fieldName, int value)
           
 void writeNumberField(String fieldName, long value)
           
 void writeObjectFieldStart(String fieldName)
           
 void writeRaw(char c)
           
 void writeRaw(char[] text, int offset, int len)
           
 void writeRaw(String text)
           
 void writeRaw(String text, int offset, int len)
           
 void writeRawUTF8String(byte[] text, int offset, int length)
           
 void writeRawValue(char[] text, int offset, int len)
           
 void writeRawValue(String text)
           
 void writeRawValue(String text, int offset, int len)
           
 void writeStartArray()
           
 void writeStartObject()
           
 void writeString(char[] text, int offset, int len)
           
 void writeString(String text)
           
 void writeStringField(String fieldName, String value)
           
 void writeUTF8String(byte[] text, int offset, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE

public static boolean TRACE

NULL_HANDLER

public static final JsonStreamHandler.JsonNullHandler NULL_HANDLER
Constructor Detail

JsonStreamHandler

public JsonStreamHandler()
Method Detail

reset

public void reset(JsonStreamHandler.JsonEntityHandler handler)

isAcomplished

public boolean isAcomplished()

top

protected JsonStreamHandler.JsonEntityHandler top()

push

protected void push(JsonStreamHandler.JsonEntityHandler handler)

pop

protected void pop()

topListHandler

protected JsonStreamHandler.JsonListHandler topListHandler()

topObjectHandler

protected JsonStreamHandler.JsonObjectHandler topObjectHandler()

writeStartArray

public void writeStartArray()
                     throws IOException
Specified by:
writeStartArray in interface JsonStreamWriter
Throws:
IOException

writeEndArray

public void writeEndArray()
                   throws IOException
Specified by:
writeEndArray in interface JsonStreamWriter
Throws:
IOException

writeStartObject

public void writeStartObject()
                      throws IOException
Specified by:
writeStartObject in interface JsonStreamWriter
Throws:
IOException

writeEndObject

public void writeEndObject()
                    throws IOException
Specified by:
writeEndObject in interface JsonStreamWriter
Throws:
IOException

writeFieldName

public void writeFieldName(String name)
                    throws IOException
Specified by:
writeFieldName in interface JsonStreamWriter
Throws:
IOException

onValue

protected void onValue(Object val)

writeString

public void writeString(String text)
                 throws IOException
Specified by:
writeString in interface JsonStreamWriter
Throws:
IOException

writeString

public void writeString(char[] text,
                        int offset,
                        int len)
                 throws IOException
Specified by:
writeString in interface JsonStreamWriter
Throws:
IOException

writeRawUTF8String

public void writeRawUTF8String(byte[] text,
                               int offset,
                               int length)
                        throws IOException
Specified by:
writeRawUTF8String in interface JsonStreamWriter
Throws:
IOException

writeUTF8String

public void writeUTF8String(byte[] text,
                            int offset,
                            int length)
                     throws IOException
Specified by:
writeUTF8String in interface JsonStreamWriter
Throws:
IOException

writeRaw

public void writeRaw(String text)
              throws IOException
Specified by:
writeRaw in interface JsonStreamWriter
Throws:
IOException

writeRaw

public void writeRaw(String text,
                     int offset,
                     int len)
              throws IOException
Specified by:
writeRaw in interface JsonStreamWriter
Throws:
IOException

writeRaw

public void writeRaw(char[] text,
                     int offset,
                     int len)
              throws IOException
Specified by:
writeRaw in interface JsonStreamWriter
Throws:
IOException

writeRaw

public void writeRaw(char c)
              throws IOException
Specified by:
writeRaw in interface JsonStreamWriter
Throws:
IOException

writeRawValue

public void writeRawValue(String text)
                   throws IOException
Specified by:
writeRawValue in interface JsonStreamWriter
Throws:
IOException

writeRawValue

public void writeRawValue(String text,
                          int offset,
                          int len)
                   throws IOException
Specified by:
writeRawValue in interface JsonStreamWriter
Throws:
IOException

writeRawValue

public void writeRawValue(char[] text,
                          int offset,
                          int len)
                   throws IOException
Specified by:
writeRawValue in interface JsonStreamWriter
Throws:
IOException

writeNumber

public void writeNumber(int v)
                 throws IOException
Specified by:
writeNumber in interface JsonStreamWriter
Throws:
IOException

writeNumber

public void writeNumber(long v)
                 throws IOException
Specified by:
writeNumber in interface JsonStreamWriter
Throws:
IOException

writeNumber

public void writeNumber(BigInteger v)
                 throws IOException
Specified by:
writeNumber in interface JsonStreamWriter
Throws:
IOException

writeNumber

public void writeNumber(double d)
                 throws IOException
Specified by:
writeNumber in interface JsonStreamWriter
Throws:
IOException

writeNumber

public void writeNumber(float f)
                 throws IOException
Specified by:
writeNumber in interface JsonStreamWriter
Throws:
IOException

writeNumber

public void writeNumber(BigDecimal dec)
                 throws IOException
Specified by:
writeNumber in interface JsonStreamWriter
Throws:
IOException

writeNumber

public void writeNumber(String encodedValue)
                 throws IOException,
                        UnsupportedOperationException
Specified by:
writeNumber in interface JsonStreamWriter
Throws:
IOException
UnsupportedOperationException

writeBoolean

public void writeBoolean(boolean state)
                  throws IOException
Specified by:
writeBoolean in interface JsonStreamWriter
Throws:
IOException

writeNull

public void writeNull()
               throws IOException
Specified by:
writeNull in interface JsonStreamWriter
Throws:
IOException

writeStringField

public void writeStringField(String fieldName,
                             String value)
                      throws IOException
Specified by:
writeStringField in interface JsonStreamWriter
Throws:
IOException

writeBooleanField

public void writeBooleanField(String fieldName,
                              boolean value)
                       throws IOException
Specified by:
writeBooleanField in interface JsonStreamWriter
Throws:
IOException

writeNullField

public void writeNullField(String fieldName)
                    throws IOException
Specified by:
writeNullField in interface JsonStreamWriter
Throws:
IOException

writeNumberField

public void writeNumberField(String fieldName,
                             int value)
                      throws IOException
Specified by:
writeNumberField in interface JsonStreamWriter
Throws:
IOException

writeNumberField

public void writeNumberField(String fieldName,
                             long value)
                      throws IOException
Specified by:
writeNumberField in interface JsonStreamWriter
Throws:
IOException

writeNumberField

public void writeNumberField(String fieldName,
                             double value)
                      throws IOException
Specified by:
writeNumberField in interface JsonStreamWriter
Throws:
IOException

writeNumberField

public void writeNumberField(String fieldName,
                             float value)
                      throws IOException
Specified by:
writeNumberField in interface JsonStreamWriter
Throws:
IOException

writeNumberField

public void writeNumberField(String fieldName,
                             BigDecimal value)
                      throws IOException
Specified by:
writeNumberField in interface JsonStreamWriter
Throws:
IOException

writeArrayFieldStart

public void writeArrayFieldStart(String fieldName)
                          throws IOException
Specified by:
writeArrayFieldStart in interface JsonStreamWriter
Throws:
IOException

writeObjectFieldStart

public void writeObjectFieldStart(String fieldName)
                           throws IOException
Specified by:
writeObjectFieldStart in interface JsonStreamWriter
Throws:
IOException


Copyright © 2019. All Rights Reserved.