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
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
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
protected IAMFExternalizable
protected AMFDataTrait
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
ConstructorsConstructorDescriptionCreate 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
(ByteBuffer data) Deserialize entire data array and create AMFDataObj objectAMFDataObj
(ByteBuffer data, AMFDataContextDeserialize context) -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(String name) Return true if the object/array contains keyvoid
deserialize
(ByteBuffer data) Deserialize data in byte buffervoid
deserialize
(ByteBuffer data, AMFDataContextDeserialize context) Deserialize data in byte bufferget
(int index) Return the object at a particular index.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
Get item at key return as bytegetDate
(int index) Get item at index return as DateGet item at key return as Datedouble
getDouble
(int index) Get item at index return as doubledouble
Get item at key return as doublefloat
getFloat
(int index) Get item at index return as floatfloat
Get item at key return as floatint
getInt
(int index) Get item at index return as intint
Get item at key return as intgetKey
(int index) Return the key at a particular index.getKeys()
Return a list of all the keys (the list is a copy)long
getLong
(int index) Get item at index return as longlong
Get item at key return as longgetObject
(int index) Get item at index return as AMFDataObjGet item at key return as AMFDataObjshort
getShort
(int index) Get item at index return as shortshort
Get item at key return as shortgetString
(int index) Get item at index return as StringGet item at key return as StringgetTrait()
getValue()
Convert object to Java native classvoid
Put or replace boolean value at key (data will be wrapped in an AMFDataItem object)void
Put or replace double value at key (data will be wrapped in an AMFDataItem object)void
Put or replace int value at key (data will be wrapped in an AMFDataItem object)void
Put or replace long value at key (data will be wrapped in an AMFDataItem object)void
Put or replace object at keyvoid
Put or replace string value at key (data will be wrapped in an AMFDataItem object)void
Put or replace date value at key (data will be wrapped in an AMFDataItem object)remove
(int index) Remove element by indexRemove element by keybyte[]
Serial object to byte arraybyte[]
serialize
(int objectEncoding) Serial object to byte arraybyte[]
serialize
(AMFDataContextSerialize context) Serial object to byte arrayvoid
Serialize object to output streamvoid
serialize
(DataOutputStream out, int objectEncoding) Serialize object to output streamvoid
serialize
(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/arraytoString()
Return object as formatted stringMethods 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 Details
-
DECODE_UNDEFINED
public static final int DECODE_UNDEFINED- See Also:
-
DECODE_OBJ_REF
public static final int DECODE_OBJ_REF- See Also:
-
DECODE_TRAITS_REF
public static final int DECODE_TRAITS_REF- See Also:
-
DECODE_TRAITS_EXT
public static final int DECODE_TRAITS_EXT- See Also:
-
DECODE_TRAITS
public static final int DECODE_TRAITS- See Also:
-
members
-
order
-
trait
-
serializer
-
-
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 dataoffset
- starting offset into datasize
- size of data to deserialize
-
AMFDataObj
Deserialize entire data array and create AMFDataObj object- Parameters:
data
- binary data
-
AMFDataObj
-
-
Method Details
-
size
public int size()Return the number of members of this object/array- Returns:
- number of members
-
containsKey
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
Description copied from interface:IAMFDataObj
Put or replace object at key- Specified by:
put
in interfaceIAMFDataObj
- Parameters:
name
- keydata
- object
-
put
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Description copied from class:AMFData
Deserialize data in byte buffer- Specified by:
deserialize
in classAMFData
- Parameters:
data
- binary data
-
deserialize
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
Description copied from class:AMFData
Serialize object to output stream -
serialize
Description copied from class:AMFData
Serialize object to output stream -
serialize
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
Description copied from class:AMFData
Serial object to byte array -
getValue
Description copied from class:AMFData
Convert object to Java native class -
toString
Return object as formatted string -
getClassName
-
setClassName
-
getTrait
-
getSerializer
-
setSerializer
-