Top Description Inners Fields Constructors Methods
org.eclipse.jetty.util.ajax

public Class JSONPojoConvertor

extends Object
implements Convertor
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.ajax.JSON.Convertor
Imports
java.lang.reflect.Array, .Method, .Modifier, java.util.Arrays, .HashMap, .HashSet, .Locale, .Map, .Set, org.eclipse.jetty.util.ajax.JSON.Output, org.slf4j.Logger, .LoggerFactory

Converts POJOs to JSON and vice versa.

The key differences with respect to JSONObjectConvertor are:

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static class

Field Summary

Modifier and TypeField and Description
private static final Map<Class<?>, JSONPojoConvertor.NumberType>
protected Set<String>
protected boolean
protected Map<String, Method>
protected Class<?>
protected Map<String, JSONPojoConvertor.Setter>
private static final JSONPojoConvertor.NumberType
private static final JSONPojoConvertor.NumberType
private static final JSONPojoConvertor.NumberType
private static final Logger
private static final JSONPojoConvertor.NumberType
private static final JSONPojoConvertor.NumberType

Constructor Summary

AccessConstructor and Description
public
JSONPojoConvertor(Class<?>
The class to convert
pojoClass
)

public
JSONPojoConvertor(Class<?>
The class to convert
pojoClass
,
boolean
If true, add a class field to the JSON
fromJSON
)

public
JSONPojoConvertor(Class<?>
The class to convert
pojoClass
,
String[]
The fields to exclude
excluded
)

public
JSONPojoConvertor(Class<?>
The class to convert
pojoClass
,
Set<String>
The fields to exclude
excluded
)

public
JSONPojoConvertor(Class<?>
The class to convert
pojoClass
,
Set<String>
The fields to exclude
excluded
,
boolean
If true, add a class field to the JSON
fromJSON
)

Method Summary

Modifier and TypeMethod and Description
protected void
addGetter(String name, Method method)

protected void
addSetter(String name, Method method)

public Object
public static JSONPojoConvertor.NumberType
getNumberType(Class<?> clazz)

protected JSONPojoConvertor.Setter
protected boolean
protected void
init()

private void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__numberTypesback to summary
private static final Map<Class<?>, JSONPojoConvertor.NumberType> __numberTypes
_excludedback to summary
protected Set<String> _excluded
_fromJSONback to summary
protected boolean _fromJSON
_gettersback to summary
protected Map<String, Method> _getters
_pojoClassback to summary
protected Class<?> _pojoClass
_settersback to summary
protected Map<String, JSONPojoConvertor.Setter> _setters
DOUBLEback to summary
private static final JSONPojoConvertor.NumberType DOUBLE
FLOATback to summary
private static final JSONPojoConvertor.NumberType FLOAT
INTEGERback to summary
private static final JSONPojoConvertor.NumberType INTEGER
LOGback to summary
private static final Logger LOG
LONGback to summary
private static final JSONPojoConvertor.NumberType LONG
SHORTback to summary
private static final JSONPojoConvertor.NumberType SHORT

Constructor Detail

JSONPojoConvertorback to summary
public JSONPojoConvertor(Class<?> pojoClass)
Parameters
pojoClass:Class<?>

The class to convert

JSONPojoConvertorback to summary
public JSONPojoConvertor(Class<?> pojoClass, boolean fromJSON)
Parameters
pojoClass:Class<?>

The class to convert

fromJSON:boolean

If true, add a class field to the JSON

JSONPojoConvertorback to summary
public JSONPojoConvertor(Class<?> pojoClass, String[] excluded)
Parameters
pojoClass:Class<?>

The class to convert

excluded:String[]

The fields to exclude

JSONPojoConvertorback to summary
public JSONPojoConvertor(Class<?> pojoClass, Set<String> excluded)
Parameters
pojoClass:Class<?>

The class to convert

excluded:Set<String>

The fields to exclude

JSONPojoConvertorback to summary
public JSONPojoConvertor(Class<?> pojoClass, Set<String> excluded, boolean fromJSON)
Parameters
pojoClass:Class<?>

The class to convert

excluded:Set<String>

The fields to exclude

fromJSON:boolean

If true, add a class field to the JSON

Method Detail

addGetterback to summary
protected void addGetter(String name, Method method)
addSetterback to summary
protected void addSetter(String name, Method method)
fromJSONback to summary
public Object fromJSON(Map<String, Object> object)

Implements org.eclipse.jetty.util.ajax.JSON.Convertor.fromJSON.

Annotations
@Override
getNumberTypeback to summary
public static JSONPojoConvertor.NumberType getNumberType(Class<?> clazz)
getSetterback to summary
protected JSONPojoConvertor.Setter getSetter(String name)
includeFieldback to summary
protected boolean includeField(String name, Method m)
initback to summary
protected void init()
setPropsback to summary
private void setProps(Object obj, Map<String, Object> props)
toJSONback to summary
public void toJSON(Object obj, JSON.Output out)

Implements org.eclipse.jetty.util.ajax.JSON.Convertor.toJSON.

Annotations
@Override
org.eclipse.jetty.util.ajax back to summary

public Interface JSONPojoConvertor.NumberType


Method Summary

Modifier and TypeMethod and Description
public Object

Method Detail

getActualValueback to summary
public Object getActualValue(Number number)
org.eclipse.jetty.util.ajax back to summary

public Class JSONPojoConvertor.Setter

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
protected Class<?>
protected JSONPojoConvertor.NumberType
protected String
protected Method
protected Class<?>

Constructor Summary

AccessConstructor and Description
public
Setter(String propertyName, Method method)

Method Summary

Modifier and TypeMethod and Description
public Class<?>
public Method
public JSONPojoConvertor.NumberType
public String
public Class<?>
public void
invoke(Object obj, Object value)

protected void
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_componentTypeback to summary
protected Class<?> _componentType
_numberTypeback to summary
protected JSONPojoConvertor.NumberType _numberType
_propertyNameback to summary
protected String _propertyName
_setterback to summary
protected Method _setter
_typeback to summary
protected Class<?> _type

Constructor Detail

Setterback to summary
public Setter(String propertyName, Method method)

Method Detail

getComponentTypeback to summary
public Class<?> getComponentType()
getMethodback to summary
public Method getMethod()
getNumberTypeback to summary
public JSONPojoConvertor.NumberType getNumberType()
getPropertyNameback to summary
public String getPropertyName()
getTypeback to summary
public Class<?> getType()
invokeback to summary
public void invoke(Object obj, Object value) throws Exception
invokeObjectback to summary
protected void invokeObject(Object obj, Object value) throws Exception
isPropertyNumberback to summary
public boolean isPropertyNumber()