com.supermap.services.rest.decoders

Class ObjectStreamDecoder



  • public class ObjectStreamDecoder
    extends Decoder
    

    Java object stream decoder.

    Converts a binary Java data stream to a Java object.

    • Method Summary

      Methods 
      Modifier and Type Method and Description
      protected java.util.List<MediaType> createSupportedMediaTypes()
      Creates a list of supported media types.
      java.util.List toList(java.lang.String text, java.lang.Class elementClass)
      Converts a binary stream string to a list object.
      java.util.Map<java.lang.String,java.lang.Object> toMap(java.lang.String str, java.util.Map<java.lang.String,java.lang.Class> nameClassMapping)
      Converts a binary stream string to a map set.
      java.lang.Object toObject(java.lang.String str, java.lang.Class cl)
      Converts a binary stream string to a Java object.
      java.util.Set toSet(java.lang.String text, java.lang.Class elementClass)
      Converts a binary stream string to a Set object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ObjectStreamDecoder

        public ObjectStreamDecoder()
        
    • Method Detail

      • toObject

        public java.lang.Object toObject(java.lang.String str,
                                java.lang.Class cl)
        

        Converts a binary stream string to a Java object.

        Specified by:
        toObject in class Decoder
        Parameters:
        str - wants to convert the binary stream string.
        cl - The target class, which converts the JSON string into what type of object.
        Returns:
        converted object.
        Throws:
        java.lang.Exception - java abnormal.
      • toMap

        public java.util.Map<java.lang.String,java.lang.Object> toMap(java.lang.String str,
                                                             java.util.Map<java.lang.String,java.lang.Class> nameClassMapping)
        

        Converts a binary stream string to a map set.

        Specified by:
        toMap in class Decoder
        Parameters:
        str - wants to convert the binary stream string.
        nameClassMapping - java.util.Map mapping set. Where the key is the field name and the value is the type of the field.
        Returns:
        mapping set.
      • toList

        public java.util.List toList(java.lang.String text,
                            java.lang.Class elementClass)
                              throws java.lang.Exception
        

        Converts a binary stream string to a list object.

        Specified by:
        toList in class Decoder
        Parameters:
        text - wants to convert the binary stream string.
        elementClass - The class to which the list element belongs.
        Returns:
        List Object.
        Throws:
        java.lang.Exception - An exception is thrown when the argument (text or elementClass) is null.
      • toSet

        public java.util.Set toSet(java.lang.String text,
                          java.lang.Class elementClass)
                            throws java.lang.Exception
        

        Converts a binary stream string to a Set object.

        Specified by:
        toSet in class Decoder
        Parameters:
        text - wants to convert the binary stream string.
        elementClass - Set The class to which the element belongs.
        Returns:
        after conversion of the collection object.
        Throws:
        java.lang.Exception - java abnormal.
      • createSupportedMediaTypes

        protected java.util.List<MediaType> createSupportedMediaTypes()
        

        Creates a list of supported media types.

        That is, when the request is one of the media types, by the decoder to identify and convert.

        Specified by:
        createSupportedMediaTypes in class Decoder
        Returns:
        media type list.