Packagecom.smartfoxserver.v2.entities.data
Classpublic class SFSObject
InheritanceSFSObject Inheritance Object
Implements ISFSObject

The SFSObject class is used by SmartFoxServer in client-server data transfer. It can be thought of as a specialized Dictionary/Map object that can contain any type of data.

The advantage of using the SFSObject class (for example when sending an ExtensionRequest request) is that you can fine tune the way your data is transmitted over the network. For instance, a number like 100 can be transmitted as a normal integer (which takes 32 bits), but also a short (16 bit) or even a byte (8 bit).

SFSObject supports many primitive data types and related arrays of primitives (see the SFSDataType class). It also allows to serialize class instances and rebuild them on the other side (client or server). Check the SmartFoxServer 2X documentation for more informations on this advanced topic.

NOTE: UTF-8/multi-byte strings are not supported in key names. In other words you should restrict key names to standard ASCII characters. It is also recommended to keep key names very short to save bandwidth.

See also

ExtensionRequest
SFSDataType


Public Methods
 MethodDefined By
  
Creates a new SFSObject instance.
SFSObject
  
containsKey(key:String):Boolean
Indicates whether this object contains a mapping for the specified key or not.
SFSObject
  
getBool(key:String):Boolean
Returns the element corresponding to the specified key as a boolean.
SFSObject
  
getBoolArray(key:String):Array
Returns the element corresponding to the specified key as an array of booleans.
SFSObject
  
getByte(key:String):int
Returns the element corresponding to the specified key as a signed byte (8 bit).
SFSObject
  
getByteArray(key:String):ByteArray
Returns the element corresponding to the specified key as an array of bytes.
SFSObject
  
getClass(key:String):*
Returns the element corresponding to the specified key as an instance of a custom class.
SFSObject
  
getDouble(key:String):Number
Returns the element corresponding to the specified key as a double precision number.
SFSObject
  
getDoubleArray(key:String):Array
Returns the element corresponding to the specified key as an array of double precision numbers.
SFSObject
  
getDump(format:Boolean = true):String
Provides a formatted string representing this object.
SFSObject
  
getFloat(key:String):Number
Returns the element corresponding to the specified key as a floating point number.
SFSObject
  
getFloatArray(key:String):Array
Returns the element corresponding to the specified key as an array of floating point numbers.
SFSObject
  
getHexDump():String
Provides a detailed hexadecimal representation of this object.
SFSObject
  
getInt(key:String):int
Returns the element corresponding to the specified key as an integer (32 bit).
SFSObject
  
getIntArray(key:String):Array
Returns the element corresponding to the specified key as an array of integers.
SFSObject
  
getKeys():Array
Retrieves a list of all the keys contained in this object.
SFSObject
  
getLong(key:String):Number
Returns the element corresponding to the specified key as a long integer (64 bit).
SFSObject
  
getLongArray(key:String):Array
Returns the element corresponding to the specified key as an array of long integers.
SFSObject
  
Returns the element corresponding to the specified key as an ISFSArray object.
SFSObject
  
Returns the element corresponding to the specified key as an ISFSObject object.
SFSObject
  
getShort(key:String):int
Returns the element corresponding to the specified key as a short integer (16 bit).
SFSObject
  
getShortArray(key:String):Array
Returns the element corresponding to the specified key as an array of short integers.
SFSObject
  
getText(key:String):String
Returns the element corresponding to the specified key as a UTF-8 string, with max length of 2 GBytes.
SFSObject
  
getUnsignedByte(key:String):int
Returns the element corresponding to the specified key as an unsigned byte (8 bit).
SFSObject
  
getUnsignedByteArray(key:String):Array
Returns the element corresponding to the specified key as an array of unsigned bytes.
SFSObject
  
getUtfString(key:String):String
Returns the element corresponding to the specified key as a UTF-8 string, with max length of 32 KBytes.
SFSObject
  
getUtfStringArray(key:String):Array
Returns the element corresponding to the specified key as an array of UTF-8 strings.
SFSObject
  
isNull(key:String):Boolean
Indicates if the value mapped by the specified key is null.
SFSObject
  
newFromObject(o:Object, forceToNumber:Boolean = false):SFSObject
[static] Returns a new SFSObject instance.
SFSObject
  
[static] Returns a new SFSObject instance.
SFSObject
  
putBool(key:String, value:Boolean):void
Associates the passed boolean value with the specified key in this object.
SFSObject
  
putBoolArray(key:String, value:Array):void
Associates the passed array of boolean values with the specified key in this object.
SFSObject
  
putByte(key:String, value:int):void
Associates the passed byte (8 bit) value with the specified key in this object.
SFSObject
  
putByteArray(key:String, value:ByteArray):void
Associates the passed array of bytes with the specified key in this object.
SFSObject
  
