Package com.wowza.wms.amf
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 Summary
Fields Modifier and Type Field Description 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 IAMFExternalizable
serializer
protected AMFDataTrait
trait
-
Fields inherited from class com.wowza.wms.amf.AMFData
AMF_DEFAULT_DESERIALIZE_CHARSETNAME, 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
Constructors Constructor Description AMFDataObj()
Create empty AMFDataObj objectAMFDataObj(byte[] data)
Deserialize entire data array and create AMFDataObj objectAMFDataObj(byte[] data, int offset, int size)
Deserialize data array starting at offest for size bytes and create AMFDataObj objectAMFDataObj(java.nio.ByteBuffer data)
Deserialize entire data array and create AMFDataObj objectAMFDataObj(java.nio.ByteBuffer data, AMFDataContextDeserialize context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(String name)
Return true if the object/array contains keyvoid
deserialize(java.nio.ByteBuffer data)
Deserialize data in byte buffervoid
deserialize(java.nio.ByteBuffer data, AMFDataContextDeserialize context)
Deserialize data in byte bufferAMFData
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 booleanboolean
getBoolean(String name)
Get item at key return as booleanbyte
getByte(int index)
Get item at index return as bytebyte
getByte(String name)
Get item at key return as byteString
getClassName()
java.util.Date
getDate(int index)
Get item at index return as Datejava.util.Date
getDate(String name)
Get item at key return as Datedouble
getDouble(int index)
Get item at index return as doubledouble
getDouble(String name)
Get item at key return as doublefloat
getFloat(int index)
Get item at index return as floatfloat
getFloat(String name)
Get item at key return as floatint
getInt(int index)
Get item at index return as intint
getInt(String name)
Get item at key return as intString
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 longlong
getLong(String name)
Get item at key return as longAMFDataObj
getObject(int index)
Get item at index return as AMFDataObjAMFDataObj
getObject(String name)
Get item at key return as AMFDataObjIAMFExternalizable
getSerializer()
short
getShort(int index)
Get item at index return as shortshort
getShort(String name)
Get item at key return as shortString
getString(int index)
Get item at index return as StringString
getString(String name)
Get item at key return as StringAMFDataTrait
getTrait()
Object
getValue()
Convert object to Java native classvoid
put(String name, boolean data)
Put or replace boolean 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, AMFData data)
Put or replace object at keyvoid
put(String name, String data)
Put or replace string 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)AMFData
remove(int index)
Remove element by indexAMFData
remove(String name)
Remove element by keybyte[]
serialize()
Serial object to byte arraybyte[]
serialize(int objectEncoding)
Serial object to byte arraybyte[]
serialize(AMFDataContextSerialize context)
Serial object to byte arrayvoid
serialize(java.io.DataOutputStream out)
Serialize object to output streamvoid
serialize(java.io.DataOutputStream out, int objectEncoding)
Serialize object to output streamvoid
serialize(java.io.DataOutputStream out, AMFDataContextSerialize context)
Serialize object to output streamvoid
setClassName(String className)
void
setSerializer(IAMFExternalizable serializer)
int
size()
Return the number of members of this object/arrayString
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
-
-
-
-
Field Detail
-
DECODE_UNDEFINED
public static final int DECODE_UNDEFINED
- See Also:
- Constant Field Values
-
DECODE_OBJ_REF
public static final int DECODE_OBJ_REF
- See Also:
- Constant Field Values
-
DECODE_TRAITS_REF
public static final int DECODE_TRAITS_REF
- See Also:
- Constant Field Values
-
DECODE_TRAITS_EXT
public static final int DECODE_TRAITS_EXT
- See Also:
- Constant Field Values
-
DECODE_TRAITS
public static final int DECODE_TRAITS
- See Also:
- Constant Field Values
-
members
protected java.util.Map<String,AMFData> members
-
order
protected java.util.List<String> order
-
trait
protected AMFDataTrait trait
-
serializer
protected IAMFExternalizable serializer
-
-
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 dataoffset
- starting offset into datasize
- 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
-
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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- Parameters:
name
- keydata
- 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 interfaceIAMFDataObj
- Parameters:
name
- keydata
- 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 interfaceIAMFDataObj
- Parameters:
name
- keydata
- 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 interfaceIAMFDataObj
- Parameters:
name
- keydata
- 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 interfaceIAMFDataObj
- Parameters:
name
- keydata
- long value
-
put
public void put(String name, java.util.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 interfaceIAMFDataObj
- Parameters:
name
- keydata
- 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 interfaceIAMFDataObj
- Parameters:
name
- keydata
- boolean value
-
getKeys
public java.util.List getKeys()
Description copied from interface:IAMFDataObj
Return a list of all the keys (the list is a copy)- Specified by:
getKeys
in interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- Parameters:
name
- key- Returns:
- Return item as boolean or false if out of bounds
-
getDate
public java.util.Date getDate(String name)
Description copied from interface:IAMFDataObj
Get item at key return as Date- Specified by:
getDate
in interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- Parameters:
index
- index- Returns:
- Return item as boolean or false if out of bounds
-
getDate
public java.util.Date getDate(int index)
Description copied from interface:IAMFDataObj
Get item at index return as Date- Specified by:
getDate
in interfaceIAMFDataObj
- 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 interfaceIAMFDataObj
- Parameters:
index
- index- Returns:
- Return item as AMFDataObj or null 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 classAMFData
- 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 classAMFData
- Parameters:
data
- binary datacontext
- deserialization context used by AMF3
-
serialize
public void serialize(java.io.DataOutputStream out)
Description copied from class:AMFData
Serialize object to output stream
-
serialize
public void serialize(java.io.DataOutputStream out, int objectEncoding)
Description copied from class:AMFData
Serialize object to output stream
-
serialize
public void serialize(java.io.DataOutputStream out, AMFDataContextSerialize context)
Description copied from class:AMFData
Serialize object to output stream
-
serialize
public byte[] serialize()
Description copied from class:AMFData
Serial object to byte array
-
serialize
public byte[] serialize(int objectEncoding)
Description copied from class:AMFData
Serial object to byte array
-
serialize
public byte[] serialize(AMFDataContextSerialize context)
Description copied from class:AMFData
Serial object to byte array
-
getValue
public Object getValue()
Description copied from class:AMFData
Convert object to Java native class
-
toString
public String toString()
Return object as formatted string- Overrides:
toString
in classObject
-
getClassName
public String getClassName()
-
setClassName
public void setClassName(String className)
-
getTrait
public AMFDataTrait getTrait()
-
getSerializer
public IAMFExternalizable getSerializer()
-
setSerializer
public void setSerializer(IAMFExternalizable serializer)
-
-