com.wowza.wms.amf
Class AMFDataItem

Object
  extended by com.wowza.wms.amf.AMFData
      extended by com.wowza.wms.amf.AMFDataItem

public class AMFDataItem
extends AMFData

AMFDataItem: class for marshalling data between Wowza Pro server and Flash client. The type wraps native Java data types.

Create Native Java Types

AMFDataItem amfDataString = new AMFDataItem("here is my string"); // String
AMFDataItem amfDataLong = new AMFDataItem(1234L); // long
AMFDataItem amfDataDouble = new AMFDataItem(1.234); // double
AMFDataItem amfDataBoolean = new AMFDataItem(true); // boolean
AMFDataItem amfDataNull = new AMFDataItem(); // null

Get Native Java Types

String dataString = amfDataString.getType()==AMFData.DATA_TYPE_LONG_STRING?
                      amfDataString.toString():"";

long dataLong = amfDataLong.getType()==AMFData.DATA_TYPE_NUMBER?
                  amfDataLong.longValue():0;

double dataDouble = amfDataDouble.getType()==AMFData.DATA_TYPE_NUMBER?
                      amfDataLong.doubleValue():0.0;

boolean dataBoolean = amfDataBoolean.getType()==AMFData.DATA_TYPE_BOOLEAN?
                        amfDataLong.booleanValue():false;

Object dataNull = amfDataNull.getType()==AMFData.DATA_TYPE_NULL?
                    null:null;


Field Summary
 
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
AMFDataItem()
          Construct AMF type DATA_TYPE_NULL object
AMFDataItem(boolean value)
          Construct AMF type DATA_TYPE_BOOLEAN
AMFDataItem(byte[] data)
          Deserialize entire data array and create AMFDataItem object
AMFDataItem(byte[] data, int offset, int size)
          Deserialize data array starting at offest for size bytes and create AMFDataItem object
AMFDataItem(java.nio.ByteBuffer data)
          Deserialize entire data array and create AMFDataItem object
AMFDataItem(java.nio.ByteBuffer data, AMFDataContextDeserialize context)
           
AMFDataItem(java.util.Date value)
          Construct AMF type DATA_TYPE_DATE
AMFDataItem(double value)
          Construct AMF type DATA_TYPE_NUMBER object
AMFDataItem(int value)
          Construct AMF type DATA_TYPE_NUMBER object
AMFDataItem(long value)
          Construct AMF type DATA_TYPE_NUMBER object
AMFDataItem(String value)
          Construct AMF type DATA_TYPE_STRING object
 
Method Summary
 boolean booleanValue()
          Return object as boolean.
 byte byteValue()
          Return object as byte.
 java.util.Date dateValue()
          Return object as Date.
 void deserialize(java.nio.ByteBuffer data)
          Deserialize data in byte buffer
 void deserialize(java.nio.ByteBuffer data, AMFDataContextDeserialize context)
          Deserialize data in byte buffer
 double doubleValue()
          Return object as double.
 float floatValue()
          Return object as float.
 Object getValue()
          Return value as Java class
 int intValue()
          Return object as int.
 long longValue()
          Return object as long.
 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
 short shortValue()
          Return object as short.
 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
 

Constructor Detail

AMFDataItem

public AMFDataItem()
Construct AMF type DATA_TYPE_NULL object


AMFDataItem

public AMFDataItem(boolean value)
Construct AMF type DATA_TYPE_BOOLEAN

Parameters:
value - boolean value

AMFDataItem

public AMFDataItem(byte[] data)
Deserialize entire data array and create AMFDataItem object

Parameters:
data - binary data

AMFDataItem

public AMFDataItem(byte[] data,
                   int offset,
                   int size)
Deserialize data array starting at offest for size bytes and create AMFDataItem object

Parameters:
data - binary data
offset - starting offset into data
size - size of data to deserialize

AMFDataItem

public AMFDataItem(java.nio.ByteBuffer data)
Deserialize entire data array and create AMFDataItem object

Parameters:
data - binary data

AMFDataItem

public AMFDataItem(java.nio.ByteBuffer data,
                   AMFDataContextDeserialize context)

AMFDataItem

public AMFDataItem(java.util.Date value)
Construct AMF type DATA_TYPE_DATE

Parameters:
value - Date value

AMFDataItem

public AMFDataItem(double value)
Construct AMF type DATA_TYPE_NUMBER object

Parameters:
value - double value

AMFDataItem

public AMFDataItem(int value)
Construct AMF type DATA_TYPE_NUMBER object

Parameters:
value - int value

AMFDataItem

public AMFDataItem(long value)
Construct AMF type DATA_TYPE_NUMBER object

Parameters:
value - long value

AMFDataItem

public AMFDataItem(String value)
Construct AMF type DATA_TYPE_STRING object

Parameters:
value - String value
Method Detail

booleanValue

public boolean booleanValue()
Return object as boolean. Valid object types are DATA_TYPE_BOOLEAN and DATA_TYPE_STRING.

Returns:
boolean value or false if failure

byteValue

public byte byteValue()
Return object as byte. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.

Returns:
byte value or 0 if failure

dateValue

public java.util.Date dateValue()
Return object as Date. Valid object types are DATA_TYPE_DATE.

Returns:
Date value or null if failure

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

doubleValue

public double doubleValue()
Return object as double. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.

Returns:
double value or 0 if failure

floatValue

public float floatValue()
Return object as float. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.

Returns:
float value or 0 if failure

getValue

public Object getValue()
Return value as Java class

Specified by:
getValue in class AMFData
Returns:
java native class

intValue

public int intValue()
Return object as int. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.

Returns:
int value or 0 if failure

longValue

public long longValue()
Return object as long. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.

Returns:
long value or 0 if failure

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

shortValue

public short shortValue()
Return object as short. Valid object types are DATA_TYPE_NUMBER and DATA_TYPE_STRING.

Returns:
short value or 0 if failure

toString

public String toString()
Return object as formatted string

Overrides:
toString in class Object