Package net.sf.json.util
Class CycleDetectionStrategy
java.lang.Object
net.sf.json.util.CycleDetectionStrategy
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:
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 aalmiray@users.sourceforge.net
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JSONArraystatic final JSONObjectstatic final CycleDetectionStrategyReturns empty array and null objectstatic final CycleDetectionStrategyReturns a special object (IGNORE_PROPERTY_OBJ) that indicates the entire property should be ignoredstatic final CycleDetectionStrategyThrows a JSONException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract JSONArrayhandleRepeatedReferenceAsArray(Object reference) Handle a repeated reference
Must return a valid JSONArray or null.abstract JSONObjecthandleRepeatedReferenceAsObject(Object reference) Handle a repeated reference
Must return a valid JSONObject or null.
-
Field Details
-
IGNORE_PROPERTY_ARR
-
IGNORE_PROPERTY_OBJ
-
LENIENT
Returns empty array and null object -
NOPROP
Returns a special object (IGNORE_PROPERTY_OBJ) that indicates the entire property should be ignored -
STRICT
Throws a JSONException
-
-
Constructor Details
-
CycleDetectionStrategy
public CycleDetectionStrategy()
-
-
Method Details
-
handleRepeatedReferenceAsArray
Handle a repeated reference
Must return a valid JSONArray or null.- Parameters:
reference- the repeated reference.
-
handleRepeatedReferenceAsObject
Handle a repeated reference
Must return a valid JSONObject or null.- Parameters:
reference- the repeated reference.
-