Packagecom.smartfoxserver.v2.entities.data
Classpublic class SFSArray
InheritanceSFSArray Inheritance Object
Implements ISFSArray

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

The advantage of using the SFSArray class (for example as a nested object inside a SFSObject object) is that you can fine tune the way your data is transmitted over the network. For instance, when transmitting a list of numbers between 0 and 100, those values can be treated as normal integers (which take 32 bits each), but also as shorts (16 bit) or even as bytes (8 bit).

SFSArray 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.

See also

SFSObject
SFSDataType


Public Methods
 MethodDefined By
  
Creates a new SFSArray instance.
SFSArray
  
addBool(value:Boolean):void
Appends a boolean value to the end of this array.
SFSArray
  
addBoolArray(value:Array):void
Appends an array of boolean values to the end of this array.
SFSArray
  
addByte(value:int):void
Appends a byte (8 bit) value to the end of this array.
SFSArray
  
addByteArray(value:ByteArray):void
Appends an array of bytes to the end of this array.
SFSArray
  
addClass(value:*):void
Appends the passed custom class instance to the end of this array.
SFSArray
  
addDouble(value:Number):void
Appends a double precision number (64 bit) value to the end of this array.
SFSArray
  
addDoubleArray(value:Array):void
Appends an array of double precision number values to the end of this array.
SFSArray
  
addFloat(value:Number):void
Appends a floating point number (32 bit) value to the end of this array.
SFSArray
  
addFloatArray(value:Array):void
Appends an array of floating point number values to the end of this array.
SFSArray
  
addInt(value:int):void
Appends an integer (32 bit) value to the end of this array.
SFSArray
  
addIntArray(value:Array):void
Appends an array of integer values to the end of this array.
SFSArray
  
addLong(value:Number):void
Appends a long integer (64 bit) value to the end of this array.
SFSArray
  
addLongArray(value:Array):void
Appends an array of long integer values to the end of this array.
SFSArray
  
addNull():void
Appends a null value to the end of this array.
SFSArray
  
Appends a ISFSArray object to the end of this array.
SFSArray
  
Appends a ISFSObject object to the end of this array.
SFSArray
  
addShort(value:int):void
Appends a short integer (16 bit) value to the end of this array.
SFSArray
  
addShortArray(value:Array):void
Appends an array of short integer values to the end of this array.
SFSArray
  
addText(value:String):void
Appends a UTF-8 string (with max length of 2 GBytes) to the end of this array.
SFSArray
  
addUtfString(value:String):void
Appends a UTF-8 string (with max length of 32 KBytes) to the end of this array.
SFSArray
  
addUtfStringArray(value:Array):void
Appends an array of UTF-8 string values to the end of this array.
SFSArray
  
contains(obj:*):Boolean
Indicates whether this array contains the specified object or not.
SFSArray
  
getBool(index:int):Boolean
Returns the element at the specified position as a boolean.
SFSArray
  
getBoolArray(index:int):Array
Returns the element at the specified position as an array of booleans.
SFSArray
  
getByte(index:int):int
Returns the element at the specified position as a signed byte (8 bit).
SFSArray
  
getByteArray(index:int):ByteArray
Returns the element at the specified position as an array of bytes.
SFSArray
  
getClass(index:int):*
Returns the element at the specified position as an instance of a custom class.
SFSArray
  
getDouble(index:int):Number
Returns the element at the specified position as a double precision number.
SFSArray
  
getDoubleArray(index:int):Array
Returns the element at the specified position as an array of double precision numbers.
SFSArray
  
getDump(format:Boolean = true):String
Provides a formatted string representing this array.
SFSArray
  
getElementAt(index:int):*
Returns the element at the specified position in this array.
SFSArray
  
getFloat(index:int):Number
Returns the element at the specified position as a floating point number.
SFSArray
  
getFloatArray(index:int):Array
Returns the element at the specified position as an array of floating point numbers.
SFSArray
  
getHexDump():String
Provides a detailed hexadecimal representation of this array.
SFSArray
  
getInt(index:int):int
Returns the element at the specified position as an integer (32 bit).
SFSArray
  
getIntArray(index:int):Array
Returns the element at the specified position as an array of integers.
SFSArray
  
getLong(index:int):Number
Returns the element at the specified position as a long integer (64 bit).
SFSArray
  
getLongArray(index:int):Array
Returns the element at the specified position as an array of long integers.
SFSArray
  
Returns the element at the specified position as an ISFSArray object.
SFSArray
  
Returns the element at the specified position as an ISFSObject object.
SFSArray
  
getShort(index:int):int
Returns the element at the specified position as a short integer (16 bit).
SFSArray
  
getShortArray(index:int):Array
Returns the element at the specified position as an array of short integers.
SFSArray
  
getText(index:int):String
Returns the element at the specified position as a UTF-8 string, with max length of 2 Gbytes.
SFSArray
  
getUnsignedByte(index:int):int
Returns the element at the specified position as an unsigned byte (8 bit).
SFSArray
  
getUnsignedByteArray(index:int):Array
Returns the element at the specified position as an array of unsigned bytes.
SFSArray
  
