|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sr.common.transformer.json.JSTransformer
public final class JSTransformer
This class is designed to be a generic JSON transformer which covers all Java types. The class contains references to all type converters and uses them in it's operations. The project covers all java types from primitives to complex beans. It's quite easy to add your own transformer classes by using registerTransformer method of this class to improve transformation performance.
Field Summary |
---|
Fields inherited from interface org.sr.common.transformer.json.IJSTransformer |
---|
ARRAY_ATTRIBUTE, ARRAY_CLASS, JSNULL_CLASS_IDENTIFIER, JSNULL_VALUE, LIST_ATTRIBUTE, MAP_ATTRIBUTE, MAPITEM_PREFIX, MAPKEY_ATTRIBUTE, MAPVALUE_ATTRIBUTE, SET_ATTRIBUTE, TIME_ATTRIBUTE, TIMEZONE_ATTRIBUTE |
Fields inherited from interface org.sr.common.transformer.ITransformer |
---|
CLASS_HINT_ATTRIBUTE, VALUE_ATTRIBUTE |
Constructor Summary | |
---|---|
JSTransformer()
|
Method Summary | |
---|---|
java.util.List<java.lang.Class<?>> |
findConvertibles()
Gives convertible java types |
boolean |
isConvertible(java.lang.Class<?> clazz)
tells if the given class is convertible by the implementation |
boolean |
isConvertible(java.lang.String className)
tells if the given class is convertible by the implementation |
static void |
registerTransformer(java.lang.Class<? extends IJSTransformer> clazz)
|
java.lang.Object |
toJava(java.lang.Class<?> clazz,
java.lang.Object obj)
Transforms from target type to Java |
java.lang.Object |
toJava(java.lang.Object obj)
Transforms from target type to Java |
java.lang.Object |
toTargetType(java.lang.Object o)
Converts java object to targetted type |
java.lang.Object |
toTargetType(java.lang.Object o,
ObjectReferenceMap referenceMap)
Converts java object to targetted type |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JSTransformer()
Method Detail |
---|
public static final void registerTransformer(java.lang.Class<? extends IJSTransformer> clazz)
public java.lang.Object toJava(java.lang.Object obj) throws TransformationException, TransformationNotSupportedException
ITransformer
toJava
in interface ITransformer<java.lang.Object>
obj
- source object
TransformationException
TransformationNotSupportedException
public java.lang.Object toJava(java.lang.Class<?> clazz, java.lang.Object obj) throws TransformationException, TransformationNotSupportedException
ITransformer
toJava
in interface ITransformer<java.lang.Object>
clazz
- to be transformed java classobj
- source object
TransformationException
TransformationNotSupportedException
public java.lang.Object toTargetType(java.lang.Object o) throws TransformationException, TransformationNotSupportedException
ITransformer
toTargetType
in interface ITransformer<java.lang.Object>
o
- source java object
TransformationException
TransformationNotSupportedException
public java.lang.Object toTargetType(java.lang.Object o, ObjectReferenceMap referenceMap) throws TransformationException, TransformationNotSupportedException
ITransformer
toTargetType
in interface ITransformer<java.lang.Object>
o
- source java objectreferenceMap
- this parameters usually created by highest level transformer to control cyclic dependencies
TransformationException
TransformationNotSupportedException
public java.util.List<java.lang.Class<?>> findConvertibles()
ITransformer
findConvertibles
in interface ITransformer<java.lang.Object>
public boolean isConvertible(java.lang.String className)
ITransformer
isConvertible
in interface ITransformer<java.lang.Object>
public boolean isConvertible(java.lang.Class<?> clazz)
ITransformer
isConvertible
in interface ITransformer<java.lang.Object>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |