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
  • Field Details

    • CLASSNAME_MARKER

      public static final String CLASSNAME_MARKER
      See Also:
    • ID_MARKER

      public static final String ID_MARKER
      See Also:
    • REFERENCE_MARKER

      public static final String REFERENCE_MARKER
      See Also:
    • ARRAY_MARKER

      public static final String ARRAY_MARKER
      See Also:
    • COLLECTION_MARKER

      public static final String COLLECTION_MARKER
      See Also:
    • writetraverser

      protected static jadex.common.transformation.traverser.Traverser writetraverser
    • readtraverser

      protected static JsonTraverser readtraverser
    • writeprocs

      public static List<jadex.common.transformation.traverser.ITraverseProcessor> writeprocs
    • readprocs

      public static List<jadex.common.transformation.traverser.ITraverseProcessor> readprocs
    • nestedreadprocs

      public static List<jadex.common.transformation.traverser.ITraverseProcessor> nestedreadprocs
  • Constructor Details

    • JsonTraverser

      public JsonTraverser()
  • Method Details

    • findClazz

      public Class<?> findClazz(Object object, ClassLoader targetcl)
      Find the class of an object.
      Overrides:
      findClazz in class jadex.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

      protected static JsonTraverser getReadTraverser()
      Returns:
    • objectToByteArray

      public static byte[] objectToByteArray(Object val, ClassLoader classloader)
      Convert to a byte array.
    • objectToByteArray

      public static byte[] objectToByteArray(Object val, ClassLoader classloader, String enc)
      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

      public static String objectToString(Object val, ClassLoader classloader)
      Convert to a string.
    • objectToString

      public static String objectToString(Object val, ClassLoader classloader, boolean writeclass)
      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

      public static Object objectFromByteArray(byte[] val, 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 Object objectFromByteArray(byte[] val, ClassLoader classloader, 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 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

      public static <T> T objectFromString(String val, ClassLoader classloader, 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)
      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

      public static String prettifyJson(String json)
      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.