net.minidev.json
Class JSONStyler

java.lang.Object
  extended by net.minidev.json.JSONStyle
      extended by net.minidev.json.JSONStyler
All Implemented Interfaces:
ContentHandler

public class JSONStyler
extends JSONStyle
implements ContentHandler

This class is used to format JSon output, fot a better humain readability

Author:
Uriel Chemouni

Field Summary
 
Fields inherited from class net.minidev.json.JSONStyle
FLAG_AGRESSIVE, FLAG_PROTECT_4WEB, FLAG_PROTECT_KEYS, FLAG_PROTECT_VALUES, LT_COMPRESS, MAX_COMPRESS, NO_COMPRESS
 
Constructor Summary
JSONStyler()
           
JSONStyler(int FLAG)
           
JSONStyler(int FLAG, int nbLevel)
           
 
Method Summary
 boolean endArray()
          Receive notification of the end of a JSON array.
 void endJSON()
          Receive notification of the end of JSON processing.
 boolean endObject()
          Receive notification of the end of a JSON object.
 boolean endObjectEntry()
          Receive notification of the end of the value of previous object entry.
 String getNewLine()
           
 JSONStyler getStyler()
           
 boolean indent()
           
 boolean primitive(Object value)
          Receive notification of the JSON primitive values: java.lang.String, java.lang.Number, java.lang.Boolean null
 void setIdentLevel(int nbLevel)
           
 void setOutput(Appendable out)
           
 boolean startArray()
          Receive notification of the beginning of a JSON array.
 void startJSON()
          Receive notification of the beginning of JSON processing.
 boolean startObject()
          Receive notification of the beginning of a JSON object.
 boolean startObjectEntry(String key)
          Receive notification of the beginning of a JSON object entry.
 
Methods inherited from class net.minidev.json.JSONStyle
escape, mustProtectKey, mustProtectValue, protect4Web, protectKeys, protectValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONStyler

public JSONStyler(int FLAG)

JSONStyler

public JSONStyler(int FLAG,
                  int nbLevel)

JSONStyler

public JSONStyler()
Method Detail

setOutput

public void setOutput(Appendable out)

setIdentLevel

public void setIdentLevel(int nbLevel)

indent

public boolean indent()
Overrides:
indent in class JSONStyle

getNewLine

public String getNewLine()

getStyler

public JSONStyler getStyler()

startJSON

public void startJSON()
               throws ParseException
Description copied from interface: ContentHandler
Receive notification of the beginning of JSON processing. The parser will invoke this method only once.

Specified by:
startJSON in interface ContentHandler
Throws:
ParseException - - JSONParser will stop and throw the same exception to the caller when receiving this exception.

endJSON

public void endJSON()
             throws ParseException
Description copied from interface: ContentHandler
Receive notification of the end of JSON processing.

Specified by:
endJSON in interface ContentHandler
Throws:
ParseException

startObject

public boolean startObject()
                    throws ParseException
Description copied from interface: ContentHandler
Receive notification of the beginning of a JSON object.

Specified by:
startObject in interface ContentHandler
Returns:
false if the handler wants to stop parsing after return.
Throws:
ParseException - - JSONParser will stop and throw the same exception to the caller when receiving this exception.
See Also:
ContentHandler.endJSON()

endObject

public boolean endObject()
                  throws ParseException
Description copied from interface: ContentHandler
Receive notification of the end of a JSON object.

Specified by:
endObject in interface ContentHandler
Returns:
false if the handler wants to stop parsing after return.
Throws:
ParseException
See Also:
ContentHandler.startObject()

startObjectEntry

public boolean startObjectEntry(String key)
                         throws ParseException
Description copied from interface: ContentHandler
Receive notification of the beginning of a JSON object entry.

Specified by:
startObjectEntry in interface ContentHandler
Parameters:
key - - Key of a JSON object entry.
Returns:
false if the handler wants to stop parsing after return.
Throws:
ParseException
See Also:
ContentHandler.endObjectEntry()

endObjectEntry

public boolean endObjectEntry()
                       throws ParseException
Description copied from interface: ContentHandler
Receive notification of the end of the value of previous object entry.

Specified by:
endObjectEntry in interface ContentHandler
Returns:
false if the handler wants to stop parsing after return.
Throws:
ParseException
See Also:
ContentHandler.startObjectEntry(java.lang.String)

startArray

public boolean startArray()
                   throws ParseException
Description copied from interface: ContentHandler
Receive notification of the beginning of a JSON array.

Specified by:
startArray in interface ContentHandler
Returns:
false if the handler wants to stop parsing after return.
Throws:
ParseException
See Also:
ContentHandler.endArray()

endArray

public boolean endArray()
                 throws ParseException
Description copied from interface: ContentHandler
Receive notification of the end of a JSON array.

Specified by:
endArray in interface ContentHandler
Returns:
false if the handler wants to stop parsing after return.
Throws:
ParseException
See Also:
ContentHandler.startArray()

primitive

public boolean primitive(Object value)
                  throws ParseException
Description copied from interface: ContentHandler
Receive notification of the JSON primitive values: java.lang.String, java.lang.Number, java.lang.Boolean null

Specified by:
primitive in interface ContentHandler
Parameters:
value - - Instance of the following: java.lang.String, java.lang.Number, java.lang.Boolean null
Returns:
false if the handler wants to stop parsing after return.
Throws:
ParseException


Copyright © 2012 Chemouni Uriel. All Rights Reserved.