Package com.smartfoxserver.entities.data
Class SFSObject
java.lang.Object
com.smartfoxserver.entities.data.SFSObject
- All Implemented Interfaces:
ISFSObject,Serializable
- Direct Known Subclasses:
SFSObjectLite
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) Looks for a specific key in the objectGet the element for the specified key as Boolean.getBoolArray(String key) Get the element for the specified key as a Collection of Booleans.Get the element for the specified key as Byte (signed 8 bit).byte[]getByteArray(String key) Get the element for the specified key as a Collection of Byte.Get the element for the specified key as Double (signed decimal 64 bit).getDoubleArray(String key) Get the element for the specified key as a Collection of Double.getDump()Get a detailed dump of the SFSObject structuregetDump(boolean noFormat) Get a detailed dump of the SFSObject structureGet the element for the specified key as Float (signed decimal 32 bit).getFloatArray(String key) Get the element for the specified key as a Collection of Float.Get a pretty-printed hex-dump of the objectGet the element for the specified key as Integer (signed 32 bit).getIntArray(String key) Get the element for the specified key as a Collection of Integer.getKeys()Get a set of all keysGet the element for the specified key as Long (signed 64 bit).getLongArray(String key) Get the element for the specified key as a Collection of Long.getSFSArray(String key) Get the element for the specified key as ISFSArray.getSFSObject(String key) Get the element for the specified key as ISFSObject.Get the element for the specified key as Short (signed 16 bit).getShortArray(String key) Get the element for the specified key as a Collection of Short.getShortString(String key) Get the element for the specified key as String using UTF-8 encoding.Get the element for the specified key as a Collection of Strings.Get the element for the specified key as String using UTF-8 encoding.getStringArray(String key) Get the element for the specified key as a Collection of Strings.Get the element for the specified key as String using UTF-8 encoding.Get the element for the specified key as a Collection of unsigned Byte.getVector2(String key) Get the element for the specified key as SFSVector2.getVector2Array(String key) Get the element for the specified key as a Collection of SFSVector2.getVector3(String key) Get the element for the specified key as SFSVector3.getVector3Array(String key) Get the element for the specified key as a Collection of SFSVector3.booleanChecks if a specific element is of SFSDataType.NULL.iterator()Return an Iterator to loop through the collection of valuesstatic SFSObjectnewFromBinaryData(byte[] bytes) Rebuild an SFSObject form its binary formstatic SFSObjectnewFromBinaryData(ByteBuffer buff) static ISFSObjectnewFromJsonData(String jsonStr) static SFSObjectnewFromResultSet(ResultSet rset) static SFSObjectStatic constructor, similar to new SFSObject();voidput(String key, SFSDataWrapper wrappedObject) voidAdd a booleanvoidputBoolArray(String key, Collection<Boolean> value) Add a Collection of booleanvoidAdd a byte (signed 8-bit)voidputByteArray(String key, byte[] value) Add an array of bytesvoidAdd a double value (signed 64-bit)voidputDoubleArray(String key, Collection<Double> value) Add a Collection of doublevoidAdd a float value (signed 32-bit)voidputFloatArray(String key, Collection<Float> value) Add a Collection of floatvoidAdd a short value (signed 32-bit)voidputIntArray(String key, Collection<Integer> value) Add a Collection of intvoidAdd a long value (signed 64-bit)voidputLongArray(String key, Collection<Long> value) Add a Collection of longvoidAdd a null field to the Object.voidputSFSArray(String key, ISFSArray value) Add a nested ISFSArrayvoidputSFSObject(String key, ISFSObject value) Add a nested SFSObjectvoidAdd a short value (signed 16-bit)voidputShortArray(String key, Collection<Short> value) Add a Collection of shortvoidputShortString(String key, String value) Add a short string value (UTF encoded), with a limit of 255 bytesvoidputShortStringArray(String key, Collection<String> value) Add a collection of short strings (each string limited to 255 bytes) The collection is also limited to a max of 32768 short stringsvoidAdd a string value (encoded in UTF-8), with a limit of 32768 bytes.voidputStringArray(String key, Collection<String> value) Add a collection of strings (each string limited to 32768 bytes) The collection is also limited to a max of 32768 stringsvoidAdd a string value (UTF encoded), with a limit of 2 GBytesvoidputVector2(String key, SFSVector2 value) Add a SFSVector2voidputVector2Array(String key, Collection<SFSVector2> value) Add a collection of SFSVector2voidputVector3(String key, SFSVector3 value) Add a SFSVector3voidputVector3Array(String key, Collection<SFSVector3> value) Add a collection of SFSVector3booleanremoveElement(String key) Remove an element in the objectintsize()Get the size of the SFSObjectbyte[]toBinary()Serialize the SFSObject to a byte[]toJson()toString()
-
Constructor Details
-
SFSObject
public SFSObject()
-
-
Method Details
-
newFromBinaryData
Rebuild an SFSObject form its binary form- Parameters:
bytes- the binary data- Returns:
- the original SFSObject
- Throws:
IllegalStateException- if there's any problem with decoding the binary data
-
newFromBinaryData
- Internal
-
newFromJsonData
- Internal
-
newFromResultSet
- Throws:
SQLException- Internal
-
newInstance
Static constructor, similar to new SFSObject();- Returns:
- a new SFSObject
-
iterator
Description copied from interface:ISFSObjectReturn an Iterator to loop through the collection of valuesNOTE: SFSObject is not thread safe. Use synchronization if you need to iterate and write from different threads
- Specified by:
iteratorin interfaceISFSObject- Returns:
- the SFSObject iterator
-
containsKey
Description copied from interface:ISFSObjectLooks for a specific key in the object- Specified by:
containsKeyin interfaceISFSObject- Returns:
- true if the element exists
-
removeElement
Description copied from interface:ISFSObjectRemove an element in the object- Specified by:
removeElementin interfaceISFSObject- Parameters:
key- the element name- Returns:
- true if the element was really present in the object
-
size
public int size()Description copied from interface:ISFSObjectGet the size of the SFSObject- Specified by:
sizein interfaceISFSObject- Returns:
- the number of elements contained in the SFSObject
-
toBinary
public byte[] toBinary()Description copied from interface:ISFSObjectSerialize the SFSObject to a byte[]- Specified by:
toBinaryin interfaceISFSObject- Returns:
- the serialized form of the SFSObject
-
toJson
- Specified by:
toJsonin interfaceISFSObject
-
getDump
Description copied from interface:ISFSObjectGet a detailed dump of the SFSObject structure- Specified by:
getDumpin interfaceISFSObject- Returns:
- a detailed dump of the SFSObject structure
-
getDump
Description copied from interface:ISFSObjectGet a detailed dump of the SFSObject structure- Specified by:
getDumpin interfaceISFSObject- Parameters:
noFormat- if true the dump will not be pretty-printed- Returns:
- a detailed dump of the SFSObject structure
-
getHexDump
Description copied from interface:ISFSObjectGet a pretty-printed hex-dump of the object- Specified by:
getHexDumpin interfaceISFSObject- Returns:
- a pretty-printed hex-dump of the object
-
isNull
Description copied from interface:ISFSObjectChecks if a specific element is of SFSDataType.NULL.- Specified by:
isNullin interfaceISFSObject- Parameters:
key- the property name- Returns:
- true if the item is null
-
get
- Specified by:
getin interfaceISFSObject
-
getBool
Description copied from interface:ISFSObjectGet the element for the specified key as Boolean. It can be null if no element exists for the specified key- Specified by:
getBoolin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getBoolArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Booleans. It can be null if no element exists for the specified key- Specified by:
getBoolArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getByte
Description copied from interface:ISFSObjectGet the element for the specified key as Byte (signed 8 bit). It can be null if no element exists for the specified key- Specified by:
getBytein interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getByteArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Byte. It can be null if no element exists for the specified keyNOTE: This is not supported for HTML5 / Websocket clients, which includes Unity WebGL exports.
- Specified by:
getByteArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getDouble
Description copied from interface:ISFSObjectGet the element for the specified key as Double (signed decimal 64 bit). It can be null if no element exists for the specified key- Specified by:
getDoublein interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getDoubleArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Double. It can be null if no element exists for the specified key- Specified by:
getDoubleArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getFloat
Description copied from interface:ISFSObjectGet the element for the specified key as Float (signed decimal 32 bit). It can be null if no element exists for the specified key- Specified by:
getFloatin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getFloatArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Float. It can be null if no element exists for the specified key- Specified by:
getFloatArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getInt
Description copied from interface:ISFSObjectGet the element for the specified key as Integer (signed 32 bit). It can be null if no element exists for the specified key- Specified by:
getIntin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getIntArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Integer. It can be null if no element exists for the specified key- Specified by:
getIntArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getKeys
Description copied from interface:ISFSObjectGet a set of all keys- Specified by:
getKeysin interfaceISFSObject- Returns:
- all the keys
-
getLong
Description copied from interface:ISFSObjectGet the element for the specified key as Long (signed 64 bit). It can be null if no element exists for the specified key- Specified by:
getLongin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getLongArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Long. It can be null if no element exists for the specified key- Specified by:
getLongArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getSFSArray
Description copied from interface:ISFSObjectGet the element for the specified key as ISFSArray. It can be null if no element exists for the specified key- Specified by:
getSFSArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
- See Also:
-
getSFSObject
Description copied from interface:ISFSObjectGet the element for the specified key as ISFSObject. It can be null if no element exists for the specified key- Specified by:
getSFSObjectin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getShort
Description copied from interface:ISFSObjectGet the element for the specified key as Short (signed 16 bit). It can be null if no element exists for the specified key- Specified by:
getShortin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getShortArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Short. It can be null if no element exists for the specified key- Specified by:
getShortArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getUnsignedByteArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of unsigned Byte. It can be null if no element exists for the specified key- Specified by:
getUnsignedByteArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getString
Description copied from interface:ISFSObjectGet the element for the specified key as String using UTF-8 encoding. It can be null if no element exists for the specified key.(The string is limited to 32768 characters)
- Specified by:
getStringin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getShortString
Description copied from interface:ISFSObjectGet the element for the specified key as String using UTF-8 encoding. It can be null if no element exists for the specified key.(a ShortString is limited to 255 characters)
- Specified by:
getShortStringin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getText
Description copied from interface:ISFSObjectGet the element for the specified key as String using UTF-8 encoding. It can be null if no element exists for the specified key.The string is limited to 2 GBytes
- Specified by:
getTextin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getVector2
Description copied from interface:ISFSObjectGet the element for the specified key as SFSVector2. It can be null if no element exists for the specified key- Specified by:
getVector2in interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getVector3
Description copied from interface:ISFSObjectGet the element for the specified key as SFSVector3. It can be null if no element exists for the specified key- Specified by:
getVector3in interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getStringArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Strings. It can be null if no element exists for the specified key Each string is limited to 32768 bytes- Specified by:
getStringArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getShortStringArray
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of Strings. It can be null if no element exists for the specified key Each string is limited to 255 bytes- Specified by:
getShortStringArrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getVector2Array
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of SFSVector2. It can be null if no element exists for the specified key- Specified by:
getVector2Arrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
getVector3Array
Description copied from interface:ISFSObjectGet the element for the specified key as a Collection of SFSVector3. It can be null if no element exists for the specified key- Specified by:
getVector3Arrayin interfaceISFSObject- Parameters:
key-- Returns:
- the element, or null
-
putBool
Description copied from interface:ISFSObjectAdd a boolean- Specified by:
putBoolin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putBoolArray
Description copied from interface:ISFSObjectAdd a Collection of boolean- Specified by:
putBoolArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putByte
Description copied from interface:ISFSObjectAdd a byte (signed 8-bit)- Specified by:
putBytein interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putByteArray
Description copied from interface:ISFSObjectAdd an array of bytesNOTE: This is not supported for HTML5 / Websocket clients, which includes Unity WebGL exports.
- Specified by:
putByteArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putDouble
Description copied from interface:ISFSObjectAdd a double value (signed 64-bit)- Specified by:
putDoublein interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putDoubleArray
Description copied from interface:ISFSObjectAdd a Collection of double- Specified by:
putDoubleArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putFloat
Description copied from interface:ISFSObjectAdd a float value (signed 32-bit)- Specified by:
putFloatin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putFloatArray
Description copied from interface:ISFSObjectAdd a Collection of float- Specified by:
putFloatArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putInt
Description copied from interface:ISFSObjectAdd a short value (signed 32-bit)- Specified by:
putIntin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putIntArray
Description copied from interface:ISFSObjectAdd a Collection of int- Specified by:
putIntArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putLong
Description copied from interface:ISFSObjectAdd a long value (signed 64-bit)- Specified by:
putLongin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putLongArray
Description copied from interface:ISFSObjectAdd a Collection of long- Specified by:
putLongArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putNull
Description copied from interface:ISFSObjectAdd a null field to the Object. Normally we recommend that null values are simply not sent. On the other end of the application you can simply check if a specific key exists or not to detect a null.This method will effectively add the key and a byte id to describe the Null value, thus "bloating" the message
- Specified by:
putNullin interfaceISFSObject- Parameters:
key- the property name
-
putSFSArray
Description copied from interface:ISFSObjectAdd a nested ISFSArray- Specified by:
putSFSArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value- See Also:
-
putSFSObject
Description copied from interface:ISFSObjectAdd a nested SFSObject- Specified by:
putSFSObjectin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putShort
Description copied from interface:ISFSObjectAdd a short value (signed 16-bit)- Specified by:
putShortin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putShortArray
Description copied from interface:ISFSObjectAdd a Collection of short- Specified by:
putShortArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putString
Description copied from interface:ISFSObjectAdd a string value (encoded in UTF-8), with a limit of 32768 bytes.- Specified by:
putStringin interfaceISFSObject- Parameters:
key- the property namevalue- the value- See Also:
-
putShortString
Description copied from interface:ISFSObjectAdd a short string value (UTF encoded), with a limit of 255 bytes- Specified by:
putShortStringin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putText
Description copied from interface:ISFSObjectAdd a string value (UTF encoded), with a limit of 2 GBytes- Specified by:
putTextin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putVector2
Description copied from interface:ISFSObjectAdd a SFSVector2- Specified by:
putVector2in interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putVector3
Description copied from interface:ISFSObjectAdd a SFSVector3- Specified by:
putVector3in interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putStringArray
Description copied from interface:ISFSObjectAdd a collection of strings (each string limited to 32768 bytes) The collection is also limited to a max of 32768 strings- Specified by:
putStringArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putShortStringArray
Description copied from interface:ISFSObjectAdd a collection of short strings (each string limited to 255 bytes) The collection is also limited to a max of 32768 short strings- Specified by:
putShortStringArrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putVector2Array
Description copied from interface:ISFSObjectAdd a collection of SFSVector2- Specified by:
putVector2Arrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
putVector3Array
Description copied from interface:ISFSObjectAdd a collection of SFSVector3- Specified by:
putVector3Arrayin interfaceISFSObject- Parameters:
key- the property namevalue- the value
-
put
- Specified by:
putin interfaceISFSObject
-
toString
-