Class JsonTraverser
java.lang.Object
jadex.common.transformation.traverser.Traverser
jadex.transformation.jsonserializer.JsonTraverser
public class JsonTraverser
extends jadex.common.transformation.traverser.Traverser
The JsonTraverser converts a preparsed JsonValue object to
a corresponding Java object.
todo: introduce boolean in traverser that checks if read a json object in map is ok
-
Nested Class Summary
Nested classes/interfaces inherited from class jadex.common.transformation.traverser.Traverser
jadex.common.transformation.traverser.Traverser.MODE
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static List
<jadex.common.transformation.traverser.ITraverseProcessor> static List
<jadex.common.transformation.traverser.ITraverseProcessor> protected static JsonTraverser
static final String
static List
<jadex.common.transformation.traverser.ITraverseProcessor> protected static jadex.common.transformation.traverser.Traverser
Fields inherited from class jadex.common.transformation.traverser.Traverser
IGNORE_RESULT, instance, processorcache, processors
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClass
<?> findClazz
(Object object, ClassLoader targetcl) Find the class of an object.static Class
<?> findClazzOfJsonObject
(com.eclipsesource.json.JsonObject object, ClassLoader targetcl) Find the class of an object.static List
<jadex.common.transformation.traverser.ITraverseProcessor> Get a copy of the default read processors.static List
<jadex.common.transformation.traverser.ITraverseProcessor> Get a copy of the default read processors.protected static JsonTraverser
protected static jadex.common.transformation.traverser.Traverser
static Object
objectFromByteArray
(byte[] val, ClassLoader classloader) Convert a byte array (of an xml) to an object.static Object
objectFromByteArray
(byte[] val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep) Convert a byte array (of an xml) to an object.static <T> T
objectFromByteArray
(byte[] val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, String enc, Class<T> clazz) Convert a byte array (of an xml) to an object.static <T> T
objectFromByteArray
(byte[] val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, String enc, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> procs, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocs) Convert a byte array (of an xml) to an object.static <T> T
objectFromByteArray
(byte[] val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, String enc, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> procs, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocs, Object usercontext, jadex.common.transformation.IStringConverter converter) Convert a byte array (of an xml) to an object.static Object
objectFromByteArray
(byte[] val, ClassLoader classloader, String enc) Convert a byte array (of an xml) to an object.static <T> T
objectFromString
(String val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, Class<T> clazz) Convert a byte array (of an xml) to an object.static <T> T
objectFromString
(String val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert a byte array (of an xml) to an object.static <T> T
objectFromString
(String val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocessors) Convert a byte array (of an xml) to an object.static <T> T
objectFromString
(String val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocessors, Object usercontext, jadex.common.transformation.IStringConverter converter) Convert a byte array (of an xml) to an object.static <T> T
objectFromString
(String val, ClassLoader classloader, Class<T> clazz) Convert a byte array (of an xml) to an object.static byte[]
objectToByteArray
(Object val, ClassLoader classloader) Convert to a byte array.static byte[]
objectToByteArray
(Object val, ClassLoader classloader, String enc) Convert to a byte array.static byte[]
objectToByteArray
(Object val, ClassLoader classloader, String enc, boolean writeclass) Convert to a byte array.static byte[]
objectToByteArray
(Object val, ClassLoader classloader, String enc, boolean writeclass, boolean writeid, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> conversionprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a byte array.static byte[]
objectToByteArray
(Object val, ClassLoader classloader, String enc, boolean writeclass, boolean writeid, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> conversionprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, Object usercontext, jadex.common.transformation.IStringConverter converter) Convert to a byte array.static byte[]
objectToByteArray
(Object val, ClassLoader classloader, String enc, boolean writeclass, Map<Class<?>, Set<String>> excludes) Convert to a byte array.static byte[]
objectToByteArray
(Object val, ClassLoader classloader, String enc, boolean writeclass, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a byte array.static String
objectToString
(Object val, ClassLoader classloader) Convert to a string.static String
objectToString
(Object val, ClassLoader classloader, boolean writeclass) Convert to a string.static String
objectToString
(Object val, ClassLoader classloader, boolean writeclass, boolean writeid, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a string.static String
objectToString
(Object val, ClassLoader classloader, boolean writeclass, boolean writeid, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, Object usercontext, jadex.common.transformation.IStringConverter converter) Convert to a string.static String
objectToString
(Object val, ClassLoader classloader, boolean writeclass, Map<Class<?>, Set<String>> excludes) Convert to a string.static String
objectToString
(Object val, ClassLoader classloader, boolean writeclass, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a string.static String
objectToString
(Object val, ClassLoader classloader, boolean writeclass, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a string.static String
prettifyJson
(String json) Prettifies a JSON source.Methods inherited from class jadex.common.transformation.traverser.Traverser
convertBasicType, doTraverse, finalizeProcessing, getDefaultProcessors, getInstance, preemptProcessing, traverse, traverseObject, traverseObject, traverseObject, traverseObject
-
Field Details
-
CLASSNAME_MARKER
- See Also:
-
ID_MARKER
- See Also:
-
REFERENCE_MARKER
- See Also:
-
ARRAY_MARKER
- See Also:
-
COLLECTION_MARKER
- See Also:
-
writetraverser
protected static jadex.common.transformation.traverser.Traverser writetraverser -
readtraverser
-
writeprocs
-
readprocs
-
nestedreadprocs
-
-
Constructor Details
-
JsonTraverser
public JsonTraverser()
-
-
Method Details
-
findClazz
Find the class of an object.- Overrides:
findClazz
in classjadex.common.transformation.traverser.Traverser
- Parameters:
object
- The object.- Returns:
- The objects class.
-
findClazzOfJsonObject
public static Class<?> findClazzOfJsonObject(com.eclipsesource.json.JsonObject object, ClassLoader targetcl) Find the class of an object.- Parameters:
object
- The object.- Returns:
- The objects class.
-
getWriteTraverser
protected static jadex.common.transformation.traverser.Traverser getWriteTraverser()- Returns:
-
getReadTraverser
- Returns:
-
objectToByteArray
Convert to a byte array. -
objectToByteArray
Convert to a byte array. -
objectToByteArray
public static byte[] objectToByteArray(Object val, ClassLoader classloader, String enc, boolean writeclass) Convert to a byte array. -
objectToByteArray
public static byte[] objectToByteArray(Object val, ClassLoader classloader, String enc, boolean writeclass, Map<Class<?>, Set<String>> excludes) Convert to a byte array. -
objectToByteArray
public static byte[] objectToByteArray(Object val, ClassLoader classloader, String enc, boolean writeclass, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a byte array. -
objectToByteArray
public static byte[] objectToByteArray(Object val, ClassLoader classloader, String enc, boolean writeclass, boolean writeid, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> conversionprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a byte array. -
objectToByteArray
public static byte[] objectToByteArray(Object val, ClassLoader classloader, String enc, boolean writeclass, boolean writeid, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> conversionprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, Object usercontext, jadex.common.transformation.IStringConverter converter) Convert to a byte array. -
objectToString
Convert to a string. -
objectToString
Convert to a string. -
objectToString
public static String objectToString(Object val, ClassLoader classloader, boolean writeclass, Map<Class<?>, Set<String>> excludes) Convert to a string. -
objectToString
public static String objectToString(Object val, ClassLoader classloader, boolean writeclass, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a string. -
objectToString
public static String objectToString(Object val, ClassLoader classloader, boolean writeclass, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a string. -
objectToString
public static String objectToString(Object val, ClassLoader classloader, boolean writeclass, boolean writeid, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert to a string. -
objectToString
public static String objectToString(Object val, ClassLoader classloader, boolean writeclass, boolean writeid, Map<Class<?>, Set<String>> excludes, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, Object usercontext, jadex.common.transformation.IStringConverter converter) Convert to a string. -
objectFromByteArray
Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromByteArray
Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromByteArray
public static Object objectFromByteArray(byte[] val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep) Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromByteArray
public static <T> T objectFromByteArray(byte[] val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, String enc, Class<T> clazz) Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromByteArray
public static <T> T objectFromByteArray(byte[] val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, String enc, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> procs, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocs) Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromByteArray
public static <T> T objectFromByteArray(byte[] val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, String enc, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> procs, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocs, Object usercontext, jadex.common.transformation.IStringConverter converter) Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromString
Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromString
public static <T> T objectFromString(String val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, Class<T> clazz) Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromString
public static <T> T objectFromString(String val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> processors) Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromString
public static <T> T objectFromString(String val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocessors) Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
objectFromString
public static <T> T objectFromString(String val, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter rep, Class<T> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocessors, Object usercontext, jadex.common.transformation.IStringConverter converter) Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
prettifyJson
Prettifies a JSON source.- Parameters:
json
- The JSON.- Returns:
- Prettified JSON or the original JSON on error.
-
getDefaultReadProcessorsCopy
public static List<jadex.common.transformation.traverser.ITraverseProcessor> getDefaultReadProcessorsCopy()Get a copy of the default read processors.- Returns:
- A copy of the read processor list.
-
getDefaultWriteProcessorsCopy
public static List<jadex.common.transformation.traverser.ITraverseProcessor> getDefaultWriteProcessorsCopy()Get a copy of the default read processors.- Returns:
- A copy of the read processor list.
-