com.wowza.wms.amf
Class AMFDataObj

Object
  extended by com.wowza.wms.amf.AMFData
      extended by com.wowza.wms.amf.AMFDataObj
Direct Known Subclasses:
AMFDataMixedArray

public class AMFDataObj
extends AMFData

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;
}

NOTE: A AMFDataObj is exactly the same as a AMFDataMixedArray except its type is DATA_TYPE_OBJECT.


Field Summary
static int DECODE_OBJ_REF
           
static int DECODE_TRAITS
           
static int DECODE_TRAITS_EXT
           
static int DECODE_TRAITS_REF
           
static int DECODE_UNDEFINED
           
protected  java.util.Map<String,AMFData> members
           
protected  java.util.List<String> order
           
protected  AMFDataTrait trait
           
 
Fields inherited from class com.wowza.wms.amf.AMFData
AMF_LEVEL0, AMF_LEVEL3, DATA_TYPE_AMF3, DATA_TYPE_AMF3_ARRAY, DATA_TYPE_AMF3_BOOLEAN_FALSE, DATA_TYPE_AMF3_BOOLEAN_TRUE, DATA_TYPE_AMF3_BYTEARRAY, DATA_TYPE_AMF3_DATE, DATA_TYPE_AMF3_INTEGER, DATA_TYPE_AMF3_NULL, DATA_TYPE_AMF3_NUMBER, DATA_TYPE_AMF3_OBJECT, DATA_TYPE_AMF3_STRING, DATA_TYPE_AMF3_UNDEFINED, DATA_TYPE_AMF3_XML_LEGACY, DATA_TYPE_AMF3_XML_TOP, DATA_TYPE_ARRAY, DATA_TYPE_AS_OBJECT, DATA_TYPE_BOOLEAN, DATA_TYPE_BYTEARRAY, DATA_TYPE_CUSTOM_CLASS, DATA_TYPE_DATE, DATA_TYPE_INTEGER, DATA_TYPE_LONG_STRING, DATA_TYPE_MIXED_ARRAY, DATA_TYPE_MOVIE_CLIP, DATA_TYPE_NULL, DATA_TYPE_NUMBER, DATA_TYPE_OBJECT, DATA_TYPE_OBJECT_END, DATA_TYPE_RECORDSET, DATA_TYPE_REFERENCE_OBJECT, DATA_TYPE_STRING, DATA_TYPE_UNDEFINED, DATA_TYPE_UNKNOWN, DATA_TYPE_XML, DATA_TYPE_XML_TOP, MILLS_PER_HOUR, type
 
Constructor Summary
AMFDataObj()
          Create empty AMFDataObj object
AMFDataObj(byte[] data)
          Deserialize entire data array and create AMFDataObj object
AMFDataObj(byte[] data, int offset, int size)
          Deserialize data array starting at offest for size bytes and create AMFDataObj object
AMFDataObj(java.nio.ByteBuffer data)
          Deserialize entire data array and create AMFDataObj object
