Class AMFDataObj

Object
com.wowza.wms.amf.AMFData
com.wowza.wms.amf.AMFDataObj
All Implemented Interfaces:
IAMFDataObj
Direct Known Subclasses:
AMFDataMixedArray

public class AMFDataObj extends AMFData implements IAMFDataObj

AMFDataObj: class for marshalling data between Wowza Pro server and Flash client. Object with attributes. Implementation is very similar to a java.util.Map. Each parameter is an item in the map.

Create AMFDataObj

AMFDataObj amfDataObj = new AMFDataObj();

amfDataObj.put("key1", "item1");
amfDataObj.put("key2", "item2");
amfDataObj.put("key3", "item3");

Iterate AMFDataObj

AMFDataObj amfDataObj;

List keys = amfDataObj.getKeys();
Iterator iter = keys.iterator();
while(iter.hasNext())
{
        String key = (String)iter.next();
        AMFData value = amfDataObj.get(key);
        int itemType = value.getType();
        WMSLoggerFactory.getLogger(null).debug(key+"="+value.toString()+" (type:"+itemType+")");
}

Direct Access To Attributes

AMFDataObj amfDataObj;

// If you know the type you can access it directly
String dataString = amfDataObj.getString("stringData");
long dataLong = amfDataObj.getLong("longData");
double dataDouble = amfDataObj.getDouble("doubleData");
boolean dataBoolean = amfDataObj.getBoolean("booleanData");

