sfs2x.client.entities.variables
Class SFSRoomVariable

java.lang.Object
  extended by sfs2x.client.entities.variables.BaseVariable
      extended by sfs2x.client.entities.variables.SFSRoomVariable
All Implemented Interfaces:
RoomVariable, Variable

public class SFSRoomVariable
extends BaseVariable
implements RoomVariable

The SFSRoomVariable object represents a SmartFoxServer Room Variable entity on the client. It is a custom value attached to a Room object that gets automatically synchronized between client and server on every change.

Room Variables are particularly useful to store custom Room data such as a game status and other Room-level informations. Room Variables can be set by means of the SetRoomVariablesRequest request; they support the following data types (also nested): Boolean, int, Number, String, SFSObject, SFSArray. A Room Variable can also be null.

Room Variables also support a number of specific flags:

See Also:
Room, SetRoomVariablesRequest, SFSObject, SFSArray

Constructor Summary
SFSRoomVariable(java.lang.String name, java.lang.Object val)
           
SFSRoomVariable(java.lang.String name, java.lang.Object value, int type)
          Creates a new SFSRoomVariable instance.
 
Method Summary
static RoomVariable fromSFSArray(com.smartfoxserver.v2.entities.data.ISFSArray sfsa)
          * API internal usage only *
 boolean isPersistent()
          Indicates whether this Room Variable is persistent or not.
 boolean isPrivate()
          Indicates whether this Room Variable is private or not.
 void setPersistent(boolean persistent)
          * API internal usage only *
 void setPrivate(boolean setPrivate)
          * API internal usage only *
 com.smartfoxserver.v2.entities.data.ISFSArray toSFSArray()
          Private
 java.lang.String toString()
          Returns a string that contains the Room Variable name, type, value and isPrivate flag.
 
Methods inherited from class sfs2x.client.entities.variables.BaseVariable
getBoolValue, getDoubleValue, getIntValue, getName, getSFSArrayValue, getSFSObjectValue, getStringValue, getType, getValue, isNull
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sfs2x.client.entities.variables.Variable
getBoolValue, getDoubleValue, getIntValue, getName, getSFSArrayValue, getSFSObjectValue, getStringValue, getType, getValue, isNull
 

Constructor Detail

SFSRoomVariable

public SFSRoomVariable(java.lang.String name,
                       java.lang.Object val)
See Also:
SFSRoomVariable(String, Object, int)

SFSRoomVariable

public SFSRoomVariable(java.lang.String name,
                       java.lang.Object value,
                       int type)
Creates a new SFSRoomVariable instance.

Parameters:
name - The name of the Room Variable.
value - The value of the Room Variable; valid data types are: Boolean, int, Number, String, SFSObject, SFSArray. The value can also be null.
type - The type of the Room Variable among those available in the VariableType class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
See Also:
VariableType
Method Detail

fromSFSArray

public static RoomVariable fromSFSArray(com.smartfoxserver.v2.entities.data.ISFSArray sfsa)
* API internal usage only *


isPersistent

public boolean isPersistent()
Description copied from interface: RoomVariable
Indicates whether this Room Variable is persistent or not. A persistent Room Variable continues to exist in the Room after the user who created it has left it and until he disconnects.

NOTE: setting the isPersistent property manually on an existing Room Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the Room Variable object is created by the developer only (using the new keyword).

Specified by:
isPersistent in interface RoomVariable

isPrivate

public boolean isPrivate()
Description copied from interface: RoomVariable
Indicates whether this Room Variable is private or not. A private Room Variable can be modified by its owner only (the user that created it).

NOTE: setting the isPersistent property manually on an existing Room Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the Room Variable object is created by the developer only (using the new keyword).

Specified by:
isPrivate in interface RoomVariable

setPrivate

public void setPrivate(boolean setPrivate)
Description copied from interface: RoomVariable
* API internal usage only *

Specified by:
setPrivate in interface RoomVariable

setPersistent

public void setPersistent(boolean persistent)
Description copied from interface: RoomVariable
* API internal usage only *

Specified by:
setPersistent in interface RoomVariable

toSFSArray

public com.smartfoxserver.v2.entities.data.ISFSArray toSFSArray()
Description copied from interface: Variable
Private

Specified by:
toSFSArray in interface Variable
Overrides:
toSFSArray in class BaseVariable

toString

public java.lang.String toString()
Returns a string that contains the Room Variable name, type, value and isPrivate flag.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the SFSRoomVariable object.