Class Serializer


  • public class Serializer
    extends Object
    The Serializer class writes data output and handles the data according to the core data types
    Author:
    The Red5 Project, Luke Hubbard, Codegent Ltd (luke@codegent.com), Harald Radi (harald.radi@nme.at), Paul Gregoire (mondain@gmail.com)
    • Field Detail

      • log

        protected static org.slf4j.Logger log
    • Method Detail

      • serialize

        public static void serialize​(Output out,
                                     Object any)
        Serializes output to a core data type object
        Parameters:
        out - Output writer
        any - Object to serialize
      • serialize

        public static void serialize​(Output out,
                                     Field field,
                                     Method getter,
                                     Object object,
                                     Object value)
        Serializes output to a core data type object
        Parameters:
        out - Output writer
        field - The field to serialize
        getter - The getter method if not a field
        object - Parent object
        value - Object to serialize
      • writeBasic

        protected static boolean writeBasic​(Output out,
                                            Object basic)
        Writes a primitive out as an object
        Parameters:
        out - Output writer
        basic - Primitive
        Returns:
        boolean true if object was successfully serialized, false otherwise
      • writeComplex

        public static boolean writeComplex​(Output out,
                                           Object complex)
        Writes a complex type object out
        Parameters:
        out - Output writer
        complex - Complex datatype object
        Returns:
        boolean true if object was successfully serialized, false otherwise
      • writeListType

        protected static boolean writeListType​(Output out,
                                               Object listType)
        Writes Lists out as a data type
        Parameters:
        out - Output write
        listType - List type
        Returns:
        boolean true if object was successfully serialized, false otherwise
      • writeList

        protected static void writeList​(Output out,
                                        List<?> list)
        Writes a List out as an Object
        Parameters:
        out - Output writer
        list - List to write as Object
      • writeArrayType

        protected static boolean writeArrayType​(Output out,
                                                Object arrType)
        Writes array (or collection) out as output Arrays, Collections, etc
        Parameters:
        out - Output object
        arrType - Array or collection type
        Returns:
        true if the object has been written, otherwise false
      • writeIterator

        protected static void writeIterator​(Output out,
                                            Iterator<Object> it)
        Writes an iterator out to the output
        Parameters:
        out - Output writer
        it - Iterator to write
      • writeXMLType

        protected static boolean writeXMLType​(Output out,
                                              Object xml)
        Writes an xml type out to the output
        Parameters:
        out - Output writer
        xml - XML
        Returns:
        boolean true if object was successfully written, false otherwise
      • writeDocument

        protected static void writeDocument​(Output out,
                                            Document doc)
        Writes a document to the output
        Parameters:
        out - Output writer
        doc - Document to write
      • writeObjectType

        protected static boolean writeObjectType​(Output out,
                                                 Object obj)
        Write typed object to the output
        Parameters:
        out - Output writer
        obj - Object type to write
        Returns:
        true if the object has been written, otherwise false
      • writeCustomType

        protected static boolean writeCustomType​(Output out,
                                                 Object obj)
        Writes a custom data to the output
        Parameters:
        out - Output writer
        obj - Custom data
        Returns:
        true if the object has been written, otherwise false
      • serializeField

        public static boolean serializeField​(String keyName,
                                             Field field,
                                             Method getter)
        Checks whether the field should be serialized or not
        Parameters:
        keyName - key name
        field - The field to be serialized
        getter - Getter method for field
        Returns:
        true if the field should be serialized, otherwise false
      • getClassName

        public static String getClassName​(Class<?> objectClass)
        Handles classes by name, also provides "shortened" class aliases where appropriate.
        Parameters:
        objectClass - class
        Returns:
        class name for given object