getUtfString(index:int):String
Returns the element at the specified position as a UTF-8 string, with max length of 32 KBytes.
SFSArray
  
getUtfStringArray(index:int):Array
Returns the element at the specified position as an array of UTF-8 strings.
SFSArray
  
isNull(index:int):Boolean
Indicates if the element at the specified position in this array is null.
SFSArray
  
newFromArray(arr:Array, forceToNumber:Boolean = false):SFSArray
[static] Returns a new SFSArray instance.
SFSArray
  
[static] Returns a new SFSArray instance.
SFSArray
  
removeElementAt(index:int):*
Removes the element at the specified position in this array.
SFSArray
  
size():int
Indicates the number of elements in this array.
SFSArray
  
toArray():Array
Converts the SFSArray to a native Actionscript Array.
SFSArray
  
toBinary():ByteArray
Provides the binary form of this array.
SFSArray
Constructor Detail
SFSArray()Constructor
public function SFSArray()

Creates a new SFSArray instance.

See also

Method Detail
addBool()method
public function addBool(value:Boolean):void

Appends a boolean value to the end of this array.

Parameters

value:Boolean — The value to be appended to this array.

addBoolArray()method 
public function addBoolArray(value:Array):void

Appends an array of boolean values to the end of this array.

Parameters

value:Array — The array of Boolean values to be appended to this array.

addByte()method 
public function addByte(value:int):void

Appends a byte (8 bit) value to the end of this array.

Parameters

value:int — The value to be appended to this array.

addByteArray()method 
public function addByteArray(value:ByteArray):void

Appends an array of bytes to the end of this array.

Parameters

value:ByteArray — The array of int values to be appended to this array.

addClass()method 
public function addClass(value:*):void

Appends the passed custom class instance to the end of this array. Read the getClass() method description for more informations.

Parameters

value:* — The custom class instance to be appended to this array.

addDouble()method 
public function addDouble(value:Number):void

Appends a double precision number (64 bit) value to the end of this array.

Parameters

value:Number — The value to be appended to this array.

addDoubleArray()method 
public function addDoubleArray(value:Array):void

Appends an array of double precision number values to the end of this array.

Parameters

value:Array — The array of Number values to be appended to this array.

addFloat()method 
public function addFloat(value:Number):void

Appends a floating point number (32 bit) value to the end of this array.

Parameters

value:Number — The value to be appended to this array.

addFloatArray()method 
public function addFloatArray(value:Array):void

Appends an array of floating point number values to the end of this array.

Parameters

value:Array — The array of Number values to be appended to this array.

addInt()method 
public function addInt(value:int):void

Appends an integer (32 bit) value to the end of this array.

Parameters

value:int — The value to be appended to this array.

addIntArray()method 
public function addIntArray(value:Array):void

Appends an array of integer values to the end of this array.

Parameters

value:Array — The array of int values to be appended to this array.

addLong()method 
public function addLong(value:Number):void

Appends a long integer (64 bit) value to the end of this array.

Parameters

value:Number — The value to be appended to this array.

addLongArray()method 
public function addLongArray(value:Array):void

Appends an array of long integer values to the end of this array.

Parameters

value:Array — The array of Number values to be appended to this array.

addNull()method 
public function addNull():void

Appends a null value to the end of this array.

addSFSArray()method 
public function addSFSArray(value:ISFSArray):void

Appends a ISFSArray object to the end of this array.

Parameters

value:ISFSArray — The object implementing the ISFSArray interface to be appended to this array.

addSFSObject()method 
public function addSFSObject(value:ISFSObject):void

Appends a ISFSObject object to the end of this array.

Parameters

value:ISFSObject — The object implementing the ISFSObject interface to be appended to this array.

addShort()method 
public function addShort(value:int):void

Appends a short integer (16 bit) value to the end of this array.

Parameters

value:int — The value to be appended to this array.

addShortArray()method 
public function addShortArray(value:Array):void

Appends an array of short integer values to the end of this array.

Parameters

value:Array — The array of int values to be appended to this array.

addText()method 
public function addText(value:String):void

Appends a UTF-8 string (with max length of 2 GBytes) to the end of this array.

Parameters

value:String — The value to be appended to this array.

addUtfString()method 
public function addUtfString(value:String):void

Appends a UTF-8 string (with max length of 32 KBytes) to the end of this array.

Parameters

value:String — The value to be appended to this array.

addUtfStringArray()method 
public function addUtfStringArray(value:Array):void

Appends an array of UTF-8 string values to the end of this array.

Parameters

value:Array — The array of String values to be appended to this array.

contains()method 
public function contains(obj:*):Boolean

Indicates whether this array contains the specified object or not.

Parameters

obj:* — The object whose presence in this array is to be tested.

Returns
Booleantrue if the specified object is present.
getBool()method 
public function getBool(index:int):Boolean

Returns the element at the specified position as a boolean.

Parameters

index:int — The position of the element to return.

Returns
Boolean — The element of this array at the specified index.
getBoolArray()method 
public function getBoolArray(index:int):Array

