Package net.sf.json.util
Class CycleDetectionStrategy
- java.lang.Object
-
- net.sf.json.util.CycleDetectionStrategy
-
public abstract class CycleDetectionStrategy extends java.lang.Object
Base class for cycle detection in a hierarchy.
The JSON spec forbides cycles in a hierarchy and most parsers will raise and error when a cycle is detected. This class defines a contract for handling those cycles and two base implementations:- STRICT - will throw a JSONException if a cycle is found.
- LENIENT - will return an empty array or null object if a cycle is found.
- Author:
- Andres Almiray
-
-
Field Summary
Fields Modifier and Type Field Description static JSONArray
IGNORE_PROPERTY_ARR
static JSONObject
IGNORE_PROPERTY_OBJ
static CycleDetectionStrategy
LENIENT
Returns empty array and null objectstatic CycleDetectionStrategy
NOPROP
Returns a special object (IGNORE_PROPERTY_OBJ) that indicates the entire property should be ignoredstatic CycleDetectionStrategy
STRICT
Throws a JSONException
-
Constructor Summary
Constructors Constructor Description CycleDetectionStrategy()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract JSONArray
handleRepeatedReferenceAsArray(java.lang.Object reference)
Handle a repeated reference
Must return a valid JSONArray or null.abstract JSONObject
handleRepeatedReferenceAsObject(java.lang.Object reference)
Handle a repeated reference
Must return a valid JSONObject or null.
-
-
-
Field Detail
-
IGNORE_PROPERTY_ARR
public static final JSONArray IGNORE_PROPERTY_ARR
-
IGNORE_PROPERTY_OBJ
public static final JSONObject IGNORE_PROPERTY_OBJ
-
LENIENT
public static final CycleDetectionStrategy LENIENT
Returns empty array and null object
-
NOPROP
public static final CycleDetectionStrategy NOPROP
Returns a special object (IGNORE_PROPERTY_OBJ) that indicates the entire property should be ignored
-
STRICT
public static final CycleDetectionStrategy STRICT
Throws a JSONException
-
-
Method Detail
-
handleRepeatedReferenceAsArray
public abstract JSONArray handleRepeatedReferenceAsArray(java.lang.Object reference)
Handle a repeated reference
Must return a valid JSONArray or null.- Parameters:
reference
- the repeated reference.
-
handleRepeatedReferenceAsObject
public abstract JSONObject handleRepeatedReferenceAsObject(java.lang.Object reference)
Handle a repeated reference
Must return a valid JSONObject or null.- Parameters:
reference
- the repeated reference.
-
-