Package net.sf.json
Class AbstractJSON
- java.lang.Object
-
- net.sf.json.AbstractJSON
-
- All Implemented Interfaces:
java.io.Serializable,JSON
- Direct Known Subclasses:
JSONArray,JSONObject
abstract class AbstractJSON extends java.lang.Object implements JSON
Base class for JSONObject and JSONArray.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAbstractJSON.CycleSet(package private) static interfaceAbstractJSON.WritingVisitor
-
Field Summary
Fields Modifier and Type Field Description private static AbstractJSON.WritingVisitorCANONICALprivate static AbstractJSON.CycleSetcycleSetprivate static org.apache.commons.logging.Loglogprivate static AbstractJSON.WritingVisitorNORMAL
-
Constructor Summary
Constructors Constructor Description AbstractJSON()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object_processValue(java.lang.Object value, JsonConfig jsonConfig)protected static booleanaddInstance(java.lang.Object instance)Adds a reference for cycle detection check.protected static voidfireArrayEndEvent(JsonConfig jsonConfig)Fires an end of array event.protected static voidfireArrayStartEvent(JsonConfig jsonConfig)Fires a start of array event.protected static voidfireElementAddedEvent(int index, java.lang.Object element, JsonConfig jsonConfig)Fires an element added event.protected static voidfireErrorEvent(JSONException jsone, JsonConfig jsonConfig)Fires an error event.protected static voidfireObjectEndEvent(JsonConfig jsonConfig)Fires an end of object event.protected static voidfireObjectStartEvent(JsonConfig jsonConfig)Fires a start of object event.protected static voidfirePropertySetEvent(java.lang.String key, java.lang.Object value, boolean accumulated, JsonConfig jsonConfig)Fires a property set event.protected static voidfireWarnEvent(java.lang.String warning, JsonConfig jsonConfig)Fires a warning event.private static java.util.SetgetCycleSet()protected static voidremoveInstance(java.lang.Object instance)Removes a reference for cycle detection check.java.io.Writerwrite(java.io.Writer writer)Write the contents as JSON text to a writer.protected abstract voidwrite(java.io.Writer w, AbstractJSON.WritingVisitor v)java.io.WriterwriteCanonical(java.io.Writer writer)Writes the canonicalized form of this JSON object.
-
-
-
Field Detail
-
cycleSet
private static AbstractJSON.CycleSet cycleSet
-
log
private static final org.apache.commons.logging.Log log
-
NORMAL
private static final AbstractJSON.WritingVisitor NORMAL
-
CANONICAL
private static final AbstractJSON.WritingVisitor CANONICAL
-
-
Method Detail
-
addInstance
protected static boolean addInstance(java.lang.Object instance)
Adds a reference for cycle detection check.- Parameters:
instance- the reference to add- Returns:
- true if the instance has not been added previously, false otherwise.
-
fireArrayEndEvent
protected static void fireArrayEndEvent(JsonConfig jsonConfig)
Fires an end of array event.
-
fireArrayStartEvent
protected static void fireArrayStartEvent(JsonConfig jsonConfig)
Fires a start of array event.
-
fireElementAddedEvent
protected static void fireElementAddedEvent(int index, java.lang.Object element, JsonConfig jsonConfig)Fires an element added event.- Parameters:
index- the index where the element was addedelement- the added element
-
fireErrorEvent
protected static void fireErrorEvent(JSONException jsone, JsonConfig jsonConfig)
Fires an error event.- Parameters:
jsone- the thrown exception
-
fireObjectEndEvent
protected static void fireObjectEndEvent(JsonConfig jsonConfig)
Fires an end of object event.
-
fireObjectStartEvent
protected static void fireObjectStartEvent(JsonConfig jsonConfig)
Fires a start of object event.
-
firePropertySetEvent
protected static void firePropertySetEvent(java.lang.String key, java.lang.Object value, boolean accumulated, JsonConfig jsonConfig)Fires a property set event.- Parameters:
key- the name of the propertyvalue- the value of the propertyaccumulated- if the value has been accumulated over 'key'
-
fireWarnEvent
protected static void fireWarnEvent(java.lang.String warning, JsonConfig jsonConfig)Fires a warning event.- Parameters:
warning- the warning message
-
removeInstance
protected static void removeInstance(java.lang.Object instance)
Removes a reference for cycle detection check.
-
_processValue
protected java.lang.Object _processValue(java.lang.Object value, JsonConfig jsonConfig)
-
getCycleSet
private static java.util.Set getCycleSet()
-
write
public final java.io.Writer write(java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:JSONWrite the contents as JSON text to a writer. For compactness, no whitespace is added. Warning: This method assumes that the data structure is acyclical.
-
writeCanonical
public final java.io.Writer writeCanonical(java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:JSONWrites the canonicalized form of this JSON object.- Specified by:
writeCanonicalin interfaceJSON- Throws:
java.io.IOException
-
write
protected abstract void write(java.io.Writer w, AbstractJSON.WritingVisitor v) throws java.io.IOException- Throws:
java.io.IOException
-
-