Returns the element at the specified position as an array of booleans.

Parameters

index:int — The position of the element to return.

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

Returns the element at the specified position as a signed byte (8 bit).

Parameters

index:int — The position of the element to return.

Returns
int — The element of this array at the specified index.
getByteArray()method 
public function getByteArray(index:int):ByteArray

Returns the element at the specified position as an array of bytes.

Parameters

index:int — The position of the element to return.

Returns
ByteArray — The element of this array as a ByteArray.
getClass()method 
public function getClass(index:int):*

Returns the element at the specified position 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

index:int — The position of the element to return.

Returns
* — The element of this array as a generic Object type to be casted to the target class definition.
getDouble()method 
public function getDouble(index:int):Number

Returns the element at the specified position as a double precision number.

Parameters

index:int — The position of the element to return.

Returns
Number — The element of this array at the specified index.
getDoubleArray()method 
public function getDoubleArray(index:int):Array

Returns the element at the specified position as an array of double precision numbers.

Parameters

index:int — The position of the element to return.

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

Provides a formatted string representing this array. 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 array.
getElementAt()method 
public function getElementAt(index:int):*

Returns the element at the specified position in this array.

Parameters

index:int — The position of the element to return.

Returns
* — The element at the specified index in this array.
getFloat()method 
public function getFloat(index:int):Number

Returns the element at the specified position as a floating point number.

Parameters

index:int — The position of the element to return.

Returns
Number — The element of this array at the specified index.
getFloatArray()method 
public function getFloatArray(index:int):Array

Returns the element at the specified position as an array of floating point numbers.

Parameters

index:int — The position of the element to return.

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

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

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

Returns the element at the specified position as an integer (32 bit).

Parameters

index:int — The position of the element to return.

Returns
int — The element of this array at the specified index.
getIntArray()method 
public function getIntArray(index:int):Array

Returns the element at the specified position as an array of integers.

Parameters

index:int — The position of the element to return.

Returns
Array — The element of this array as an array of int values.
getLong()method 
public function getLong(index:int):Number

Returns the element at the specified position as a long integer (64 bit).

Parameters

index:int — The position of the element to return.

Returns
Number — The element of this array at the specified index.
getLongArray()method 
public function getLongArray(index:int):Array

Returns the element at the specified position as an array of long integers.

Parameters

index:int — The position of the element to return.

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

Returns the element at the specified position as an ISFSArray object.

Parameters

index:int — The position of the element to return.

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

Returns the element at the specified position as an ISFSObject object.

Parameters

index:int — The position of the element to return.

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

Returns the element at the specified position as a short integer (16 bit).

Parameters

index:int — The position of the element to return.

Returns
int — The element of this array at the specified index.
getShortArray()method 
public function getShortArray(index:int):Array

Returns the element at the specified position as an array of short integers.

Parameters

index:int — The position of the element to return.

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

Returns the element at the specified position as a UTF-8 string, with max length of 2 Gbytes.

Parameters

index:int — The position of the element to return.

Returns
String — The element of this array at the specified index.
getUnsignedByte()method 
public function getUnsignedByte(index:int):int

Returns the element at the specified position as an unsigned byte (8 bit).

Parameters

index:int — The position of the element to return.

Returns
int — The element of this array at the specified index.
getUnsignedByteArray()method 
public function getUnsignedByteArray(index:int):Array

Returns the element at the specified position as an array of unsigned bytes.

Parameters

index:int — The position of the element to return.

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

Returns the element at the specified position as a UTF-8 string, with max length of 32 KBytes.

Parameters

index:int — The position of the element to return.

Returns
String — The element of this array at the specified index.
getUtfStringArray()method 
public function getUtfStringArray(index:int):Array

Returns the element at the specified position as an array of UTF-8 strings.

Parameters

index:int — The position of the element to return.

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

Indicates if the element at the specified position in this array is null.

Parameters

index:int — The position of the element to be checked.

Returns
Booleantrue if the element of this array at the specified position is null.
newFromArray()method 
public static function newFromArray(arr:Array, forceToNumber:Boolean = false):SFSArray

Returns a new SFSArray instance.

This is an alternative static constructor that builds a SFSArray populated with the data found in the passed native ActionScript Array. 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 array can contain null values too.

Parameters

arr:Array — The source Array.
 
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
SFSArray — A new SFSArray instance populated with data from the passed array.

See also

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

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

Returns
SFSArray — A new SFSArray instance.

See also

removeElementAt()method 
public function removeElementAt(index:int):*

Removes the element at the specified position in this array.

Parameters

index:int — The position of the element to be removed.

Returns
* — The element that was removed.
size()method 
public function size():int

Indicates the number of elements in this array.

Returns
int — The number of elements in this array.
toArray()method 
public function toArray():Array

Converts the SFSArray to a native Actionscript Array. The procedure is recurisive so all nested objects will also be converted. The process does not include elements of type SFSDataType.CLASS

Returns
Array — The converted Array

See also

toBinary()method 
public function toBinary():ByteArray

Provides the binary form of this array.

Returns
ByteArray — The binary data representing this array.