putClass(key:String, value:*):void
Associates the passed custom class instance with the specified key in this object.
SFSObject
  
putDouble(key:String, value:Number):void
Associates the passed double precision number (64 bit) value with the specified key in this object.
SFSObject
  
putDoubleArray(key:String, value:Array):void
Associates the passed array of double precision number values with the specified key in this object.
SFSObject
  
putFloat(key:String, value:Number):void
Associates the passed floating point number (32 bit) value with the specified key in this object.
SFSObject
  
putFloatArray(key:String, value:Array):void
Associates the passed array of floating point number values with the specified key in this object.
SFSObject
  
putInt(key:String, value:int):void
Associates the passed integer (32 bit) value with the specified key in this object.
SFSObject
  
putIntArray(key:String, value:Array):void
Associates the passed array of integer values with the specified key in this object.
SFSObject
  
putLong(key:String, value:Number):void
Associates the passed long integer (64 bit) value with the specified key in this object.
SFSObject
  
putLongArray(key:String, value:Array):void
Associates the passed array of long integer values with the specified key in this object.
SFSObject
  
putSFSArray(key:String, value:ISFSArray):void
Associates the passed ISFSArray object with the specified key in this object.
SFSObject
  
putSFSObject(key:String, value:ISFSObject):void
Associates the passed ISFSObject object with the specified key in this object.
SFSObject
  
putShort(key:String, value:int):void
Associates the passed short integer (16 bit) value with the specified key in this object.
SFSObject
  
putShortArray(key:String, value:Array):void
Associates the passed array of short integer values with the specified key in this object.
SFSObject
  
putText(key:String, value:String):void
Associates the passed UTF-8 string value (max length: 2 GBytes) with the specified key in this object.
SFSObject
  
putUtfString(key:String, value:String):void
Associates the passed UTF-8 string value (max length: 32 KBytes) with the specified key in this object.
SFSObject
  
putUtfStringArray(key:String, value:Array):void
Associates the passed array of UTF-8 string values with the specified key in this object.
SFSObject
  
removeElement(key:String):void
Removes the element corresponding to the passed key from this object.
SFSObject
  
size():int
Indicates the number of elements in this object.
SFSObject
  
toBinary():ByteArray
Provides the binary form of this object.
SFSObject
  
toObject():Object
Converts this SFSObject to a native ActionScript Object.
SFSObject
Constructor Detail
SFSObject()Constructor
public function SFSObject()

Creates a new SFSObject instance.

See also

Method Detail
containsKey()method
public function containsKey(key:String):Boolean

Indicates whether this object contains a mapping for the specified key or not.

Parameters

key:String — The key whose presence in this object is to be tested.

Returns
Booleantrue if this object contains a mapping for the specified key.
getBool()method 
public function getBool(key:String):Boolean

Returns the element corresponding to the specified key as a boolean.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Boolean — The element of this object associated with the specified key.
getBoolArray()method 
public function getBoolArray(key:String):Array

Returns the element corresponding to the specified key as an array of booleans.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Array — The element of this object as an array of Boolean values.
getByte()method 
public function getByte(key:String):int

Returns the element corresponding to the specified key as a signed byte (8 bit).

Parameters

key:String — The key whose associated value is to be returned.

Returns
int — The element of this object associated with the specified key.
getByteArray()method 
public function getByteArray(key:String):ByteArray

Returns the element corresponding to the specified key as an array of bytes.

Parameters

key:String — The key whose associated value is to be returned.

Returns
ByteArray — The element of this object as a ByteArray.
getClass()method 
public function getClass(key:String):*

Returns the element corresponding to the specified key as an instance of a custom class.

This advanced feature allows the transmission of specific object instances between client-side ActionScript and server-side Java provided that the respective class definitions on both sides have the same package name and they implement the SerializableSFSType interface.

Parameters

key:String — The key whose associated value is to be returned.

Returns
* — The element of this object as a generic Object type to be casted to the target class definition.

See also

getDouble()method 
public function getDouble(key:String):Number

Returns the element corresponding to the specified key as a double precision number.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Number — The element of this object associated with the specified key.
getDoubleArray()method 
public function getDoubleArray(key:String):Array

Returns the element corresponding to the specified key as an array of double precision numbers.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Array — The element of this object as an array of Number values.
getDump()method 
public function getDump(format:Boolean = true):String

Provides a formatted string representing this object. The returned string can be logged or traced in the console for debugging purposes.

Parameters

format:Boolean (default = true) — If true, the output is formatted in a human-readable way.

Returns
String — The string representation of this object.
getFloat()method 
public function getFloat(key:String):Number

Returns the element corresponding to the specified key as a floating point number.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Number — The element of this object associated with the specified key.
getFloatArray()method 
public function getFloatArray(key:String):Array

