Package org.eclipse.jetty.util.ajax
Class JSONPojoConvertor
java.lang.Object
org.eclipse.jetty.util.ajax.JSONPojoConvertor
- All Implemented Interfaces:
JSON.Convertor
Converts POJOs to JSON and vice versa.
The key difference:
- returns the actual object from Convertor.fromJSON (JSONObjectConverter returns a Map)
- the getters/setters are resolved at initialization (JSONObjectConverter resolves it at runtime)
- correctly sets the number fields
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map
<Class<?>, JSONPojoConvertor.NumberType> protected boolean
protected Class
<?> protected Map
<String, JSONPojoConvertor.Setter> static final JSONPojoConvertor.NumberType
static final JSONPojoConvertor.NumberType
static final Object[]
static final JSONPojoConvertor.NumberType
private static final Logger
static final JSONPojoConvertor.NumberType
static final Object[]
static final JSONPojoConvertor.NumberType
-
Constructor Summary
ConstructorsConstructorDescriptionJSONPojoConvertor
(Class<?> pojoClass) JSONPojoConvertor
(Class<?> pojoClass, boolean fromJSON) JSONPojoConvertor
(Class<?> pojoClass, String[] excluded) JSONPojoConvertor
(Class<?> pojoClass, Set<String> excluded) JSONPojoConvertor
(Class<?> pojoClass, Set<String> excluded, boolean fromJSON) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
protected int
static JSONPojoConvertor.NumberType
getNumberType
(Class<?> clazz) protected JSONPojoConvertor.Setter
protected boolean
includeField
(String name, Method m) protected void
init()
protected void
int
void
toJSON
(Object obj, JSON.Output out)
-
Field Details
-
LOG
-
GETTER_ARG
-
NULL_ARG
-
__numberTypes
-
_fromJSON
protected boolean _fromJSON -
_pojoClass
-
_getters
-
_setters
-
_excluded
-
SHORT
-
INTEGER
-
FLOAT
-
LONG
-
DOUBLE
-
-
Constructor Details
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convert
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convertexcluded
- The fields to exclude
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convertexcluded
- The fields to exclude
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convertexcluded
- The fields to excludefromJSON
- If true, add a class field to the JSON
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convertfromJSON
- If true, add a class field to the JSON
-
-
Method Details
-
getNumberType
-
init
protected void init() -
addGetter
-
addSetter
-
getSetter
-
includeField
-
getExcludedCount
protected int getExcludedCount() -
fromJSON
- Specified by:
fromJSON
in interfaceJSON.Convertor
-
setProps
-
toJSON
- Specified by:
toJSON
in interfaceJSON.Convertor
-
log
-