Class AbstractJSON
java.lang.Object
net.sf.json.AbstractJSON
- All Implemented Interfaces:
Serializable, JSON
- Direct Known Subclasses:
JSONArray, JSONObject
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class(package private) static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AbstractJSON.WritingVisitorprivate static AbstractJSON.CycleSetprivate static final org.apache.commons.logging.Logprivate static final AbstractJSON.WritingVisitor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object_processValue(Object value, JsonConfig jsonConfig) protected static booleanaddInstance(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, 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(String key, Object value, boolean accumulated, JsonConfig jsonConfig) Fires a property set event.protected static voidfireWarnEvent(String warning, JsonConfig jsonConfig) Fires a warning event.private static Setprotected static voidremoveInstance(Object instance) Removes a reference for cycle detection check.final WriterWrite the contents as JSON text to a writer.protected abstract voidfinal WriterwriteCanonical(Writer writer) Writes the canonicalized form of this JSON object.
-
Field Details
-
cycleSet
-
log
private static final org.apache.commons.logging.Log log -
NORMAL
-
CANONICAL
-
-
Constructor Details
-
AbstractJSON
AbstractJSON()
-
-
Method Details
-
addInstance
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
Fires an end of array event. -
fireArrayStartEvent
Fires a start of array event. -
fireElementAddedEvent
Fires an element added event.- Parameters:
index- the index where the element was addedelement- the added element
-
fireErrorEvent
Fires an error event.- Parameters:
jsone- the thrown exception
-
fireObjectEndEvent
Fires an end of object event. -
fireObjectStartEvent
Fires a start of object event. -
firePropertySetEvent
protected static void firePropertySetEvent(String key, 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
Fires a warning event.- Parameters:
warning- the warning message
-
removeInstance
Removes a reference for cycle detection check. -
_processValue
-
getCycleSet
-
write
Description 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.- Specified by:
writein interfaceJSON- Returns:
- The writer.
- Throws:
IOException
-
writeCanonical
Description copied from interface:JSONWrites the canonicalized form of this JSON object.- Specified by:
writeCanonicalin interfaceJSON- Throws:
IOException
-
write
- Throws:
IOException
-