Package org.kordamp.json
Class AbstractJSON
java.lang.Object
org.kordamp.json.AbstractJSON
- All Implemented Interfaces:
Serializable
,JSON
- Direct Known Subclasses:
JSONArray
,JSONObject
Base class for JSONObject and JSONArray.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
(package private) static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AbstractJSON.WritingVisitor
private static AbstractJSON.CycleSet
private static final org.slf4j.Logger
private static final AbstractJSON.WritingVisitor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
_processValue
(Object value, JsonConfig jsonConfig) protected static boolean
addInstance
(Object instance) Adds a reference for cycle detection check.protected static void
fireArrayEndEvent
(JsonConfig jsonConfig) Fires an end of array event.protected static void
fireArrayStartEvent
(JsonConfig jsonConfig) Fires a start of array event.protected static void
fireElementAddedEvent
(int index, Object element, JsonConfig jsonConfig) Fires an element added event.protected static void
fireErrorEvent
(JSONException jsone, JsonConfig jsonConfig) Fires an error event.protected static void
fireObjectEndEvent
(JsonConfig jsonConfig) Fires an end of object event.protected static void
fireObjectStartEvent
(JsonConfig jsonConfig) Fires a start of object event.protected static void
firePropertySetEvent
(String key, Object value, boolean accumulated, JsonConfig jsonConfig) Fires a property set event.protected static void
fireWarnEvent
(String warning, JsonConfig jsonConfig) Fires a warning event.private static Set
protected static void
removeInstance
(Object instance) Removes a reference for cycle detection check.final Writer
Write the contents as JSON text to a writer.protected abstract void
final Writer
writeCanonical
(Writer writer) Writes the canonicalized form of this JSON object.
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
NORMAL
-
CANONICAL
-
cycleSet
-
-
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. -
getCycleSet
-
_processValue
-
write
Description copied from interface:JSON
Write 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:
write
in interfaceJSON
- Returns:
- The writer.
- Throws:
IOException
-
writeCanonical
Description copied from interface:JSON
Writes the canonicalized form of this JSON object.- Specified by:
writeCanonical
in interfaceJSON
- Throws:
IOException
-
write
- Throws:
IOException
-