Class JsonTraverser
- java.lang.Object
-
- jadex.commons.transformation.traverser.Traverser
-
- jadex.transformation.jsonserializer.JsonTraverser
-
public class JsonTraverser extends 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.commons.transformation.traverser.Traverser
Traverser.MODE
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARRAY_MARKER
static java.lang.String
CLASSNAME_MARKER
static java.lang.String
COLLECTION_MARKER
static java.lang.String
ID_MARKER
static java.util.List<ITraverseProcessor>
nestedreadprocs
static java.util.List<ITraverseProcessor>
readprocs
protected static JsonTraverser
readtraverser
static java.lang.String
REFERENCE_MARKER
static java.util.List<ITraverseProcessor>
writeprocs
protected static Traverser
writetraverser
-
Fields inherited from class jadex.commons.transformation.traverser.Traverser
IGNORE_RESULT, instance, processorcache, processors
-
-
Constructor Summary
Constructors Constructor Description JsonTraverser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<?>
findClazz(java.lang.Object object, java.lang.ClassLoader targetcl)
Find the class of an object.static java.lang.Class<?>
findClazzOfJsonObject(com.eclipsesource.json.JsonObject object, java.lang.ClassLoader targetcl)
Find the class of an object.static java.util.List<ITraverseProcessor>
getDefaultReadProcessorsCopy()
Get a copy of the default read processors.static java.util.List<ITraverseProcessor>
getDefaultWriteProcessorsCopy()
Get a copy of the default read processors.protected static JsonTraverser
getReadTraverser()
protected static Traverser
getWriteTraverser()
static java.lang.Object
objectFromByteArray(byte[] val, java.lang.ClassLoader classloader)
Convert a byte array (of an xml) to an object.static java.lang.Object
objectFromByteArray(byte[] val, java.lang.ClassLoader classloader, IErrorReporter rep)
Convert a byte array (of an xml) to an object.static <T> T
objectFromByteArray(byte[] val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.String enc, java.lang.Class<T> clazz)
Convert a byte array (of an xml) to an object.static <T> T
objectFromByteArray(byte[] val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.String enc, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> procs, java.util.List<ITraverseProcessor> postprocs)
Convert a byte array (of an xml) to an object.static <T> T
objectFromByteArray(byte[] val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.String enc, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> procs, java.util.List<ITraverseProcessor> postprocs, java.lang.Object usercontext)
Convert a byte array (of an xml) to an object.static java.lang.Object
objectFromByteArray(byte[] val, java.lang.ClassLoader classloader, java.lang.String enc)
Convert a byte array (of an xml) to an object.static <T> T
objectFromString(java.lang.String val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.Class<T> clazz)
Convert a byte array (of an xml) to an object.static <T> T
objectFromString(java.lang.String val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> processors)
Convert a byte array (of an xml) to an object.static <T> T
objectFromString(java.lang.String val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> processors, java.util.List<ITraverseProcessor> postprocessors)
Convert a byte array (of an xml) to an object.static <T> T
objectFromString(java.lang.String val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> processors, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext)
Convert a byte array (of an xml) to an object.static <T> T
objectFromString(java.lang.String val, java.lang.ClassLoader classloader, java.lang.Class<T> clazz)
Convert a byte array (of an xml) to an object.static byte[]
objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader)
Convert to a byte array.static byte[]
objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc)
Convert to a byte array.static byte[]
objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass)
Convert to a byte array.static byte[]
objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> conversionprocessors, java.util.List<ITraverseProcessor> processors)
Convert to a byte array.static byte[]
objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> conversionprocessors, java.util.List<ITraverseProcessor> processors, java.lang.Object usercontext)
Convert to a byte array.static byte[]
objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)
Convert to a byte array.static byte[]
objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> processors)
Convert to a byte array.static java.lang.String
objectToString(java.lang.Object val, java.lang.ClassLoader classloader)
Convert to a string.static java.lang.String
objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass)
Convert to a string.static java.lang.String
objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> processors)
Convert to a string.static java.lang.String
objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> processors, java.lang.Object usercontext)
Convert to a string.static java.lang.String
objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)
Convert to a string.static java.lang.String
objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> processors)
Convert to a string.static java.lang.String
objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> processors)
Convert to a string.static java.lang.String
prettifyJson(java.lang.String json)
Prettifies a JSON source.-
Methods inherited from class jadex.commons.transformation.traverser.Traverser
doTraverse, finalizeProcessing, getDefaultProcessors, getInstance, preemptProcessing, traverse, traverseObject, traverseObject, traverseObject, traverseObject
-
-
-
-
Field Detail
-
CLASSNAME_MARKER
public static final java.lang.String CLASSNAME_MARKER
- See Also:
- Constant Field Values
-
ID_MARKER
public static final java.lang.String ID_MARKER
- See Also:
- Constant Field Values
-
REFERENCE_MARKER
public static final java.lang.String REFERENCE_MARKER
- See Also:
- Constant Field Values
-
ARRAY_MARKER
public static final java.lang.String ARRAY_MARKER
- See Also:
- Constant Field Values
-
COLLECTION_MARKER
public static final java.lang.String COLLECTION_MARKER
- See Also:
- Constant Field Values
-
writetraverser
protected static Traverser writetraverser
-
readtraverser
protected static JsonTraverser readtraverser
-
writeprocs
public static java.util.List<ITraverseProcessor> writeprocs
-
readprocs
public static java.util.List<ITraverseProcessor> readprocs
-
nestedreadprocs
public static java.util.List<ITraverseProcessor> nestedreadprocs
-
-
Method Detail
-
findClazz
public java.lang.Class<?> findClazz(java.lang.Object object, java.lang.ClassLoader targetcl)
Find the class of an object.
-
findClazzOfJsonObject
public static java.lang.Class<?> findClazzOfJsonObject(com.eclipsesource.json.JsonObject object, java.lang.ClassLoader targetcl)
Find the class of an object.- Parameters:
object
- The object.- Returns:
- The objects class.
-
getWriteTraverser
protected static Traverser getWriteTraverser()
- Returns:
-
getReadTraverser
protected static JsonTraverser getReadTraverser()
- Returns:
-
objectToByteArray
public static byte[] objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader)
Convert to a byte array.
-
objectToByteArray
public static byte[] objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc)
Convert to a byte array.
-
objectToByteArray
public static byte[] objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass)
Convert to a byte array.
-
objectToByteArray
public static byte[] objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)
Convert to a byte array.
-
objectToByteArray
public static byte[] objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> processors)
Convert to a byte array.
-
objectToByteArray
public static byte[] objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> conversionprocessors, java.util.List<ITraverseProcessor> processors)
Convert to a byte array.
-
objectToByteArray
public static byte[] objectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader, java.lang.String enc, boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> conversionprocessors, java.util.List<ITraverseProcessor> processors, java.lang.Object usercontext)
Convert to a byte array.
-
objectToString
public static java.lang.String objectToString(java.lang.Object val, java.lang.ClassLoader classloader)
Convert to a string.
-
objectToString
public static java.lang.String objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass)
Convert to a string.
-
objectToString
public static java.lang.String objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)
Convert to a string.
-
objectToString
public static java.lang.String objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> processors)
Convert to a string.
-
objectToString
public static java.lang.String objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> processors)
Convert to a string.
-
objectToString
public static java.lang.String objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> processors)
Convert to a string.
-
objectToString
public static java.lang.String objectToString(java.lang.Object val, java.lang.ClassLoader classloader, boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> processors, java.lang.Object usercontext)
Convert to a string.
-
objectFromByteArray
public static java.lang.Object objectFromByteArray(byte[] val, java.lang.ClassLoader classloader)
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 java.lang.Object objectFromByteArray(byte[] val, java.lang.ClassLoader classloader, java.lang.String enc)
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 java.lang.Object objectFromByteArray(byte[] val, java.lang.ClassLoader classloader, 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, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.String enc, java.lang.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, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.String enc, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> procs, java.util.List<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, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.String enc, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> procs, java.util.List<ITraverseProcessor> postprocs, java.lang.Object usercontext)
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(java.lang.String val, java.lang.ClassLoader classloader, java.lang.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(java.lang.String val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.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(java.lang.String val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.Class<T> clazz, java.util.List<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(java.lang.String val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> processors, java.util.List<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(java.lang.String val, java.lang.ClassLoader classloader, IErrorReporter rep, java.lang.Class<T> clazz, java.util.List<ITraverseProcessor> processors, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext)
Convert a byte array (of an xml) to an object.- Parameters:
val
- The byte array.classloader
- The class loader.- Returns:
- The decoded object.
-
prettifyJson
public static java.lang.String prettifyJson(java.lang.String json)
Prettifies a JSON source.- Parameters:
json
- The JSON.- Returns:
- Prettified JSON or the original JSON on error.
-
getDefaultReadProcessorsCopy
public static java.util.List<ITraverseProcessor> getDefaultReadProcessorsCopy()
Get a copy of the default read processors.- Returns:
- A copy of the read processor list.
-
getDefaultWriteProcessorsCopy
public static java.util.List<ITraverseProcessor> getDefaultWriteProcessorsCopy()
Get a copy of the default read processors.- Returns:
- A copy of the read processor list.
-
-