Returns the element corresponding to the specified key as an array of floating point numbers.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Array — The element of this object as an array of Number values.
getHexDump()method 
public function getHexDump():String

Provides a detailed hexadecimal representation of this object. The returned string can be logged or traced in the console for debugging purposes.

Returns
String — The hexadecimal string representation of this object.
getInt()method 
public function getInt(key:String):int

Returns the element corresponding to the specified key as an integer (32 bit).

Parameters

key:String — The key whose associated value is to be returned.

Returns
int — The element of this object associated with the specified key.
getIntArray()method 
public function getIntArray(key:String):Array

Returns the element corresponding to the specified key as an array of integers.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Array — The element of this object as an array of int values.
getKeys()method 
public function getKeys():Array

Retrieves a list of all the keys contained in this object.

Returns
Array — The list of all the keys in this object.
getLong()method 
public function getLong(key:String):Number

Returns the element corresponding to the specified key as a long integer (64 bit).

Parameters

key:String — The key whose associated value is to be returned.

Returns
Number — The element of this object associated with the specified key.
getLongArray()method 
public function getLongArray(key:String):Array

Returns the element corresponding to the specified key as an array of long integers.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Array — The element of this object as an array of Number values.
getSFSArray()method 
public function getSFSArray(key:String):ISFSArray

Returns the element corresponding to the specified key as an ISFSArray object.

Parameters

key:String — The key whose associated value is to be returned.

Returns
ISFSArray — The element of this object as an object implementing the ISFSArray interface.
getSFSObject()method 
public function getSFSObject(key:String):ISFSObject

Returns the element corresponding to the specified key as an ISFSObject object.

Parameters

key:String — The key whose associated value is to be returned.

Returns
ISFSObject — The element of this object as an object implementing the ISFSObject interface.
getShort()method 
public function getShort(key:String):int

Returns the element corresponding to the specified key as a short integer (16 bit).

Parameters

key:String — The key whose associated value is to be returned.

Returns
int — The element of this object associated with the specified key.
getShortArray()method 
public function getShortArray(key:String):Array

Returns the element corresponding to the specified key as an array of short integers.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Array — The element of this object as an array of int values.
getText()method 
public function getText(key:String):String

Returns the element corresponding to the specified key as a UTF-8 string, with max length of 2 GBytes.

Parameters

key:String — The key whose associated value is to be returned.

Returns
String — The element of this object associated with the specified key.
getUnsignedByte()method 
public function getUnsignedByte(key:String):int

Returns the element corresponding to the specified key as an unsigned byte (8 bit).

Parameters

key:String — The key whose associated value is to be returned.

Returns
int — The element of this object associated with the specified key.
getUnsignedByteArray()method 
public function getUnsignedByteArray(key:String):Array

Returns the element corresponding to the specified key as an array of unsigned bytes.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Array — The element of this object as an array of int values.
getUtfString()method 
public function getUtfString(key:String):String

Returns the element corresponding to the specified key as a UTF-8 string, with max length of 32 KBytes.

Parameters

key:String — The key whose associated value is to be returned.

Returns
String — The element of this object associated with the specified key.
getUtfStringArray()method 
public function getUtfStringArray(key:String):Array

Returns the element corresponding to the specified key as an array of UTF-8 strings.

Parameters

key:String — The key whose associated value is to be returned.

Returns
Array — The element of this object as an array of String values.
isNull()method 
public function isNull(key:String):Boolean

Indicates if the value mapped by the specified key is null.

Parameters

key:String — The key to be checked.

Returns
Booleantrue if the value mapped by the passed key is null.
newFromObject()method 
public static function newFromObject(o:Object, forceToNumber:Boolean = false):SFSObject

Returns a new SFSObject instance.

This is an alternative static constructor that builds a SFSObject populated with the data found in the passed native ActionScript Object. Numeric data is translated to int (integer values) or Number (decimal values). The procedure is recursive and works for nested objects and arrays. The supported native types are: Boolean, int, Number, String, Object, Array. The object can contain null values too.

Parameters

o:Object — The source Object.
 
forceToNumber:Boolean (default = false) — Indicates if the conversion of all numeric values should be forced to the highest precision possible (Number). This means that integer values will be treated as double precision values.

Returns
SFSObject — A new SFSObject instance populated with data from the passed object.

See also

newInstance()method 
public static function newInstance():SFSObject

Returns a new SFSObject instance. This method is an alternative to the standard class constructor.

Returns
SFSObject — A new SFSObject instance.

See also

putBool()method 
public function putBool(key:String, value:Boolean):void

Associates the passed boolean value with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:Boolean — The value to be associated with the specified key.

putBoolArray()method 
public function putBoolArray(key:String, value:Array):void

Associates the passed array of boolean values with the specified key in this object.

Parameters

