Package net.sf.json
Class JsonConfig
- java.lang.Object
-
- net.sf.json.JsonConfig
-
public class JsonConfig extends java.lang.Object
Utility class that helps configuring the serialization process.- Author:
- Andres Almiray
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultValueProcessorMatcher
DEFAULT_DEFAULT_VALUE_PROCESSOR_MATCHER
static JsonBeanProcessorMatcher
DEFAULT_JSON_BEAN_PROCESSOR_MATCHER
static JsonValueProcessorMatcher
DEFAULT_JSON_VALUE_PROCESSOR_MATCHER
static NewBeanInstanceStrategy
DEFAULT_NEW_BEAN_INSTANCE_STRATEGY
static PropertyExclusionClassMatcher
DEFAULT_PROPERTY_EXCLUSION_CLASS_MATCHER
static PropertyNameProcessorMatcher
DEFAULT_PROPERTY_NAME_PROCESSOR_MATCHER
static int
MODE_LIST
static int
MODE_OBJECT_ARRAY
static int
MODE_SET
-
Constructor Summary
Constructors Constructor Description JsonConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addIgnoreFieldAnnotation(java.lang.Class annotationClass)
Removes an annotation that marks a field to be skipped when building.
[Java -> JSON]void
addIgnoreFieldAnnotation(java.lang.String annotationClassName)
Adds an annotation that marks a field to be skipped when building.
[Java -> JSON]void
addJsonEventListener(JsonEventListener listener)
Registers a listener for JSON events.
The events will be triggered only when using the static builders and if event triggering is enabled.
[Java -> JSON]void
clearJavaPropertyNameProcessors()
Removes all registered PropertyNameProcessors.
[JSON -> Java]void
clearJsonBeanProcessors()
Removes all registered JsonBeanProcessors.
[Java -> JSON]void
clearJsonEventListeners()
Removes all registered listener for JSON Events.
[Java -> JSON]void
clearJsonPropertyNameProcessors()
Removes all registered PropertyNameProcessors.
[Java -> JSON]void
clearJsonValueProcessors()
Removes all registered JsonValueProcessors.
[Java -> JSON]void
clearPropertyExclusions()
Removes all property exclusions registered per class.
[Java -> JSON]void
clearPropertyNameProcessors()
Deprecated.use clearJavaPropertyNameProcessors() insteadJsonConfig
copy()
void
disableEventTriggering()
Disables event triggering when building.
[Java -> JSON]void
enableEventTriggering()
Enables event triggering when building.
[Java -> JSON]DefaultValueProcessor
findDefaultValueProcessor(java.lang.Class target)
Finds a DefaultValueProcessor registered to the target class.
Returns null if none is registered.
[Java -> JSON]PropertyNameProcessor
findJavaPropertyNameProcessor(java.lang.Class beanClass)
Finds a PropertyNameProcessor registered to the target class.
Returns null if none is registered.
[JSON -> Java]JsonBeanProcessor
findJsonBeanProcessor(java.lang.Class target)
Finds a JsonBeanProcessor registered to the target class.
Returns null if none is registered.
[Java -> JSON]PropertyNameProcessor
findJsonPropertyNameProcessor(java.lang.Class beanClass)
Finds a PropertyNameProcessor registered to the target class.
Returns null if none is registered.
[Java -> JSON]JsonValueProcessor
findJsonValueProcessor(java.lang.Class propertyType)
Finds a JsonValueProcessor registered to the target type.
Returns null if none is registered.
[Java -> JSON]JsonValueProcessor
findJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType, java.lang.String key)
Finds a JsonValueProcessor.
It will search the registered JsonValueProcessors in the following order: beanClass, key beanClass, type key type Returns null if none is registered.
[Java -> JSON]JsonValueProcessor
findJsonValueProcessor(java.lang.Class propertyType, java.lang.String key)
Finds a JsonValueProcessor.
It will search the registered JsonValueProcessors in the following order: key type Returns null if none is registered.
[Java -> JSON]PropertyNameProcessor
findPropertyNameProcessor(java.lang.Class beanClass)
Deprecated.use findJavaPropertyNameProcessor() insteadint
getArrayMode()
Returns the current array mode conversion.
[JSON -> Java]java.util.Map
getClassMap()
Returns the current attribute/class Map.
[JSON -> Java]java.lang.Class
getCollectionType()
Returns the current collection type used for collection transformations.
[JSON -> Java]CycleDetectionStrategy
getCycleDetectionStrategy()
Returns the configured CycleDetectionStrategy.
Default value is CycleDetectionStrategy.STRICT
[Java -> JSON]DefaultValueProcessorMatcher
getDefaultValueProcessorMatcher()
Returns the configured DefaultValueProcessorMatcher.
Default value is DefaultValueProcessorMatcher.DEFAULT
[Java -> JSON]java.lang.Class
getEnclosedType()
Returns the current enclosed type for generic collection transformations.
[JSON -> Java]java.lang.String[]
getExcludes()
Returns the configured properties for exclusion.java.util.List
getIgnoreFieldAnnotations()
Returns a List of all annotations that mark a field to be skipped when building.
[Java -> JSON]JavaIdentifierTransformer
getJavaIdentifierTransformer()
Returns the configured JavaIdentifierTransformer.PropertyFilter
getJavaPropertyFilter()
Returns the configured property filter when serializing to Java.
[JSON -> Java]PropertyNameProcessorMatcher
getJavaPropertyNameProcessorMatcher()
Returns the configured PropertyNameProcessorMatcher.
Default value is PropertyNameProcessorMatcher.DEFAULT
[JSON -> Java]JsonBeanProcessorMatcher
getJsonBeanProcessorMatcher()
Returns the configured JsonBeanProcessorMatcher.
Default value is JsonBeanProcessorMatcher.DEFAULT
[JSON -> Java]java.util.List
getJsonEventListeners()
Returns a list of registered listeners for JSON events.
[JSON -> Java]PropertyFilter
getJsonPropertyFilter()
Returns the configured property filter when serializing to JSON.
[Java -> JSON]PropertyNameProcessorMatcher
getJsonPropertyNameProcessorMatcher()
Returns the configured PropertyNameProcessorMatcher.
Default value is PropertyNameProcessorMatcher.DEFAULT
[Java -> JSON]JsonValueProcessorMatcher
getJsonValueProcessorMatcher()
Returns the configured JsonValueProcessorMatcher.
Default value is JsonValueProcessorMatcher.DEFAULT
[Java -> JSON]java.util.Collection
getMergedExcludes()
Returns a set of default excludes with user-defined excludes.
[Java -> JSON]java.util.Collection
getMergedExcludes(java.lang.Class target)
Returns a set of default excludes with user-defined excludes.
Takes into account any additional excludes per matching class.NewBeanInstanceStrategy
getNewBeanInstanceStrategy()
Returns the configured NewBeanInstanceStrategy.
Default value is NewBeanInstanceStrategy.DEFAULT
[JSON -> Java]PropertyExclusionClassMatcher
getPropertyExclusionClassMatcher()
Returns the configured PropertyExclusionClassMatcher.
Default value is PropertyExclusionClassMatcher.DEFAULT
[JSON -> Java]PropertyNameProcessorMatcher
getPropertyNameProcessorMatcher()
Deprecated.use getJavaPropertyNameProcessorMatcher() insteadPropertySetStrategy
getPropertySetStrategy()
Returns the configured PropertySetStrategy.
Default value is PropertySetStrategy.DEFAULT
[JSON -> Java]java.lang.Class
getRootClass()
Returns the current root Class.
[JSON -> Java]boolean
isAllowNonStringKeys()
Returns true if non-String keys are allowed on JSONObject.
Default value is false
[Java -> JSON]boolean
isEventTriggeringEnabled()
Returns true if event triggering is enabled during building.
Default value is false
[Java -> JSON]boolean
isHandleJettisonEmptyElement()
Returns true if this Jettison convention will be handled when converting to Java.
Jettison assumes that "" (empty string) can be assigned to empty elements (objects), which clearly violates the JSON spec.
[JSON -> Java]boolean
isHandleJettisonSingleElementArray()
Returns true if this jettison convention will be handled when converting to Java.
Jettison states the following JSON {'media':{'title':'hello'}} can be set as a single element JSONArray (media is the array).
[JSON -> Java]boolean
isIgnoreDefaultExcludes()
Returns true if default excludes will not be used.
Default value is false.
[Java -> JSON]boolean
isIgnoreJPATransient()
Returns true if JPA Transient annotated methods should be ignored.
Default value is false.
[Java -> JSON]boolean
isIgnorePublicFields()
Returns true if public fields of a bean will be ignored.
Default value is true.
[Java -> JSON]boolean
isIgnoreTransientFields()
Returns true if transient fields of a bean will be ignored.
Default value is false.
[Java -> JSON]boolean
isIgnoreUnreadableProperty()
boolean
isJavascriptCompliant()
Returns true if Javascript compatibility is turned on.
Default value is false.
[Java -> JSON]boolean
isSkipJavaIdentifierTransformationInMapKeys()
Returns true if map keys will not be transformed.
Default value is false.
[JSON -> Java]void
registerDefaultValueProcessor(java.lang.Class target, DefaultValueProcessor defaultValueProcessor)
Registers a DefaultValueProcessor.
[Java -> JSON]void
registerJavaPropertyNameProcessor(java.lang.Class target, PropertyNameProcessor propertyNameProcessor)
Registers a PropertyNameProcessor.
[JSON -> Java]void
registerJsonBeanProcessor(java.lang.Class target, JsonBeanProcessor jsonBeanProcessor)
Registers a JsonBeanProcessor.
[Java -> JSON]void
registerJsonPropertyNameProcessor(java.lang.Class target, PropertyNameProcessor propertyNameProcessor)
Registers a PropertyNameProcessor.
[Java -> JSON]void
registerJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType, JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
[Java -> JSON]void
registerJsonValueProcessor(java.lang.Class beanClass, java.lang.String key, JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
[Java -> JSON]void
registerJsonValueProcessor(java.lang.Class propertyType, JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
[Java -> JSON]void
registerJsonValueProcessor(java.lang.String key, JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
[Java -> JSON]void
registerPropertyExclusion(java.lang.Class target, java.lang.String propertyName)
Registers a exclusion for a target class.
[Java -> JSON]void
registerPropertyExclusions(java.lang.Class target, java.lang.String[] properties)
Registers exclusions for a target class.
[Java -> JSON]void
registerPropertyNameProcessor(java.lang.Class target, PropertyNameProcessor propertyNameProcessor)
Deprecated.use registerJavaPropertyNameProcessor() insteadvoid
removeIgnoreFieldAnnotation(java.lang.Class annotationClass)
Removes an annotation that marks a field to be skipped when building.
[Java -> JSON]void
removeIgnoreFieldAnnotation(java.lang.String annotationClassName)
Adds an annotation that marks a field to be skipped when building.
[Java -> JSON]void
removeJsonEventListener(JsonEventListener listener)
Removes a listener for JSON events.
[Java -> JSON]void
reset()
Resets all values to its default state.void
setAllowNonStringKeys(boolean allowNonStringKeys)
Sets if non-String keys are allowed on JSONObject.
[Java -> JSON]void
setArrayMode(int arrayMode)
Sets the current array mode for conversion.
If the value is not MODE_LIST, MODE_OBJECT_ARRAY nor MODE_SET, then MODE_LIST will be used.
[JSON -> Java]void
setClassMap(java.util.Map classMap)
Sets the current attribute/Class Map
[JSON -> Java]void
setCollectionType(java.lang.Class collectionType)
Sets the current collection type used for collection transformations.
[JSON -> Java]void
setCycleDetectionStrategy(CycleDetectionStrategy cycleDetectionStrategy)
Sets a CycleDetectionStrategy to use.
Will set default value (CycleDetectionStrategy.STRICT) if null.
[Java -> JSON]void
setDefaultValueProcessorMatcher(DefaultValueProcessorMatcher defaultValueProcessorMatcher)
Sets a DefaultValueProcessorMatcher to use.
Will set default value (DefaultValueProcessorMatcher.DEFAULT) if null.
[Java -> JSON]void
setEnclosedType(java.lang.Class enclosedType)
Sets the current enclosed type for generic collection transformations.
[JSON -> Java]void
setExcludes(java.lang.String[] excludes)
Sets the excludes to use.
Will set default value ([]) if null.
[Java -> JSON]void
setHandleJettisonEmptyElement(boolean handleJettisonEmptyElement)
Activate/Deactivate handling this jettison convention when converting to Java.
Jettison states that "" (empty string) can be assigned to empty elements (objects), which clearly violates the JSON spec.
[JSON -> Java]void
setHandleJettisonSingleElementArray(boolean handleJettisonSingleElementArray)
Activate/Deactivate handling this jettison convention when converting to Java.
* Jettison states the following JSON {'media':{'title':'hello'}} can be set as a single element JSONArray (media is the array).
[JSON -> Java]void
setIgnoreDefaultExcludes(boolean ignoreDefaultExcludes)
Sets if default excludes would be skipped when building.
[Java -> JSON]void
setIgnoreJPATransient(boolean ignoreJPATransient)
Sets if JPA Transient annotated methods would be skipped when building.
[Java -> JSON]void
setIgnorePublicFields(boolean ignorePublicFields)
Sets if public fields would be skipped when building.
[Java -> JSON]void
setIgnoreTransientFields(boolean ignoreTransientFields)
Sets if transient fields would be skipped when building.
[Java -> JSON]void
setIgnoreUnreadableProperty(boolean ignoreUnreadableProperty)
If true, properties found in JSON that have no corresponding Java setter/field/etc will not raise an exception.void
setJavaIdentifierTransformer(JavaIdentifierTransformer javaIdentifierTransformer)
Sets the JavaIdentifierTransformer to use.
Will set default value (JavaIdentifierTransformer.NOOP) if null.
[JSON -> Java]void
setJavaPropertyFilter(PropertyFilter javaPropertyFilter)
Sets a property filter used when serializing to Java.
[JSON -> Java]void
setJavaPropertyNameProcessorMatcher(PropertyNameProcessorMatcher propertyNameProcessorMatcher)
Sets a PropertyNameProcessorMatcher to use.
Will set default value (PropertyNameProcessorMatcher.DEFAULT) if null.
[JSON -> Java]void
setJavascriptCompliant(boolean javascriptCompliant)
Sets if Javascript compatibility is enabled when building.
[Java -> JSON]void
setJsonBeanProcessorMatcher(JsonBeanProcessorMatcher jsonBeanProcessorMatcher)
Sets a JsonBeanProcessorMatcher to use.
Will set default value (JsonBeanProcessorMatcher.DEFAULT) if null.
[Java -> JSON]void
setJsonPropertyFilter(PropertyFilter jsonPropertyFilter)
Sets a property filter used when serializing to JSON.
[Java -> JSON]void
setJsonPropertyNameProcessorMatcher(PropertyNameProcessorMatcher propertyNameProcessorMatcher)
Sets a PropertyNameProcessorMatcher to use.
Will set default value (PropertyNameProcessorMatcher.DEFAULT) if null.
[Java -> JSON]void
setJsonValueProcessorMatcher(JsonValueProcessorMatcher jsonValueProcessorMatcher)
Sets a JsonValueProcessorMatcher to use.
Will set default value (JsonValueProcessorMatcher.DEFAULT) if null.
[Java -> JSON]void
setNewBeanInstanceStrategy(NewBeanInstanceStrategy newBeanInstanceStrategy)
Sets the NewBeanInstanceStrategy to use.
Will set default value (NewBeanInstanceStrategy.DEFAULT) if null.
[JSON -> Java]void
setPropertyExclusionClassMatcher(PropertyExclusionClassMatcher propertyExclusionClassMatcher)
Sets a PropertyExclusionClassMatcher to use.
Will set default value (PropertyExclusionClassMatcher.DEFAULT) if null.
[Java -> JSON]void
setPropertyNameProcessorMatcher(PropertyNameProcessorMatcher propertyNameProcessorMatcher)
Deprecated.use setJavaPropertyNameProcessorMatcher() insteadvoid
setPropertySetStrategy(PropertySetStrategy propertySetStrategy)
Sets a PropertySetStrategy to use.
Will set default value (PropertySetStrategy.DEFAULT) if null.
[JSON -> Java]void
setRootClass(java.lang.Class rootClass)
Sets the current root Class.
[JSON -> Java]void
setSkipJavaIdentifierTransformationInMapKeys(boolean skipJavaIdentifierTransformationInMapKeys)
Sets if property name as JavaIndetifier transformations would be skipped.
[JSON -> Java]void
unregisterDefaultValueProcessor(java.lang.Class target)
Removes a DefaultValueProcessor.
[Java -> JSON]void
unregisterJavaPropertyNameProcessor(java.lang.Class target)
Removes a PropertyNameProcessor.
[JSON -> Java]void
unregisterJsonBeanProcessor(java.lang.Class target)
Removes a JsonBeanProcessor.
[Java -> JSON]void
unregisterJsonPropertyNameProcessor(java.lang.Class target)
Removes a PropertyNameProcessor.
[Java -> JSON]void
unregisterJsonValueProcessor(java.lang.Class propertyType)
Removes a JsonValueProcessor.
[Java -> JSON]void
unregisterJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType)
Removes a JsonValueProcessor.
[Java -> JSON]void
unregisterJsonValueProcessor(java.lang.Class beanClass, java.lang.String key)
Removes a JsonValueProcessor.
[Java -> JSON]void
unregisterJsonValueProcessor(java.lang.String key)
Removes a JsonValueProcessor.
[Java -> JSON]void
unregisterPropertyExclusion(java.lang.Class target, java.lang.String propertyName)
Removes a property exclusion assigned to the target class.
[Java -> JSON]void
unregisterPropertyExclusions(java.lang.Class target)
Removes all property exclusions assigned to the target class.
[Java -> JSON]void
unregisterPropertyNameProcessor(java.lang.Class target)
Deprecated.use unregisterJavaPropertyNameProcessor() instead
-
-
-
Field Detail
-
DEFAULT_DEFAULT_VALUE_PROCESSOR_MATCHER
public static final DefaultValueProcessorMatcher DEFAULT_DEFAULT_VALUE_PROCESSOR_MATCHER
-
DEFAULT_JSON_BEAN_PROCESSOR_MATCHER
public static final JsonBeanProcessorMatcher DEFAULT_JSON_BEAN_PROCESSOR_MATCHER
-
DEFAULT_JSON_VALUE_PROCESSOR_MATCHER
public static final JsonValueProcessorMatcher DEFAULT_JSON_VALUE_PROCESSOR_MATCHER
-
DEFAULT_NEW_BEAN_INSTANCE_STRATEGY
public static final NewBeanInstanceStrategy DEFAULT_NEW_BEAN_INSTANCE_STRATEGY
-
DEFAULT_PROPERTY_EXCLUSION_CLASS_MATCHER
public static final PropertyExclusionClassMatcher DEFAULT_PROPERTY_EXCLUSION_CLASS_MATCHER
-
DEFAULT_PROPERTY_NAME_PROCESSOR_MATCHER
public static final PropertyNameProcessorMatcher DEFAULT_PROPERTY_NAME_PROCESSOR_MATCHER
-
MODE_LIST
public static final int MODE_LIST
- See Also:
- Constant Field Values
-
MODE_OBJECT_ARRAY
public static final int MODE_OBJECT_ARRAY
- See Also:
- Constant Field Values
-
MODE_SET
public static final int MODE_SET
- See Also:
- Constant Field Values
-
-
Method Detail
-
addJsonEventListener
public void addJsonEventListener(JsonEventListener listener)
Registers a listener for JSON events.
The events will be triggered only when using the static builders and if event triggering is enabled.
[Java -> JSON]- Parameters:
listener
- a listener for events- See Also:
enableEventTriggering()
,disableEventTriggering()
,removeJsonEventListener(JsonEventListener)
-
clearJavaPropertyNameProcessors
public void clearJavaPropertyNameProcessors()
Removes all registered PropertyNameProcessors.
[JSON -> Java]
-
clearJsonBeanProcessors
public void clearJsonBeanProcessors()
Removes all registered JsonBeanProcessors.
[Java -> JSON]
-
clearJsonEventListeners
public void clearJsonEventListeners()
Removes all registered listener for JSON Events.
[Java -> JSON]
-
clearJsonPropertyNameProcessors
public void clearJsonPropertyNameProcessors()
Removes all registered PropertyNameProcessors.
[Java -> JSON]
-
clearJsonValueProcessors
public void clearJsonValueProcessors()
Removes all registered JsonValueProcessors.
[Java -> JSON]
-
clearPropertyExclusions
public void clearPropertyExclusions()
Removes all property exclusions registered per class.
[Java -> JSON]
-
clearPropertyNameProcessors
public void clearPropertyNameProcessors()
Deprecated.use clearJavaPropertyNameProcessors() insteadRemoves all registered PropertyNameProcessors.
[JSON -> Java]
-
copy
public JsonConfig copy()
-
disableEventTriggering
public void disableEventTriggering()
Disables event triggering when building.
[Java -> JSON]
-
enableEventTriggering
public void enableEventTriggering()
Enables event triggering when building.
[Java -> JSON]
-
isIgnoreUnreadableProperty
public boolean isIgnoreUnreadableProperty()
-
setIgnoreUnreadableProperty
public void setIgnoreUnreadableProperty(boolean ignoreUnreadableProperty)
If true, properties found in JSON that have no corresponding Java setter/field/etc will not raise an exception.For example, given {"x":1, "y":2, "z":3} on the following Point class,
JSONObject.toBean()
would fail unless this flag is set to true, because propety "x" in JSON has no corresponding Java counerpart.class Point { private int x,y; public int getX() { return x; } public int getY() { return y; } public void setX(int v) { x=v; } public void setY(int v) { y=v; } }
[JSON -> Java]
-
findDefaultValueProcessor
public DefaultValueProcessor findDefaultValueProcessor(java.lang.Class target)
Finds a DefaultValueProcessor registered to the target class.
Returns null if none is registered.
[Java -> JSON]- Parameters:
target
- a class used for searching a DefaultValueProcessor.
-
findJavaPropertyNameProcessor
public PropertyNameProcessor findJavaPropertyNameProcessor(java.lang.Class beanClass)
Finds a PropertyNameProcessor registered to the target class.
Returns null if none is registered.
[JSON -> Java]- Parameters:
propertyType
- a class used for searching a PropertyNameProcessor.
-
findJsonBeanProcessor
public JsonBeanProcessor findJsonBeanProcessor(java.lang.Class target)
Finds a JsonBeanProcessor registered to the target class.
Returns null if none is registered.
[Java -> JSON]- Parameters:
target
- a class used for searching a JsonBeanProcessor.
-
findJsonPropertyNameProcessor
public PropertyNameProcessor findJsonPropertyNameProcessor(java.lang.Class beanClass)
Finds a PropertyNameProcessor registered to the target class.
Returns null if none is registered.
[Java -> JSON]- Parameters:
propertyType
- a class used for searching a PropertyNameProcessor.
-
findJsonValueProcessor
public JsonValueProcessor findJsonValueProcessor(java.lang.Class propertyType)
Finds a JsonValueProcessor registered to the target type.
Returns null if none is registered.
[Java -> JSON]- Parameters:
propertyType
- a class used for searching a JsonValueProcessor.
-
findJsonValueProcessor
public JsonValueProcessor findJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType, java.lang.String key)
Finds a JsonValueProcessor.
It will search the registered JsonValueProcessors in the following order:- beanClass, key
- beanClass, type
- key
- type
[Java -> JSON]- Parameters:
beanClass
- the class to which the property may belongpropertyType
- the type of the propertykey
- the name of the property which may belong to the target class
-
findJsonValueProcessor
public JsonValueProcessor findJsonValueProcessor(java.lang.Class propertyType, java.lang.String key)
Finds a JsonValueProcessor.
It will search the registered JsonValueProcessors in the following order:- key
- type
[Java -> JSON]- Parameters:
propertyType
- the type of the propertykey
- the name of the property which may belong to the target class
-
findPropertyNameProcessor
public PropertyNameProcessor findPropertyNameProcessor(java.lang.Class beanClass)
Deprecated.use findJavaPropertyNameProcessor() insteadFinds a PropertyNameProcessor registered to the target class.
Returns null if none is registered.
[JSON -> Java]- Parameters:
propertyType
- a class used for searching a PropertyNameProcessor.
-
getArrayMode
public int getArrayMode()
Returns the current array mode conversion.
[JSON -> Java]- Returns:
- MODE_OBJECT_ARRAY, MODE_LIST or MODE_SET
-
getClassMap
public java.util.Map getClassMap()
Returns the current attribute/class Map.
[JSON -> Java]- Returns:
- a Map of classes, every key identifies a property or a regexp
-
getCollectionType
public java.lang.Class getCollectionType()
Returns the current collection type used for collection transformations.
[JSON -> Java]- Returns:
- the target collection class for conversion
-
getCycleDetectionStrategy
public CycleDetectionStrategy getCycleDetectionStrategy()
Returns the configured CycleDetectionStrategy.
Default value is CycleDetectionStrategy.STRICT
[Java -> JSON]
-
getDefaultValueProcessorMatcher
public DefaultValueProcessorMatcher getDefaultValueProcessorMatcher()
Returns the configured DefaultValueProcessorMatcher.
Default value is DefaultValueProcessorMatcher.DEFAULT
[Java -> JSON]
-
getEnclosedType
public java.lang.Class getEnclosedType()
Returns the current enclosed type for generic collection transformations.
[JSON -> Java]- Returns:
- the target type for conversion
-
getExcludes
public java.lang.String[] getExcludes()
Returns the configured properties for exclusion.
[Java -> JSON]
-
getJavaIdentifierTransformer
public JavaIdentifierTransformer getJavaIdentifierTransformer()
Returns the configured JavaIdentifierTransformer.
Default value is JavaIdentifierTransformer.NOOP
[JSON -> Java]
-
getJavaPropertyFilter
public PropertyFilter getJavaPropertyFilter()
Returns the configured property filter when serializing to Java.
[JSON -> Java]
-
getJavaPropertyNameProcessorMatcher
public PropertyNameProcessorMatcher getJavaPropertyNameProcessorMatcher()
Returns the configured PropertyNameProcessorMatcher.
Default value is PropertyNameProcessorMatcher.DEFAULT
[JSON -> Java]
-
getJsonBeanProcessorMatcher
public JsonBeanProcessorMatcher getJsonBeanProcessorMatcher()
Returns the configured JsonBeanProcessorMatcher.
Default value is JsonBeanProcessorMatcher.DEFAULT
[JSON -> Java]
-
getJsonEventListeners
public java.util.List getJsonEventListeners()
Returns a list of registered listeners for JSON events.
[JSON -> Java]
-
getJsonPropertyFilter
public PropertyFilter getJsonPropertyFilter()
Returns the configured property filter when serializing to JSON.
[Java -> JSON]
-
getJsonPropertyNameProcessorMatcher
public PropertyNameProcessorMatcher getJsonPropertyNameProcessorMatcher()
Returns the configured PropertyNameProcessorMatcher.
Default value is PropertyNameProcessorMatcher.DEFAULT
[Java -> JSON]
-
getJsonValueProcessorMatcher
public JsonValueProcessorMatcher getJsonValueProcessorMatcher()
Returns the configured JsonValueProcessorMatcher.
Default value is JsonValueProcessorMatcher.DEFAULT
[Java -> JSON]
-
getMergedExcludes
public java.util.Collection getMergedExcludes()
Returns a set of default excludes with user-defined excludes.
[Java -> JSON]
-
getMergedExcludes
public java.util.Collection getMergedExcludes(java.lang.Class target)
Returns a set of default excludes with user-defined excludes.
Takes into account any additional excludes per matching class. [Java -> JSON]
-
getNewBeanInstanceStrategy
public NewBeanInstanceStrategy getNewBeanInstanceStrategy()
Returns the configured NewBeanInstanceStrategy.
Default value is NewBeanInstanceStrategy.DEFAULT
[JSON -> Java]
-
getPropertyExclusionClassMatcher
public PropertyExclusionClassMatcher getPropertyExclusionClassMatcher()
Returns the configured PropertyExclusionClassMatcher.
Default value is PropertyExclusionClassMatcher.DEFAULT
[JSON -> Java]
-
getPropertyNameProcessorMatcher
public PropertyNameProcessorMatcher getPropertyNameProcessorMatcher()
Deprecated.use getJavaPropertyNameProcessorMatcher() insteadReturns the configured PropertyNameProcessorMatcher.
Default value is PropertyNameProcessorMatcher.DEFAULT
[JSON -> Java]
-
getPropertySetStrategy
public PropertySetStrategy getPropertySetStrategy()
Returns the configured PropertySetStrategy.
Default value is PropertySetStrategy.DEFAULT
[JSON -> Java]
-
getRootClass
public java.lang.Class getRootClass()
Returns the current root Class.
[JSON -> Java]- Returns:
- the target class for conversion
-
isAllowNonStringKeys
public boolean isAllowNonStringKeys()
Returns true if non-String keys are allowed on JSONObject.
Default value is false
[Java -> JSON]
-
isEventTriggeringEnabled
public boolean isEventTriggeringEnabled()
Returns true if event triggering is enabled during building.
Default value is false
[Java -> JSON]
-
isHandleJettisonEmptyElement
public boolean isHandleJettisonEmptyElement()
Returns true if this Jettison convention will be handled when converting to Java.
Jettison assumes that "" (empty string) can be assigned to empty elements (objects), which clearly violates the JSON spec.
[JSON -> Java]
-
isHandleJettisonSingleElementArray
public boolean isHandleJettisonSingleElementArray()
Returns true if this jettison convention will be handled when converting to Java.
Jettison states the following JSON {'media':{'title':'hello'}} can be set as a single element JSONArray (media is the array).
[JSON -> Java]
-
isIgnoreDefaultExcludes
public boolean isIgnoreDefaultExcludes()
Returns true if default excludes will not be used.
Default value is false.
[Java -> JSON]
-
isIgnoreJPATransient
public boolean isIgnoreJPATransient()
Returns true if JPA Transient annotated methods should be ignored.
Default value is false.
[Java -> JSON]
-
isIgnoreTransientFields
public boolean isIgnoreTransientFields()
Returns true if transient fields of a bean will be ignored.
Default value is false.
[Java -> JSON]
-
isIgnorePublicFields
public boolean isIgnorePublicFields()
Returns true if public fields of a bean will be ignored.
Default value is true.
[Java -> JSON]
-
isJavascriptCompliant
public boolean isJavascriptCompliant()
Returns true if Javascript compatibility is turned on.
Default value is false.
[Java -> JSON]
-
isSkipJavaIdentifierTransformationInMapKeys
public boolean isSkipJavaIdentifierTransformationInMapKeys()
Returns true if map keys will not be transformed.
Default value is false.
[JSON -> Java]
-
registerDefaultValueProcessor
public void registerDefaultValueProcessor(java.lang.Class target, DefaultValueProcessor defaultValueProcessor)
Registers a DefaultValueProcessor.
[Java -> JSON]- Parameters:
target
- the class to use as keydefaultValueProcessor
- the processor to register
-
registerJavaPropertyNameProcessor
public void registerJavaPropertyNameProcessor(java.lang.Class target, PropertyNameProcessor propertyNameProcessor)
Registers a PropertyNameProcessor.
[JSON -> Java]- Parameters:
target
- the class to use as keypropertyNameProcessor
- the processor to register
-
registerJsonBeanProcessor
public void registerJsonBeanProcessor(java.lang.Class target, JsonBeanProcessor jsonBeanProcessor)
Registers a JsonBeanProcessor.
[Java -> JSON]- Parameters:
target
- the class to use as keyjsonBeanProcessor
- the processor to register
-
registerJsonPropertyNameProcessor
public void registerJsonPropertyNameProcessor(java.lang.Class target, PropertyNameProcessor propertyNameProcessor)
Registers a PropertyNameProcessor.
[Java -> JSON]- Parameters:
target
- the class to use as keypropertyNameProcessor
- the processor to register
-
registerJsonValueProcessor
public void registerJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType, JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
[Java -> JSON]- Parameters:
beanClass
- the class to use as keypropertyType
- the property type to use as keyjsonValueProcessor
- the processor to register
-
registerJsonValueProcessor
public void registerJsonValueProcessor(java.lang.Class propertyType, JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
[Java -> JSON]- Parameters:
propertyType
- the property type to use as keyjsonValueProcessor
- the processor to register
-
registerJsonValueProcessor
public void registerJsonValueProcessor(java.lang.Class beanClass, java.lang.String key, JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
[Java -> JSON]- Parameters:
beanClass
- the class to use as keykey
- the property name to use as keyjsonValueProcessor
- the processor to register
-
registerJsonValueProcessor
public void registerJsonValueProcessor(java.lang.String key, JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
[Java -> JSON]- Parameters:
key
- the property name to use as keyjsonValueProcessor
- the processor to register
-
registerPropertyExclusion
public void registerPropertyExclusion(java.lang.Class target, java.lang.String propertyName)
Registers a exclusion for a target class.
[Java -> JSON]- Parameters:
target
- the class to use as keypropertyName
- the property to be excluded
-
registerPropertyExclusions
public void registerPropertyExclusions(java.lang.Class target, java.lang.String[] properties)
Registers exclusions for a target class.
[Java -> JSON]- Parameters:
target
- the class to use as keyproperties
- the properties to be excluded
-
registerPropertyNameProcessor
public void registerPropertyNameProcessor(java.lang.Class target, PropertyNameProcessor propertyNameProcessor)
Deprecated.use registerJavaPropertyNameProcessor() insteadRegisters a PropertyNameProcessor.
[JSON -> Java]- Parameters:
target
- the class to use as keypropertyNameProcessor
- the processor to register
-
removeJsonEventListener
public void removeJsonEventListener(JsonEventListener listener)
Removes a listener for JSON events.
[Java -> JSON]- Parameters:
listener
- a listener for events- See Also:
addJsonEventListener(JsonEventListener)
-
reset
public void reset()
Resets all values to its default state.
-
setAllowNonStringKeys
public void setAllowNonStringKeys(boolean allowNonStringKeys)
Sets if non-String keys are allowed on JSONObject.
[Java -> JSON]
-
setArrayMode
public void setArrayMode(int arrayMode)
Sets the current array mode for conversion.
If the value is not MODE_LIST, MODE_OBJECT_ARRAY nor MODE_SET, then MODE_LIST will be used.
[JSON -> Java]- Parameters:
arrayMode
- array mode for conversion
-
setClassMap
public void setClassMap(java.util.Map classMap)
Sets the current attribute/Class Map
[JSON -> Java]- Parameters:
classMap
- a Map of classes, every key identifies a property or a regexp
-
setCollectionType
public void setCollectionType(java.lang.Class collectionType)
Sets the current collection type used for collection transformations.
[JSON -> Java]- Parameters:
collectionType
- the target collection class for conversion
-
setCycleDetectionStrategy
public void setCycleDetectionStrategy(CycleDetectionStrategy cycleDetectionStrategy)
Sets a CycleDetectionStrategy to use.
Will set default value (CycleDetectionStrategy.STRICT) if null.
[Java -> JSON]
-
setDefaultValueProcessorMatcher
public void setDefaultValueProcessorMatcher(DefaultValueProcessorMatcher defaultValueProcessorMatcher)
Sets a DefaultValueProcessorMatcher to use.
Will set default value (DefaultValueProcessorMatcher.DEFAULT) if null.
[Java -> JSON]
-
setEnclosedType
public void setEnclosedType(java.lang.Class enclosedType)
Sets the current enclosed type for generic collection transformations.
[JSON -> Java]- Parameters:
enclosedType
- the target type for conversion
-
setExcludes
public void setExcludes(java.lang.String[] excludes)
Sets the excludes to use.
Will set default value ([]) if null.
[Java -> JSON]
-
setHandleJettisonEmptyElement
public void setHandleJettisonEmptyElement(boolean handleJettisonEmptyElement)
Activate/Deactivate handling this jettison convention when converting to Java.
Jettison states that "" (empty string) can be assigned to empty elements (objects), which clearly violates the JSON spec.
[JSON -> Java]
-
setHandleJettisonSingleElementArray
public void setHandleJettisonSingleElementArray(boolean handleJettisonSingleElementArray)
Activate/Deactivate handling this jettison convention when converting to Java.
* Jettison states the following JSON {'media':{'title':'hello'}} can be set as a single element JSONArray (media is the array).
[JSON -> Java]
-
setIgnoreDefaultExcludes
public void setIgnoreDefaultExcludes(boolean ignoreDefaultExcludes)
Sets if default excludes would be skipped when building.
[Java -> JSON]
-
setIgnoreJPATransient
public void setIgnoreJPATransient(boolean ignoreJPATransient)
Sets if JPA Transient annotated methods would be skipped when building.
[Java -> JSON]
-
addIgnoreFieldAnnotation
public void addIgnoreFieldAnnotation(java.lang.String annotationClassName)
Adds an annotation that marks a field to be skipped when building.
[Java -> JSON]
-
removeIgnoreFieldAnnotation
public void removeIgnoreFieldAnnotation(java.lang.String annotationClassName)
Adds an annotation that marks a field to be skipped when building.
[Java -> JSON]
-
addIgnoreFieldAnnotation
public void addIgnoreFieldAnnotation(java.lang.Class annotationClass)
Removes an annotation that marks a field to be skipped when building.
[Java -> JSON]
-
removeIgnoreFieldAnnotation
public void removeIgnoreFieldAnnotation(java.lang.Class annotationClass)
Removes an annotation that marks a field to be skipped when building.
[Java -> JSON]
-
getIgnoreFieldAnnotations
public java.util.List getIgnoreFieldAnnotations()
Returns a List of all annotations that mark a field to be skipped when building.
[Java -> JSON]
-
setIgnoreTransientFields
public void setIgnoreTransientFields(boolean ignoreTransientFields)
Sets if transient fields would be skipped when building.
[Java -> JSON]
-
setIgnorePublicFields
public void setIgnorePublicFields(boolean ignorePublicFields)
Sets if public fields would be skipped when building.
[Java -> JSON]
-
setJavascriptCompliant
public void setJavascriptCompliant(boolean javascriptCompliant)
Sets if Javascript compatibility is enabled when building.
[Java -> JSON]
-
setJavaIdentifierTransformer
public void setJavaIdentifierTransformer(JavaIdentifierTransformer javaIdentifierTransformer)
Sets the JavaIdentifierTransformer to use.
Will set default value (JavaIdentifierTransformer.NOOP) if null.
[JSON -> Java]
-
setJavaPropertyFilter
public void setJavaPropertyFilter(PropertyFilter javaPropertyFilter)
Sets a property filter used when serializing to Java.
[JSON -> Java]- Parameters:
javaPropertyFilter
- the property filter
-
setJavaPropertyNameProcessorMatcher
public void setJavaPropertyNameProcessorMatcher(PropertyNameProcessorMatcher propertyNameProcessorMatcher)
Sets a PropertyNameProcessorMatcher to use.
Will set default value (PropertyNameProcessorMatcher.DEFAULT) if null.
[JSON -> Java]
-
setJsonBeanProcessorMatcher
public void setJsonBeanProcessorMatcher(JsonBeanProcessorMatcher jsonBeanProcessorMatcher)
Sets a JsonBeanProcessorMatcher to use.
Will set default value (JsonBeanProcessorMatcher.DEFAULT) if null.
[Java -> JSON]
-
setJsonPropertyFilter
public void setJsonPropertyFilter(PropertyFilter jsonPropertyFilter)
Sets a property filter used when serializing to JSON.
[Java -> JSON]- Parameters:
jsonPropertyFilter
- the property filter
-
setJsonPropertyNameProcessorMatcher
public void setJsonPropertyNameProcessorMatcher(PropertyNameProcessorMatcher propertyNameProcessorMatcher)
Sets a PropertyNameProcessorMatcher to use.
Will set default value (PropertyNameProcessorMatcher.DEFAULT) if null.
[Java -> JSON]
-
setJsonValueProcessorMatcher
public void setJsonValueProcessorMatcher(JsonValueProcessorMatcher jsonValueProcessorMatcher)
Sets a JsonValueProcessorMatcher to use.
Will set default value (JsonValueProcessorMatcher.DEFAULT) if null.
[Java -> JSON]
-
setNewBeanInstanceStrategy
public void setNewBeanInstanceStrategy(NewBeanInstanceStrategy newBeanInstanceStrategy)
Sets the NewBeanInstanceStrategy to use.
Will set default value (NewBeanInstanceStrategy.DEFAULT) if null.
[JSON -> Java]
-
setPropertyExclusionClassMatcher
public void setPropertyExclusionClassMatcher(PropertyExclusionClassMatcher propertyExclusionClassMatcher)
Sets a PropertyExclusionClassMatcher to use.
Will set default value (PropertyExclusionClassMatcher.DEFAULT) if null.
[Java -> JSON]
-
setPropertyNameProcessorMatcher
public void setPropertyNameProcessorMatcher(PropertyNameProcessorMatcher propertyNameProcessorMatcher)
Deprecated.use setJavaPropertyNameProcessorMatcher() insteadSets a PropertyNameProcessorMatcher to use.
Will set default value (PropertyNameProcessorMatcher.DEFAULT) if null.
[JSON -> Java]
-
setPropertySetStrategy
public void setPropertySetStrategy(PropertySetStrategy propertySetStrategy)
Sets a PropertySetStrategy to use.
Will set default value (PropertySetStrategy.DEFAULT) if null.
[JSON -> Java]
-
setRootClass
public void setRootClass(java.lang.Class rootClass)
Sets the current root Class.
[JSON -> Java]- Parameters:
rootClass
- the target class for conversion
-
setSkipJavaIdentifierTransformationInMapKeys
public void setSkipJavaIdentifierTransformationInMapKeys(boolean skipJavaIdentifierTransformationInMapKeys)
Sets if property name as JavaIndetifier transformations would be skipped.
[JSON -> Java]
-
unregisterDefaultValueProcessor
public void unregisterDefaultValueProcessor(java.lang.Class target)
Removes a DefaultValueProcessor.
[Java -> JSON]- Parameters:
target
- a class used for searching a DefaultValueProcessor.
-
unregisterJavaPropertyNameProcessor
public void unregisterJavaPropertyNameProcessor(java.lang.Class target)
Removes a PropertyNameProcessor.
[JSON -> Java]- Parameters:
target
- a class used for searching a PropertyNameProcessor.
-
unregisterJsonBeanProcessor
public void unregisterJsonBeanProcessor(java.lang.Class target)
Removes a JsonBeanProcessor.
[Java -> JSON]- Parameters:
target
- a class used for searching a JsonBeanProcessor.
-
unregisterJsonPropertyNameProcessor
public void unregisterJsonPropertyNameProcessor(java.lang.Class target)
Removes a PropertyNameProcessor.
[Java -> JSON]- Parameters:
target
- a class used for searching a PropertyNameProcessor.
-
unregisterJsonValueProcessor
public void unregisterJsonValueProcessor(java.lang.Class propertyType)
Removes a JsonValueProcessor.
[Java -> JSON]- Parameters:
propertyType
- a class used for searching a JsonValueProcessor.
-
unregisterJsonValueProcessor
public void unregisterJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType)
Removes a JsonValueProcessor.
[Java -> JSON]- Parameters:
beanClass
- the class to which the property may belongpropertyType
- the type of the property
-
unregisterJsonValueProcessor
public void unregisterJsonValueProcessor(java.lang.Class beanClass, java.lang.String key)
Removes a JsonValueProcessor.
[Java -> JSON]- Parameters:
beanClass
- the class to which the property may belongkey
- the name of the property which may belong to the target class
-
unregisterJsonValueProcessor
public void unregisterJsonValueProcessor(java.lang.String key)
Removes a JsonValueProcessor.
[Java -> JSON]- Parameters:
key
- the name of the property which may belong to the target class
-
unregisterPropertyExclusion
public void unregisterPropertyExclusion(java.lang.Class target, java.lang.String propertyName)
Removes a property exclusion assigned to the target class.
[Java -> JSON]- Parameters:
target
- a class used for searching property exclusions.propertyName
- the name of the property to be removed from the exclusion list.
-
unregisterPropertyExclusions
public void unregisterPropertyExclusions(java.lang.Class target)
Removes all property exclusions assigned to the target class.
[Java -> JSON]- Parameters:
target
- a class used for searching property exclusions.
-
unregisterPropertyNameProcessor
public void unregisterPropertyNameProcessor(java.lang.Class target)
Deprecated.use unregisterJavaPropertyNameProcessor() insteadRemoves a PropertyNameProcessor.
[JSON -> Java]- Parameters:
target
- a class used for searching a PropertyNameProcessor.
-
-