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 interfacestatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Class<?>protected Map<String,JSONPojoConvertor.Setter> static final JSONPojoConvertor.NumberTypestatic final JSONPojoConvertor.NumberTypestatic final Object[]static final JSONPojoConvertor.NumberTypestatic final JSONPojoConvertor.NumberTypestatic 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 voidprotected voidprotected intstatic JSONPojoConvertor.NumberTypegetNumberType(Class<?> clazz) protected JSONPojoConvertor.Setterprotected booleanincludeField(String name, Method m) protected voidinit()protected voidintvoidtoJSON(Object obj, JSON.Output out)
-
Field Details
-
GETTER_ARG
-
NULL_ARG
-
_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:
fromJSONin interfaceJSON.Convertor
-
setProps
-
toJSON
- Specified by:
toJSONin interfaceJSON.Convertor
-
log
-