new SFSObject()

Creates a new SFSObject instance.

This is a sort of specialized 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.

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

Methods

containsKey(key) → boolean

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

Parameter

Name Type Optional Description

key

string

 

The key whose presence in this object is to be checked.

Returns

boolean true if this object contains a mapping for the passed key.

get(key[, typeId]) → any type

Returns the value assigned to the specified key.

If the typeId parameter is passed, this method also executes a type check, to make sure the requested value has the expected type. In particular this is used by the other specialized get...() methods.

Parameters

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

typeId

number

Yes

The identifier of the expected value's type; must be one of the constants set in the SFSDataType class.
If passed and the type is not corresponding, an error is thrown.
If not passed, no type check is executed and the value is returned immediately.

Defaults to null.

Returns

any type The value assigned to the specified key. null is returned if no value is associated with the passed key.

getBool(key) → boolean

Returns the boolean value corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

boolean The value assigned to the specified key.

getBoolArray(key) → Array

Returns the array of boolean values corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

Array The array assigned to the specified key.

getByte(key) → number

Returns the byte value corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

number The value assigned to the specified key.

getByteArray(key) → Uint8Array

Returns the byte array corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated byte array is to be returned.

Returns

Uint8Array The byte array assigned to the specified key.

getDouble(key) → number

Returns the double precision number corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

number The value assigned to the specified key.

getDoubleArray(key) → Array

Returns the array of double precision numbers corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

Array The array assigned to the specified key.

getDump([format]) → string

Provides a formatted string representing this object.

The returned string can be logged or traced in the console for debugging purposes.

Parameter

Name Type Optional Description

format

boolean

Yes

If true, the output is formatted in a human-readable way.

Defaults to true.

Returns

string The string representation of this object.

getFloat(key) → number

Returns the floating point number corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

number The value assigned to the specified key.

getFloatArray(key) → Array

Returns the array of floating point numbers corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

Array The array assigned to the specified key.

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(key) → number

Returns the integer corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

number The value assigned to the specified key.

getIntArray(key) → Array

Returns the array of integers corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

Array The array assigned to the specified key.

getKeysArray() → Array of string

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

Returns

Array of string The list of all the keys in this object.

getLong(key) → number

Returns the long integer corresponding to the passed key.

IMPORTANT: in JavaScript, long integer numbers are limited to Number.MAX_SAFE_INTEGER (positive and negative, inclusive). This is inconsistent with the max and min Long values available in Java, which are down to -2^63 and up to 2^63 - 1. In case a number greater than Number.MAX_SAFE_INTEGER is returned, this could differ from the actual value set on the server side (a warning will be logged on the client).

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

number The value assigned to the specified key.

getLongArray(key) → Array

Returns the array of long integers corresponding to the passed key.

IMPORTANT: in JavaScript, long integer numbers are limited to Number.MAX_SAFE_INTEGER (positive and negative, inclusive). This is inconsistent with the max and min Long values available in Java, which are down to -2^63 and up to 2^63 - 1.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

Array The array assigned to the specified key.

getSFSArray(key) → SFSArray

Returns the SFSArray corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

SFSArray The SFSArray assigned to the specified key.

getSFSObject(key) → SFSObject

Returns the SFSObject corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

SFSObject The SFSObject assigned to the specified key.

getShort(key) → number

Returns the short integer corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

number The value assigned to the specified key.

getShortArray(key) → Array

Returns the array of short integers corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

Array The array assigned to the specified key.

getText(key) → string

Returns the UTF-8 string corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

string The value assigned to the specified key.

getUtfString(key) → string

Returns the UTF-8 string corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated value is to be returned.

Returns

string The value assigned to the specified key.

getUtfStringArray(key) → Array

Returns the array of UTF-8 strings corresponding to the passed key.

Parameter

Name Type Optional Description

key

string

 

The key whose associated array is to be returned.

Returns

Array The array assigned to the specified key.

isNull(key) → boolean