key:String — The key with which the specified array is to be associated.
 
value:Array — The array of Boolean values to be associated with the specified key.

putByte()method 
public function putByte(key:String, value:int):void

Associates the passed byte (8 bit) value with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:int — The value to be associated with the specified key.

putByteArray()method 
public function putByteArray(key:String, value:ByteArray):void

Associates the passed array of bytes with the specified key in this object.

Parameters

key:String — The key with which the specified ByteArray is to be associated.
 
value:ByteArray — The ByteArray to be associated with the specified key.

putClass()method 
public function putClass(key:String, value:*):void

Associates the passed custom class instance with the specified key in this object. Read the getClass() method description for more informations.

Parameters

key:String — The key with which the specified custom class instance is to be associated.
 
value:* — The custom class instance to be associated with the specified key.

putDouble()method 
public function putDouble(key:String, value:Number):void

Associates the passed double precision number (64 bit) value with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:Number — The value to be associated with the specified key.

putDoubleArray()method 
public function putDoubleArray(key:String, value:Array):void

Associates the passed array of double precision number values with the specified key in this object.

Parameters

key:String — The key with which the specified array is to be associated.
 
value:Array — The array of Number values to be associated with the specified key.

putFloat()method 
public function putFloat(key:String, value:Number):void

Associates the passed floating point number (32 bit) value with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:Number — The value to be associated with the specified key.

putFloatArray()method 
public function putFloatArray(key:String, value:Array):void

Associates the passed array of floating point number values with the specified key in this object.

Parameters

key:String — The key with which the specified array is to be associated.
 
value:Array — The array of Number values to be associated with the specified key.

putInt()method 
public function putInt(key:String, value:int):void

Associates the passed integer (32 bit) value with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:int — The value to be associated with the specified key.

putIntArray()method 
public function putIntArray(key:String, value:Array):void

Associates the passed array of integer values with the specified key in this object.

Parameters

key:String — The key with which the specified array is to be associated.
 
value:Array — The array of int values to be associated with the specified key.

putLong()method 
public function putLong(key:String, value:Number):void

Associates the passed long integer (64 bit) value with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:Number — The value to be associated with the specified key.

putLongArray()method 
public function putLongArray(key:String, value:Array):void

Associates the passed array of long integer values with the specified key in this object.

Parameters

key:String — The key with which the specified array is to be associated.
 
value:Array — The array of Number values to be associated with the specified key.

putSFSArray()method 
public function putSFSArray(key:String, value:ISFSArray):void

Associates the passed ISFSArray object with the specified key in this object.

Parameters

key:String — The key with which the specified object implementing the ISFSArray interface is to be associated.
 
value:ISFSArray — The ISFSArray object to be associated with the specified key.

putSFSObject()method 
public function putSFSObject(key:String, value:ISFSObject):void

Associates the passed ISFSObject object with the specified key in this object.

Parameters

key:String — The key with which the specified object implementing the ISFSObject interface is to be associated.
 
value:ISFSObject — The ISFSObject object to be associated with the specified key.

putShort()method 
public function putShort(key:String, value:int):void

Associates the passed short integer (16 bit) value with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:int — The value to be associated with the specified key.

putShortArray()method 
public function putShortArray(key:String, value:Array):void

Associates the passed array of short integer values with the specified key in this object.

Parameters

key:String — The key with which the specified array is to be associated.
 
value:Array — The array of int values to be associated with the specified key.

putText()method 
public function putText(key:String, value:String):void

Associates the passed UTF-8 string value (max length: 2 GBytes) with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:String — The value to be associated with the specified key.

putUtfString()method 
public function putUtfString(key:String, value:String):void

Associates the passed UTF-8 string value (max length: 32 KBytes) with the specified key in this object.

Parameters

key:String — The key with which the specified value is to be associated.
 
value:String — The value to be associated with the specified key.

putUtfStringArray()method 
public function putUtfStringArray(key:String, value:Array):void

Associates the passed array of UTF-8 string values with the specified key in this object.

Parameters

key:String — The key with which the specified array is to be associated.
 
value:Array — The array of String values to be associated with the specified key.

removeElement()method 
public function removeElement(key:String):void

Removes the element corresponding to the passed key from this object.

Parameters

key:String — The key of the element to be removed.

size()method 
public function size():int

Indicates the number of elements in this object.

Returns
int — The number of elements in this object.
toBinary()method 
public function toBinary():ByteArray

Provides the binary form of this object.

Returns
ByteArray — The binary data representing this object.
toObject()method 
public function toObject():Object

Converts this SFSObject to a native ActionScript Object. The procedure is recurisive, so all nested objects are also converted. The process discards elements of type SFSDataType.CLASS, which must be retrieved with the appropriate method.

Returns
Object — A generic ActionScript 3 Object representing this object.

See also