AMFDataObj(java.nio.ByteBuffer data, AMFDataContextDeserialize context)
           
 
Method Summary
 boolean containsKey(String name)
          Return true if the object/array contains key
 void deserialize(java.nio.ByteBuffer data)
          Deserialize data in byte buffer
 void deserialize(java.nio.ByteBuffer data, AMFDataContextDeserialize context)
          Deserialize data in byte buffer
 AMFData get(int index)
          Return the object at a particular index.
 AMFData get(String name)
          Return the object at a particular key.
 boolean getBoolean(int index)
          Get item at index return as boolean
 boolean getBoolean(String name)
          Get item at key return as boolean
 byte getByte(int index)
          Get item at index return as byte
 byte getByte(String name)
          Get item at key return as byte
 String getClassName()
           
 java.util.Date getDate(int index)
          Get item at index return as Date
 java.util.Date getDate(String name)
          Get item at key return as Date
 double getDouble(int index)
          Get item at index return as double
 double getDouble(String name)
          Get item at key return as double
 float getFloat(int index)
          Get item at index return as float
 float getFloat(String name)
          Get item at key return as float
 int getInt(int index)
          Get item at index return as int
 int getInt(String name)
          Get item at key return as int
 String getKey(int index)
          Return the key at a particular index.
 java.util.List getKeys()
          Return a list of all the keys (the list is a copy)
 long getLong(int index)
          Get item at index return as long
 long getLong(String name)
          Get item at key return as long
 AMFDataObj getObject(int index)
          Get item at index return as AMFDataObj
 AMFDataObj getObject(String name)
          Get item at key return as AMFDataObj
 short getShort(int index)
          Get item at index return as short
 short getShort(String name)
          Get item at key return as short
 String getString(int index)
          Get item at index return as String
 String getString(String name)
          Get item at key return as String
 AMFDataTrait getTrait()
           
 Object getValue()
          Convert object to Java native class
 void put(String name, AMFData data)
          Put or replace object at key
 void put(String name, boolean data)
          Put or replace boolean value at key (data will be wrapped in an AMFDataItem object)
 void put(String name, java.util.Date data)
          Put or replace date value at key (data will be wrapped in an AMFDataItem object)
 void put(String name, double data)
          Put or replace double value at key (data will be wrapped in an AMFDataItem object)
 void put(String name, int data)
          Put or replace int value at key (data will be wrapped in an AMFDataItem object)
 void put(String name, long data)
          Put or replace long value at key (data will be wrapped in an AMFDataItem object)
 void put(String name, String data)
          Put or replace string value at key (data will be wrapped in an AMFDataItem object)
 AMFData remove(int index)
          Remove element by index
 AMFData remove(String name)
          Remove element by key
 byte[] serialize()
          Serial object to byte array
 byte[] serialize(AMFDataContextSerialize context)
          Serial object to byte array
 void serialize(java.io.DataOutputStream out)
          Serialize object to output stream
 void serialize(java.io.DataOutputStream out, AMFDataContextSerialize context)
          Serialize object to output stream
 void serialize(java.io.DataOutputStream out, int objectEncoding)
          Serialize object to output stream
 byte[] serialize(int objectEncoding)
          Serial object to byte array
 void setClassName(String className)
           
 int size()
          Return the number of members of this object/array
 String toString()
          Return object as formatted string
 
Methods inherited from class com.wowza.wms.amf.AMFData
createContextDeserialize, createContextDeserialize, createContextSerialize, createContextSerialize, deserializeInnerObject, getReference, getType, isAMF3Start, isArrayStart, isByteArrayStart, isMixedArrayStart, isObjEnd, isObjStart, peekByte, setType, skipByte, testNextByte, triggerAMF3Switch
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DECODE_OBJ_REF

public static final int DECODE_OBJ_REF
See Also:
Constant Field Values

DECODE_TRAITS

public static final int DECODE_TRAITS
See Also:
Constant Field Values

DECODE_TRAITS_EXT

public static final int DECODE_TRAITS_EXT
See Also:
Constant Field Values

DECODE_TRAITS_REF

public static final int DECODE_TRAITS_REF
See Also:
Constant Field Values

DECODE_UNDEFINED

public static final int DECODE_UNDEFINED
See Also:
Constant Field Values

members

protected java.util.Map<String,AMFData> members

order

protected java.util.List<String> order

trait

protected AMFDataTrait trait
Constructor Detail

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(java.nio.ByteBuffer data)
Deserialize entire data array and create AMFDataObj object

Parameters:
data - binary data

AMFDataObj

public AMFDataObj(java.nio.ByteBuffer data,
                  AMFDataContextDeserialize context)
Method Detail

containsKey

public boolean containsKey(String name)
Return true if the object/array contains key

Parameters:
name - key
Returns:
Return true the object/array contains key

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

get

public AMFData get(int index)
Return the object at a particular index.

Parameters:
index - index
Returns:
Return object or null if out of bounds

get

public AMFData get(String name)
Return the object at a particular key.

Parameters:
name - key
Returns:
Return object or null if out of bounds

getBoolean

public boolean getBoolean(int index)
Get item at index return as boolean

Parameters:
index - index
Returns:
Return item as boolean or false if out of bounds

getBoolean

public boolean getBoolean(String name)
Get item at key return as boolean

Parameters:
name - key
Returns:
Return item as boolean or false if out of bounds

getByte

public byte getByte(int index)
Get item at index return as byte

Parameters:
index - index
Returns:
Return item as byte or 0 if out of bounds

getByte

public byte getByte(String name)
Get item at key return as byte

Parameters:
name - key
Returns:
Return item as byte or 0 if out of bounds

getClassName

public String getClassName()

getDate

public java.util.Date getDate(int index)
Get item at index return as Date

Parameters:
index - index
Returns:
Return item as Date or null if out of bounds

getDate

public java.util.Date getDate(String name)
Get item at key return as Date

Parameters:
name - key
Returns:
Return item as Date or null if out of bounds

getDouble

public double getDouble(int index)
Get item at index return as double

Parameters:
index - index
Returns:
Return item as double or 0 if out of bounds

getDouble

public double getDouble(String name)
Get item at key return as double

Parameters:
name - key
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 - index
Returns:
Return item as float or 0 if out of bounds

getFloat

public float getFloat(String name)
Get item at key return as float

Parameters:
name - key
Returns:
Return item as float or 0 if out of bounds

getInt

public int getInt(int index)
Get item at index return as int

Parameters:
index - index
Returns:
Return item as int or 0 if out of bounds

getInt

public int getInt(String name)
Get item at key return as int

Parameters:
name - key
Returns:
Return item as int or 0 if out of bounds

getKey

public String getKey(int index)
Return the key at a particular index.

Parameters:
index -
Returns:
Return key at index or null if out of bounds

getKeys

public java.util.List getKeys()
Return a list of all the keys (the list is a copy)

Returns:
new list that contains one entry for each key

getLong

public long getLong(int index)
Get item at index return as long

Parameters:
index - index
Returns:
Return item as long or 0 if out of bounds

getLong

public long getLong(String name)
Get item at key return as long

Parameters:
name - key
Returns:
Return item as long or 0 if out of bounds

getObject

public AMFDataObj getObject(int index)
Get item at index return as AMFDataObj

Parameters:
index - index
Returns:
Return item as AMFDataObj or null if out of bounds

getObject

public AMFDataObj getObject(String name)
Get item at key return as AMFDataObj

Parameters:
name - key
Returns:
Return item as AMFDataObj or null if out of bounds

getShort

public short getShort(int index)
Get item at index return as short

Parameters:
index - index
Returns:
Return item as short or 0 if out of bounds

getShort

public short getShort(String name)
Get item at key return as short

Parameters:
name - key
Returns:
Return item as short or 0 if out of bounds

getString

public String getString(int index)
Get item at index return as String

Parameters:
index - index
Returns:
Return item as String or null if out of bounds

getString

public String getString(String name)
Get item at key return as String

Parameters:
name - key
Returns:
Return item as String or null if out of bounds

getTrait

public AMFDataTrait getTrait()

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

put

public void put(String name,
                AMFData data)
Put or replace object at key

Parameters:
name - key
data - object

put

public void put(String name,
                boolean data)
Put or replace boolean value at key (data will be wrapped in an AMFDataItem object)

Parameters:
name - key
data - boolean value

put

public void put(String name,
                java.util.Date data)
Put or replace date value at key (data will be wrapped in an AMFDataItem object)

Parameters:
name - key
data - date value

put

public void put(String name,
                double data)
Put or replace double value at key (data will be wrapped in an AMFDataItem object)

Parameters:
name - key
data - double value

put

public void put(String name,
                int data)
Put or replace int value at key (data will be wrapped in an AMFDataItem object)

Parameters:
name - key
data - int value

put

public void put(String name,
                long data)
Put or replace long value at key (data will be wrapped in an AMFDataItem object)

Parameters:
name - key
data - long value

put

public void put(String name,
                String data)
Put or replace string value at key (data will be wrapped in an AMFDataItem object)

Parameters:
name - key
data - string value

remove

public AMFData remove(int index)
Remove element by index

Parameters:
index - index
Returns:
removed object or null if not found

remove

public AMFData remove(String name)
Remove element by key

Parameters:
name - key
Returns:
removed object or null if not found

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(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

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,
                      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 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 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

setClassName

public void setClassName(String className)

size

public int size()
Return the number of members of this object/array

Returns:
number of members

toString

public String toString()
Return object as formatted string

Overrides:
toString in class Object