// This illustrate how to decode the value if
// you don't know the type
AMFData myItemKey1 = amfDataObj.get("theData");
switch (myItemKey1.getType())
{
default:
case AMFDataItem.DATA_TYPE_UNDEFINED:
case AMFDataItem.DATA_TYPE_UNKNOWN:
case AMFDataItem.DATA_TYPE_NULL:
        // the value is null or undefined
        break;
case AMFDataItem.DATA_TYPE_NUMBER:
        double amfDataDouble = ((AMFDataItem)myItemKey1).doubleValue();
        break;
case AMFDataItem.DATA_TYPE_BOOLEAN:
        boolean amfDataBoolean = ((AMFDataItem)myItemKey1).booleanValue();
        break;
case AMFDataItem.DATA_TYPE_STRING:
        String amfDataString = ((AMFDataItem)myItemKey1).toString();
        break;
case AMFDataItem.DATA_TYPE_DATE:
        Date amfDataDate = ((AMFDataItem)myItemKey1).dateValue();
        break;
case AMFDataItem.DATA_TYPE_OBJECT:
        AMFDataObj amfDataValObj = (AMFDataObj)myItemKey1;
        break;
case AMFDataItem.DATA_TYPE_MIXED_ARRAY:
        AMFDataMixedArray amfDataMixedArray = (AMFDataMixedArray)myItemKey1;
        break;
case AMFDataItem.DATA_TYPE_ARRAY:
        AMFDataArray amfDataArray = (AMFDataArray)myItemKey1;
        break;
}
  • Field Details

  • Constructor Details

    • AMFDataObj

      public AMFDataObj()
      Create empty AMFDataObj object
    • AMFDataObj

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

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

      public AMFDataObj(ByteBuffer data)
      Deserialize entire data array and create AMFDataObj object
      Parameters:
      data - binary data
    • AMFDataObj

      public AMFDataObj(ByteBuffer data, AMFDataContextDeserialize context)
  • Method Details

    • size

      public int size()
      Return the number of members of this object/array
      Returns:
      number of members
    • containsKey

      public boolean containsKey(String name)
      Description copied from interface: IAMFDataObj
      Return true if the object/array contains key
      Specified by:
      containsKey in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return true the object/array contains key
    • put

      public void put(String name, AMFData data)
      Description copied from interface: IAMFDataObj
      Put or replace object at key
      Specified by:
      put in interface IAMFDataObj
      Parameters:
      name - key
      data - object
    • put

      public void put(String name, String data)
      Description copied from interface: IAMFDataObj
      Put or replace string value at key (data will be wrapped in an AMFDataItem object)
      Specified by:
      put in interface IAMFDataObj
      Parameters:
      name - key
      data - string value
    • put

      public void put(String name, double data)
      Description copied from interface: IAMFDataObj
      Put or replace double value at key (data will be wrapped in an AMFDataItem object)
      Specified by:
      put in interface IAMFDataObj
      Parameters:
      name - key
      data - double value
    • put

      public void put(String name, int data)
      Description copied from interface: IAMFDataObj
      Put or replace int value at key (data will be wrapped in an AMFDataItem object)
      Specified by:
      put in interface IAMFDataObj
      Parameters:
      name - key
      data - int value
    • put

      public void put(String name, long data)
      Description copied from interface: IAMFDataObj
      Put or replace long value at key (data will be wrapped in an AMFDataItem object)
      Specified by:
      put in interface IAMFDataObj
      Parameters:
      name - key
      data - long value
    • put

      public void put(String name, Date data)
      Description copied from interface: IAMFDataObj
      Put or replace date value at key (data will be wrapped in an AMFDataItem object)
      Specified by:
      put in interface IAMFDataObj
      Parameters:
      name - key
      data - date value
    • put

      public void put(String name, boolean data)
      Description copied from interface: IAMFDataObj
      Put or replace boolean value at key (data will be wrapped in an AMFDataItem object)
      Specified by:
      put in interface IAMFDataObj
      Parameters:
      name - key
      data - boolean value
    • getKeys

      public List getKeys()
      Description copied from interface: IAMFDataObj
      Return a list of all the keys (the list is a copy)
      Specified by:
      getKeys in interface IAMFDataObj
      Returns:
      new list that contains one entry for each key
    • getKey

      public String getKey(int index)
      Description copied from interface: IAMFDataObj
      Return the key at a particular index.
      Specified by:
      getKey in interface IAMFDataObj
      Returns:
      Return key at index or null if out of bounds
    • get

      public AMFData get(String name)
      Description copied from interface: IAMFDataObj
      Return the object at a particular key.
      Specified by:
      get in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return object or null if out of bounds
    • get

      public AMFData get(int index)
      Description copied from interface: IAMFDataObj
      Return the object at a particular index.
      Specified by:
      get in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return object or null if out of bounds
    • remove

      public AMFData remove(String name)
      Description copied from interface: IAMFDataObj
      Remove element by key
      Specified by:
      remove in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      removed object or null if not found
    • remove

      public AMFData remove(int index)
      Description copied from interface: IAMFDataObj
      Remove element by index
      Specified by:
      remove in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      removed object or null if not found
    • getString

      public String getString(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as String
      Specified by:
      getString in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as String or null if out of bounds
    • getInt

      public int getInt(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as int
      Specified by:
      getInt in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as int or 0 if out of bounds
    • getLong

      public long getLong(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as long
      Specified by:
      getLong in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as long or 0 if out of bounds
    • getShort

      public short getShort(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as short
      Specified by:
      getShort in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as short or 0 if out of bounds
    • getDouble

      public double getDouble(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as double
      Specified by:
      getDouble in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as double or 0 if out of bounds
    • getFloat

      public float getFloat(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as float
      Specified by:
      getFloat in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as float or 0 if out of bounds
    • getByte

      public byte getByte(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as byte
      Specified by:
      getByte in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as byte or 0 if out of bounds
    • getBoolean

      public boolean getBoolean(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as boolean
      Specified by:
      getBoolean in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as boolean or false if out of bounds
    • getDate

      public Date getDate(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as Date
      Specified by:
      getDate in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as Date or null if out of bounds
    • getObject

      public AMFDataObj getObject(String name)
      Description copied from interface: IAMFDataObj
      Get item at key return as AMFDataObj
      Specified by:
      getObject in interface IAMFDataObj
      Parameters:
      name - key
      Returns:
      Return item as AMFDataObj or null if out of bounds
    • getString

      public String getString(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as String
      Specified by:
      getString in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as String or null if out of bounds
    • getInt

      public int getInt(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as int
      Specified by:
      getInt in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as int or 0 if out of bounds
    • getLong

      public long getLong(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as long
      Specified by:
      getLong in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as long or 0 if out of bounds
    • getShort

      public short getShort(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as short
      Specified by:
      getShort in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as short or 0 if out of bounds
    • getByte

      public byte getByte(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as byte
      Specified by:
      getByte in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as byte or 0 if out of bounds
    • getDouble

      public double getDouble(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as double
      Specified by:
      getDouble in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as double or 0 if out of bounds
    • getFloat

      public float getFloat(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as float
      Specified by:
      getFloat in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as float or 0 if out of bounds
    • getBoolean

      public boolean getBoolean(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as boolean
      Specified by:
      getBoolean in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as boolean or false if out of bounds
    • getDate

      public Date getDate(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as Date
      Specified by:
      getDate in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as Date or null if out of bounds
    • getObject

      public AMFDataObj getObject(int index)
      Description copied from interface: IAMFDataObj
      Get item at index return as AMFDataObj
      Specified by:
      getObject in interface IAMFDataObj
      Parameters:
      index - index
      Returns:
      Return item as AMFDataObj or null if out of bounds
    • deserialize

      public void deserialize(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(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(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(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(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
    • getClassName

      public String getClassName()
    • setClassName

      public void setClassName(String className)
    • getTrait

      public AMFDataTrait getTrait()
    • getSerializer

      public IAMFExternalizable getSerializer()
    • setSerializer

      public void setSerializer(IAMFExternalizable serializer)