Class AMFDataItem


  • public class AMFDataItem
    extends AMFData

    AMFDataItem: class for marshalling data between Wowza Pro server and Flash client. The type wraps native Java data types.

    • DATA_TYPE_NUMBER = int, long, short, double, float
    • DATA_TYPE_STRING = String
    • DATA_TYPE_BOOLEAN = boolean
    • DATA_TYPE_DATE = Date
    • DATA_TYPE_NULL = 'null'

    Create Native Java Types

    AMFDataItem amfDataString = new AMFDataItem("here is my string"); // String
    AMFDataItem amfDataLong = new AMFDataItem(1234L); // long
    AMFDataItem amfDataDouble = new AMFDataItem(1.234); // double
    AMFDataItem amfDataBoolean = new AMFDataItem(true); // boolean
    AMFDataItem amfDataNull = new AMFDataItem(); // null
    

    Get Native Java Types

    String dataString = amfDataString.getType()==AMFData.DATA_TYPE_LONG_STRING?
                          amfDataString.toString():"";
                                                    
    long dataLong = amfDataLong.getType()==AMFData.DATA_TYPE_NUMBER?
                      amfDataLong.longValue():0;
                                                    
    double dataDouble = amfDataDouble.getType()==AMFData.DATA_TYPE_NUMBER?
                          amfDataLong.doubleValue():0.0;
                                                    
    boolean dataBoolean = amfDataBoolean.getType()==AMFData.DATA_TYPE_BOOLEAN?
                            amfDataLong.booleanValue():false;
                                                    
    Object dataNull = amfDataNull.getType()==AMFData.DATA_TYPE_NULL?
                        null:null;
    
    • Field Detail

      • fastDateFormat

        protected org.apache.commons.lang.time.FastDateFormat fastDateFormat
    • Constructor Detail

      • AMFDataItem

        public AMFDataItem()
        Construct AMF type DATA_TYPE_NULL object
      • AMFDataItem

        public AMFDataItem​(String value)
        Construct AMF type DATA_TYPE_STRING object
        Parameters:
        value - String value
      • AMFDataItem

        public AMFDataItem​(int value)
        Construct AMF type DATA_TYPE_NUMBER object
        Parameters:
        value - int value
      • AMFDataItem

        public AMFDataItem​(long value)
        Construct AMF type DATA_TYPE_NUMBER object
        Parameters:
        value - long value
      • AMFDataItem

        public AMFDataItem​(double value)
        Construct AMF type DATA_TYPE_NUMBER object
        Parameters:
        value - double value
      • AMFDataItem

        public AMFDataItem​(boolean value)
        Construct AMF type DATA_TYPE_BOOLEAN
        Parameters:
        value - boolean value
      • AMFDataItem

        public AMFDataItem​(java.util.Date value)
        Construct AMF type DATA_TYPE_DATE
        Parameters:
        value - Date value
      • AMFDataItem

        public AMFDataItem​(byte[] data)
        Deserialize entire data array and create AMFDataItem object
        Parameters:
        data - binary data
      • AMFDataItem

        public AMFDataItem​(byte[] data,
                           int offset,
                           int size)
        Deserialize data array starting at offest for size bytes and create AMFDataItem object
        Parameters:
        data - binary data
        offset - starting offset into data
        size - size of data to deserialize
      • AMFDataItem

        public AMFDataItem​(java.nio.ByteBuffer data)
        Deserialize entire data array and create AMFDataItem object
        Parameters:
        data - binary data
    • Method Detail

      • longValue

        public long longValue()
        Return object as long. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.
        Returns:
        long value or 0 if failure
      • intValue

        public int intValue()
        Return object as int. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.
        Returns:
        int value or 0 if failure
      • doubleValue

        public double doubleValue()
        Return object as double. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.
        Returns:
        double value or 0 if failure
      • floatValue

        public float floatValue()
        Return object as float. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.
        Returns:
        float value or 0 if failure
      • shortValue

        public short shortValue()
        Return object as short. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.
        Returns:
        short value or 0 if failure
      • byteValue

        public byte byteValue()
        Return object as byte. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.
        Returns:
        byte value or 0 if failure
      • dateValue

        public java.util.Date dateValue()
        Return object as Date. Valid object types are DATA_TYPE_DATE.
        Returns:
        Date value or null if failure
      • booleanValue

        public boolean booleanValue()
        Return object as boolean. Valid object types are DATA_TYPE_BOOLEAN and DATA_TYPE_STRING.
        Returns:
        boolean value or false if failure
      • deserialize

        public void deserialize​(java.nio.ByteBuffer data)
        Description copied from class: AMFData
        Deserialize data in byte buffer
        Specified by:
        deserialize in class AMFData
        Parameters:
        data - binary data
      • deserialize

        public void deserialize​(java.nio.ByteBuffer data,
                                AMFDataContextDeserialize context)
        Description copied from class: AMFData
        Deserialize data in byte buffer
        Specified by:
        deserialize in class AMFData
        Parameters:
        data - binary data
        context - deserialization context used by AMF3
      • getValue

        public Object getValue()
        Return value as Java class
        Specified by:
        getValue in class AMFData
        Returns:
        java native class
      • toString

        public String toString()
        Return object as formatted string
        Overrides:
        toString in class Object
      • serialize

        public void serialize​(java.io.DataOutputStream out)
        Description copied from class: AMFData
        Serialize object to output stream
        Specified by:
        serialize in class AMFData
        Parameters:
        out - Output stream
      • serialize

        public void serialize​(java.io.DataOutputStream out,
                              int objectEncoding)
        Description copied from class: AMFData
        Serialize object to output stream
        Specified by:
        serialize in class AMFData
        Parameters:
        out - Output stream
        objectEncoding - object encoding level (see AMF_LEVEL*)
      • serialize

        public void serialize​(java.io.DataOutputStream out,
                              AMFDataContextSerialize context)
        Description copied from class: AMFData
        Serialize object to output stream
        Specified by:
        serialize in class AMFData
        Parameters:
        out - Output stream
        context - serialization context used by AMF3
      • serialize

        public byte[] serialize()
        Description copied from class: AMFData
        Serial object to byte array
        Specified by:
        serialize in class AMFData
        Returns:
        serialized byte array
      • serialize

        public byte[] serialize​(int objectEncoding)
        Description copied from class: AMFData
        Serial object to byte array
        Specified by:
        serialize in class AMFData
        Parameters:
        objectEncoding - object encoding level (see AMF_LEVEL*)
        Returns:
        serialized byte array
      • serialize

        public byte[] serialize​(AMFDataContextSerialize context)
        Description copied from class: AMFData
        Serial object to byte array
        Specified by:
        serialize in class AMFData
        Parameters:
        context - serialization context used by AMF3
        Returns:
        serialized byte array