Indicates if the value mapped by the passed key is of type SFSDataType.NULL.

Parameter

Name Type Optional Description

key

string

 

The key to be checked.

Returns

boolean true if the value mapped by the passed key is of type SFSDataType.NULL.

put(key, value, typeId)

Assign a value of the passed type to the passed key.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

any type

 

The value to be assigned to the passed key.

typeId

number

 

The value's type identifier; must be one of the constants set in the SFSDataType class.

See also
SFSDataType

putBool(key, value)

Assigns a boolean value to the passed key.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

boolean

 

The value to be assigned to the passed key.

putBoolArray(key, array)

Assigns an array of booleans to the passed key.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified array has to be assigned.

array

Array of boolean

 

The array to be assigned to the passed key.

putByte(key, value)

Assigns a number to the passed key as a byte (8 bit).

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

number

 

The value to be assigned to the passed key.

putByteArray(key, array)

Assigns a byte array to the passed key.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified byte array has to be assigned.

array

Uint8Array

 

The byte array to be assigned to the passed key.

putDouble(key, value)

Assigns a number to the passed key as a double precision value (64 bit).

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

number

 

The value to be assigned to the passed key.

putDoubleArray(key, array)

Assigns an array of numbers to the passed key as double precision values.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified array has to be assigned.

array

Array of number

 

The array to be assigned to the passed key.

putFloat(key, value)

Assigns a number to the passed key as a floating point value (32 bit).

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

number

 

The value to be assigned to the passed key.

putFloatArray(key, array)

Assigns an array of numbers to the passed key as floating point values.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified array has to be assigned.

array

Array of number

 

The array to be assigned to the passed key.

putInt(key, value)

Assigns a number to the passed key as an integer (32 bit).

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

number

 

The value to be assigned to the passed key.

putIntArray(key, array)

Assigns an array of numbers to the passed key as integers.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified array has to be assigned.

array

Array of number

 

The array to be assigned to the passed key.

putLong(key, value)

Assigns a number to the passed key as a long integer.

IMPORTANT: in JavaScript, long integer numbers are limited to Number.MAX_SAFE_INTEGER (positive and negative, inclusive). This is inconsistent with the max and min Long values available in Java, which are down to -2^63 and up to 2^63 - 1. So if you are developing your server side Extension in Java, make sure you take this limitation into account when dealing with integers.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

number

 

The value to be assigned to the passed key.

putLongArray(key, array)

Assigns an array of numbers to the passed key as long integers.

This is a shortcut for the put() method.

Read important note in the put() method description.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified array has to be assigned.

array

Array of number

 

The array to be assigned to the passed key.

putNull(key)

Assigns a null value to the passed key.

This is a shortcut for the put() method.

Parameter

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

putSFSArray(key, value)

Assigns a nested SFSArray to the passed key.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

SFSArray

 

The SFSArray to be assigned to the passed key.

putSFSObject(key, value)

Assigns a nested SFSObject to the passed key.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

SFSObject

 

The SFSObject to be assigned to the passed key.

putShort(key, value)

Assigns a number to the passed key as a short integer (16 bit).

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

number

 

The value to be assigned to the passed key.

putShortArray(key, array)

Assigns an array of numbers to the passed key as short integers.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified array has to be assigned.

array

Array of number

 

The array to be assigned to the passed key.

putText(key, value)

Assigns a UTF-8 text to the passed key (max length: 2 GBytes).

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

string

 

The value to be assigned to the passed key.

putUtfString(key, value)

Assigns a UTF-8 string to the passed key (max length: 32 KBytes).

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified value has to be assigned.

value

string

 

The value to be assigned to the passed key.

putUtfStringArray(key, array)

Assigns an array of UTF-8 strings to the passed key.

This is a shortcut for the put() method.

Parameters

Name Type Optional Description

key

string

 

The key to which the specified array has to be assigned.

array

Array of string

 

The array to be assigned to the passed key.

size() → number

Returns the number of elements in this object.

Returns

number The number of elements in this object.