net.sf.json
public class JsonConfig extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static JsonBeanProcessorMatcher |
DEFAULT_JSON_BEAN_PROCESSOR_MATCHER |
static NewBeanInstanceStrategy |
DEFAULT_NEW_BEAN_INSTANCE_STRATEGY |
static int |
MODE_LIST |
static int |
MODE_OBJECT_ARRAY |
Constructor and Description |
---|
JsonConfig() |
Modifier and Type | Method and Description |
---|---|
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. |
void |
clearJsonBeanProcessors()
Removes all registered JsonBeanProcessors.
|
void |
clearJsonEventListeners()
Removes all registered listener for Json Events.
|
void |
clearJsonValueProcessors()
Removes all registered JsonValueProcessors.
|
JsonConfig |
copy() |
void |
disableEventTriggering()
Disables event triggering when building.
|
void |
enableEventTriggering()
Enables event triggering when building.
|
JsonBeanProcessor |
findJsonBeanProcessor(java.lang.Class target)
Finds a JsonBeanProcessor registered to the target class.
Returns null if none is registered. |
JsonValueProcessor |
findJsonValueProcessor(java.lang.Class propertyType)
Finds a JsonValueProcessor registered to the target type.
Returns null if none is registered. |
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. |
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. |
int |
getArrayMode()
Returns the current array mode conversion
|
java.util.Map |
getClassMap()
Returns the current attribute/class Map
|
CycleDetectionStrategy |
getCycleDetectionStrategy()
Returns the configured CycleDetectionStrategy.
Default value is CycleDetectionStrategy.STRICT |
java.lang.String[] |
getExcludes()
Returns the configured properties for exclusion.
|
JavaIdentifierTransformer |
getJavaIdentifierTransformer()
Returns the configured JavaIdentifierTransformer.
|
PropertyFilter |
getJavaPropertyFilter()
Returns the configured property filter when serializing to Java.
|
JsonBeanProcessorMatcher |
getJsonBeanProcessorMatcher()
Returns the configured JsonBeanProcessorMatcher.
Default value is JsonBeanProcessorMatcher.DEFAULT |
java.util.List |
getJsonEventListeners()
Returns a list of registered listeners for Json events.
|
PropertyFilter |
getJsonPropertyFilter()
Returns the configured property filter when serializing to JSON.
|
java.util.Collection |
getMergedExcludes()
Returns a set of default excludes with user-defined excludes.
|
NewBeanInstanceStrategy |
getNewBeanInstanceStrategy()
Returns the configured NewBeanInstanceStrategy.
Default value is NewBeanInstanceStrategy.DEFAULT |
java.lang.Class |
getRootClass()
Returns the current root Class.
|
boolean |
isEventTriggeringEnabled()
Returns true if event triggering is enabled during building.
Default value is false |
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. |
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). |
boolean |
isIgnoreDefaultExcludes()
Returns true if default excludes will not be used.
Default value is false |
boolean |
isIgnoreTransientFields()
Returns true if transient fields of a bean will be ignored.
Default value is false |
boolean |
isSkipJavaIdentifierTransformationInMapKeys()
Returns true if map keys will not be transformed.
Default value is false |
void |
registerJsonBeanProcessor(java.lang.Class target,
JsonBeanProcessor jsonBeanProcessor)
Registers a JsonValueProcessor.
|
void |
registerJsonValueProcessor(java.lang.Class beanClass,
java.lang.Class propertyType,
JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
|
void |
registerJsonValueProcessor(java.lang.Class propertyType,
JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
|
void |
registerJsonValueProcessor(java.lang.Class beanClass,
java.lang.String key,
JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
|
void |
registerJsonValueProcessor(java.lang.String key,
JsonValueProcessor jsonValueProcessor)
Registers a JsonValueProcessor.
|
void |
removeJsonEventListener(JsonEventListener listener)
Removes a listener for Json events.
|
void |
reset()
Resets all values to its default state.
|
void |
setArrayMode(int arrayMode)
Sets the current array mode for conversion.
If the value is not MODE_LIST neither MODE_OBJECT_ARRAY, then MODE_LIST will be used. |
void |
setClassMap(java.util.Map classMap)
Sets the current attribute/Class Map
|
void |
setCycleDetectionStrategy(CycleDetectionStrategy cycleDetectionStrategy)
Sets a CycleDetectionStrategy to use.
Will set default value (CycleDetectionStrategy.STRICT) if null. |
void |
setExcludes(java.lang.String[] excludes)
Sets the excludes to use.
Will set default value ([]) if null. |
void |
setHandleJettisonEmptyElement(boolean handleJettisonEmptyElement)
Activate/Deactive 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. |
void |
setHandleJettisonSingleElementArray(boolean handleJettisonSingleElementArray)
Activate/Deactive 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). |
void |
setIgnoreDefaultExcludes(boolean ignoreDefaultExcludes)
Sets if default ecludes would be skipped when building.
|
void |
setIgnoreTransientFields(boolean ignoreTransientFields)
Sets if transient fields would be skipped when building.
|
void |
setJavaIdentifierTransformer(JavaIdentifierTransformer javaIdentifierTransformer)
Sets the JavaIdentifierTransformer to use.
Will set default value (JavaIdentifierTransformer.NOOP) if null. |
void |
setJavaPropertyFilter(PropertyFilter javaPropertyFilter)
Sets a property filter used when serializing to Java.
|
void |
setJsonBeanProcessorMatcher(JsonBeanProcessorMatcher jsonBeanProcessorMatcher)
Sets a JsonBeanProcessorMatcher to use.
Will set default value (JsonBeanProcessorMatcher.STRICT) if null. |
void |
setJsonPropertyFilter(PropertyFilter jsonPropertyFilter)
Sets a property filter used when serializing to JSON.
|
void |
setNewBeanInstanceStrategy(NewBeanInstanceStrategy newBeanInstanceStrategy)
Sets the NewBeanInstanceStrategy to use.
Will set default value (NewBeanInstanceStrategy.DEFAULT) if null. |
void |
setRootClass(java.lang.Class rootClass)
Sets the current root Class
|
void |
setSkipJavaIdentifierTransformationInMapKeys(boolean skipJavaIdentifierTransformationInMapKeys)
Sets if transient fields of beans would be skipped when building.
|
void |
unregisterJsonBeanProcessor(java.lang.Class target)
Removes a JsonBeanProcessor.
|
void |
unregisterJsonValueProcessor(java.lang.Class propertyType)
Removes a JsonValueProcessor.
|
void |
unregisterJsonValueProcessor(java.lang.Class beanClass,
java.lang.Class propertyType)
Removes a JsonValueProcessor.
|
void |
unregisterJsonValueProcessor(java.lang.Class beanClass,
java.lang.String key)
Removes a JsonValueProcessor.
|
void |
unregisterJsonValueProcessor(java.lang.String key)
Removes a JsonValueProcessor.
|
public static final JsonBeanProcessorMatcher DEFAULT_JSON_BEAN_PROCESSOR_MATCHER
public static final NewBeanInstanceStrategy DEFAULT_NEW_BEAN_INSTANCE_STRATEGY
public static final int MODE_LIST
public static final int MODE_OBJECT_ARRAY
public void addJsonEventListener(JsonEventListener listener)
listener
- a listener for eventsenableEventTriggering()
,
disableEventTriggering()
,
removeJsonEventListener(JsonEventListener)
public void clearJsonBeanProcessors()
public void clearJsonEventListeners()
public void clearJsonValueProcessors()
public JsonConfig copy()
public void disableEventTriggering()
public void enableEventTriggering()
public JsonBeanProcessor findJsonBeanProcessor(java.lang.Class target)
target
- a class used for searching a JsonBeanProcessor.public JsonValueProcessor findJsonValueProcessor(java.lang.Class propertyType)
propertyType
- a class used for searching a JsonValueProcessor.public JsonValueProcessor findJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType, java.lang.String key)
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 classpublic JsonValueProcessor findJsonValueProcessor(java.lang.Class propertyType, java.lang.String key)
propertyType
- the type of the propertykey
- the name of the property which may belong to the target classpublic int getArrayMode()
public java.util.Map getClassMap()
public CycleDetectionStrategy getCycleDetectionStrategy()
public java.lang.String[] getExcludes()
public JavaIdentifierTransformer getJavaIdentifierTransformer()
public PropertyFilter getJavaPropertyFilter()
public JsonBeanProcessorMatcher getJsonBeanProcessorMatcher()
public java.util.List getJsonEventListeners()
public PropertyFilter getJsonPropertyFilter()
public java.util.Collection getMergedExcludes()
public NewBeanInstanceStrategy getNewBeanInstanceStrategy()
public java.lang.Class getRootClass()
public boolean isEventTriggeringEnabled()
public boolean isHandleJettisonEmptyElement()
public boolean isHandleJettisonSingleElementArray()
public boolean isIgnoreDefaultExcludes()
public boolean isIgnoreTransientFields()
public boolean isSkipJavaIdentifierTransformationInMapKeys()
public void registerJsonBeanProcessor(java.lang.Class target, JsonBeanProcessor jsonBeanProcessor)
target
- the class to use as keyjsonBeanProcessor
- the processor to registerpublic void registerJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType, JsonValueProcessor jsonValueProcessor)
beanClass
- the class to use as keypropertyType
- the property type to use as keyjsonValueProcessor
- the processor to registerpublic void registerJsonValueProcessor(java.lang.Class propertyType, JsonValueProcessor jsonValueProcessor)
propertyType
- the property type to use as keyjsonValueProcessor
- the processor to registerpublic void registerJsonValueProcessor(java.lang.Class beanClass, java.lang.String key, JsonValueProcessor jsonValueProcessor)
beanClass
- the class to use as keykey
- the property name to use as keyjsonValueProcessor
- the processor to registerpublic void registerJsonValueProcessor(java.lang.String key, JsonValueProcessor jsonValueProcessor)
key
- the property name to use as keyjsonValueProcessor
- the processor to registerpublic void removeJsonEventListener(JsonEventListener listener)
listener
- a listener for eventsaddJsonEventListener(JsonEventListener)
public void reset()
public void setArrayMode(int arrayMode)
arrayMode
- array mode for conversionpublic void setClassMap(java.util.Map classMap)
classMap
- a Map of classes, every key identifies a property or a
regexppublic void setCycleDetectionStrategy(CycleDetectionStrategy cycleDetectionStrategy)
public void setExcludes(java.lang.String[] excludes)
public void setHandleJettisonEmptyElement(boolean handleJettisonEmptyElement)
public void setHandleJettisonSingleElementArray(boolean handleJettisonSingleElementArray)
public void setIgnoreDefaultExcludes(boolean ignoreDefaultExcludes)
public void setIgnoreTransientFields(boolean ignoreTransientFields)
public void setJavaIdentifierTransformer(JavaIdentifierTransformer javaIdentifierTransformer)
public void setJavaPropertyFilter(PropertyFilter javaPropertyFilter)
javaPropertyFilter
- the property filterpublic void setJsonBeanProcessorMatcher(JsonBeanProcessorMatcher jsonBeanProcessorMatcher)
public void setJsonPropertyFilter(PropertyFilter jsonPropertyFilter)
jsonPropertyFilter
- the property filterpublic void setNewBeanInstanceStrategy(NewBeanInstanceStrategy newBeanInstanceStrategy)
public void setRootClass(java.lang.Class rootClass)
rootClass
- the target class for conversionpublic void setSkipJavaIdentifierTransformationInMapKeys(boolean skipJavaIdentifierTransformationInMapKeys)
public void unregisterJsonBeanProcessor(java.lang.Class target)
target
- a class used for searching a JsonBeanProcessor.public void unregisterJsonValueProcessor(java.lang.Class propertyType)
propertyType
- a class used for searching a JsonValueProcessor.public void unregisterJsonValueProcessor(java.lang.Class beanClass, java.lang.Class propertyType)
beanClass
- the class to which the property may belongpropertyType
- the type of the propertypublic void unregisterJsonValueProcessor(java.lang.Class beanClass, java.lang.String key)
beanClass
- the class to which the property may belongkey
- the name of the property which may belong to the target classpublic void unregisterJsonValueProcessor(java.lang.String key)
key
- the name of the property which may belong to the target classCopyright © 2006-2014 Json-lib. All Rights Reserved.