Package org.kordamp.json.util
Class CycleDetectionStrategy
java.lang.Object
org.kordamp.json.util.CycleDetectionStrategy
- Direct Known Subclasses:
CycleDetectionStrategy.LenientCycleDetectionStrategy
,CycleDetectionStrategy.LenientNoRefCycleDetectionStrategy
,CycleDetectionStrategy.StrictCycleDetectionStrategy
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
A cycle detection strategy that prevents any mention of the possible conflict from appearing.private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JSONArray
static final JSONObject
static final CycleDetectionStrategy
Returns empty array and null objectstatic final CycleDetectionStrategy
Returns a special object (IGNORE_PROPERTY_OBJ) that indicates the entire property should be ignoredstatic final CycleDetectionStrategy
Throws a JSONException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract JSONArray
handleRepeatedReferenceAsArray
(Object reference) Handle a repeated reference
Must return a valid JSONArray or null.abstract JSONObject
handleRepeatedReferenceAsObject
(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.
-