Class AMFDataArray


  • public class AMFDataArray
    extends AMFData

    AMFDataArray: class for marshalling data between Wowza Pro server and Flash client. This class is a simple ordered array of items.

    Create Array of Strings

    AMFDataArray amfDataArray = new AMFDataArray();
    
    amfDataArray.add("item1");
    amfDataArray.add("item2");
    amfDataArray.add("item3");
    

    Iterate Items In Array

    AMFDataArray amfDataArray;
    
    for(int i=0;i<amfDataArray.size();i++)
    {
            AMFData amfData = amfDataArray.get(i);
            WMSLoggerFactory.getLogger(null).debug("amfData.getType(): "+amfData.getType());
    }
    

    NOTE: There is a slight difference between this class and AMFDataList. This class when serialized/deserialized does include the DATA_TYPE_ARRAY header (byte) and array size (int).

    NOTE: Simple arrays created in the Flash player client and sent to the Wowza Pro server are of type AMFDataMixedArray.

    • Constructor Detail

      • AMFDataArray

        public AMFDataArray()
        Create empty AMFDataArray object
      • AMFDataArray

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

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

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

      • remove

        public AMFData remove​(int index)
        Remove an item from the array
        Parameters:
        index - index
        Returns:
        delete item or null if not found
      • size

        public int size()
        Returns the number of items in array
        Returns:
        number of items in array
      • add

        public void add​(AMFData data)
        Append a new item onto the array
        Parameters:
        data - AMFData object
      • add

        public void add​(String data)
        Append a string (will be wrapped in an AMFDataItem object)
        Parameters:
        data - string value
      • add

        public void add​(double data)
        Append a double (will be wrapped in an AMFDataItem object)
        Parameters:
        data - double value
      • add

        public void add​(int data)
        Append a int (will be wrapped in an AMFDataItem object)
        Parameters:
        data - int value
      • add

        public void add​(long data)
        Append a long (will be wrapped in an AMFDataItem object)
        Parameters:
        data - long value
      • add

        public void add​(java.util.Date data)
        Append a date (will be wrapped in an AMFDataItem object)
        Parameters:
        data - date value
      • add

        public void add​(boolean data)
        Append a boolean (will be wrapped in an AMFDataItem object)
        Parameters:
        data - boolean value
      • add

        public void add​(int index,
                        AMFData data)
        Insert an item into the array
        Parameters:
        index - index
        data - AMFData object
      • add

        public void add​(int index,
                        String data)
        Insert a string value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - string value
      • add

        public void add​(int index,
                        double data)
        Insert a double value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - double value
      • add

        public void add​(int index,
                        int data)
        Insert a int value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - int value
      • add

        public void add​(int index,
                        long data)
        Insert a long value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - long value
      • add

        public void add​(int index,
                        java.util.Date data)
        Insert a date value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - date value
      • add

        public void add​(int index,
                        boolean data)
        Insert a boolean value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - boolean value
      • set

        public void set​(int index,
                        AMFData data)
        Set an array item
        Parameters:
        index - index
        data - AMFData object
      • set

        public void set​(int index,
                        String data)
        Set an string value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - string value
      • set

        public void set​(int index,
                        double data)
        Set an double value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - double value
      • set

        public void set​(int index,
                        int data)
        Set an int value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - int value
      • set

        public void set​(int index,
                        long data)
        Set an long value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - long value
      • set

        public void set​(int index,
                        java.util.Date data)
        Set an date value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - date value
      • set

        public void set​(int index,
                        boolean data)
        Set an boolean value (will be wrapped in an AMFDataItem object)
        Parameters:
        index - index
        data - boolean value
      • get

        public AMFData get​(int index)
        Get item at index
        Parameters:
        index -
        Returns:
        Returns AMFData object or null if out of bounds
      • getString

        public String getString​(int index)
        Get item at index return as String
        Parameters:
        index -
        Returns:
        Return item as String or null if out of bounds
      • getInt

        public int getInt​(int index)
        Get item at index return as int
        Parameters:
        index -
        Returns:
        Return item as int or 0 if out of bounds
      • getLong

        public long getLong​(int index)
        Get item at index return as long
        Parameters:
        index -
        Returns:
        Return item as long or 0 if out of bounds
      • getShort

        public short getShort​(int index)
        Get item at index return as short
        Parameters:
        index -
        Returns:
        Return item as short or 0 if out of bounds
      • getByte

        public byte getByte​(int index)
        Get item at index return as byte
        Parameters:
        index -
        Returns:
        Return item as byte or 0 if out of bounds
      • getBoolean

        public boolean getBoolean​(int index)
        Get item at index return as boolean
        Parameters:
        index -
        Returns:
        Return item as boolean or false if out of bounds
      • getDate

        public java.util.Date getDate​(int index)
        Get item at index return as Date
        Parameters:
        index -
        Returns:
        Return item as Date or null if out of bounds
      • getObject

        public AMFDataObj getObject​(int index)
        Get item at index return as AMFDataObj
        Parameters:
        index -
        Returns:
        Return item as AMFDataObj or null if out of bounds
      • getDouble

        public double getDouble​(int index)
        Get item at index return as double
        Parameters:
        index -
        Returns:
        Return item as double or 0 if out of bounds
      • getFloat

        public float getFloat​(int index)
        Get item at index return as float
        Parameters:
        index -
        Returns:
        Return item as float or 0 if out of bounds
      • 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
      • 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
      • getValue

        public Object getValue()
        Description copied from class: AMFData
        Convert object to Java native 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