Class JadexJsonSerializer

  • All Implemented Interfaces:
    ISerializer, IStringConverter

    public class JadexJsonSerializer
    extends java.lang.Object
    implements ISerializer, IStringConverter
    The Jadex JSON serializer. Codec supports parallel calls of multiple concurrent clients (no method synchronization necessary). Converts object -> byte[] and byte[] -> object.
    • Constructor Detail

      • JadexJsonSerializer

        public JadexJsonSerializer()
        Create a new serializer.
    • Method Detail

      • getSerializerId

        public int getSerializerId()
        Get the serializer id.
        Specified by:
        getSerializerId in interface ISerializer
        Returns:
        The serializer id.
      • encode

        public byte[] encode​(java.lang.Object val,
                             java.lang.ClassLoader classloader,
                             ITraverseProcessor[] preprocs,
                             java.lang.Object usercontext)
        Encode data with the serializer.
        Specified by:
        encode in interface ISerializer
        Parameters:
        val - The value.
        classloader - The classloader.
        preproc - The encoding preprocessors.
        Returns:
        The encoded object.
      • decode

        public java.lang.Object decode​(byte[] bytes,
                                       java.lang.ClassLoader classloader,
                                       ITraverseProcessor[] postprocs,
                                       IErrorReporter rep,
                                       java.lang.Object usercontext)
        Decode an object.
        Specified by:
        decode in interface ISerializer
        Parameters:
        bytes - The value bytes as byte array or input stream.
        Returns:
        The decoded object.
        Throws:
        java.io.IOException
      • decode

        public java.lang.Object decode​(java.io.InputStream is,
                                       java.lang.ClassLoader classloader,
                                       ITraverseProcessor[] postprocs,
                                       IErrorReporter rep,
                                       java.lang.Object usercontext)
        Decode an object.
        Specified by:
        decode in interface ISerializer
        Returns:
        The decoded object.
        Throws:
        java.io.IOException
      • convertString

        public java.lang.Object convertString​(java.lang.String val,
                                              java.lang.Class<?> type,
                                              java.lang.ClassLoader cl,
                                              java.lang.Object context)
        Convert a string to an object.
        Specified by:
        convertString in interface IStringConverter
        Parameters:
        val - The string.
        type - The target type.
        context - The context.
        Returns:
        The object.
      • convertObject

        public java.lang.String convertObject​(java.lang.Object val,
                                              java.lang.Class<?> type,
                                              java.lang.ClassLoader cl,
                                              java.lang.Object context)
        Convert an object to a string.
        Specified by:
        convertObject in interface IStringConverter
        Parameters:
        val - The object.
        type - The encoding type.
        context - The context.
        Returns:
        The object.
      • getType

        public java.lang.String getType()
        Get the type of string that can be processed (xml, json, plain).
        Specified by:
        getType in interface IStringConverter
        Returns:
        The object.
      • isSupportedType

        public boolean isSupportedType​(java.lang.Class<?> clazz)
        Test if the type can be converted.
        Specified by:
        isSupportedType in interface IStringConverter
        Parameters:
        clazz - The class.
        Returns:
        True if can be converted.