Package com.smartfoxserver.v2.buddylist
Class SFSBuddyVariable
- java.lang.Object
-
- com.smartfoxserver.v2.buddylist.SFSBuddyVariable
-
- All Implemented Interfaces:
BuddyVariable
,Variable
,java.lang.Cloneable
public class SFSBuddyVariable extends java.lang.Object implements BuddyVariable
BuddyVariables are custom values attached to any Buddy in a BuddyList. They work with the same principle of the User/Room Variables. The only difference is the logic by which they get propagated to other Users. While RoomVariables are broadcast to all clients in the same Room, BuddyVariables are updated to all Users who have the BuddyVariable owner in their BuddyLists.BuddyVariables support basic data types and nested complex objects:
- Null
- Bool
- Int
- Double
- String
- SFSObject
- SFSArray
Also BuddyVariables provide a special convention that allows certain variables to be "seen" to the other Users even when they are not online. All variable names starting with a dollar sign ($) will be persistent and available at any time whether the owner is online or not.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
name
protected VariableType
type
protected java.lang.Object
value
-
Constructor Summary
Constructors Modifier Constructor Description protected
SFSBuddyVariable()
SFSBuddyVariable(java.lang.String name, java.lang.Object value)
protected
SFSBuddyVariable(java.lang.String name, java.lang.Object value, VariableType type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
java.lang.Boolean
getBoolValue()
Get the value of the variable as Booleanjava.lang.Double
getDoubleValue()
Get the value of the variable as Doublejava.lang.Integer
getIntValue()
Get the value of the variable as Integerjava.lang.String
getName()
ISFSArray
getSFSArrayValue()
Get the value of the variable as SFSArrayISFSObject
getSFSObjectValue()
Get the value of the variable as SFSObjectjava.lang.String
getStringValue()
Get the value of the variable as StringVariableType
getType()
Return the data type of the variablejava.lang.Object
getValue()
Get the value of the variable as Objectboolean
isNull()
Test if a variable is nullboolean
isOffline()
Checks if this is a "offline" variable (persistent), which is available to other Users even when the client is not online.static SFSBuddyVariable
newFromSFSArray(ISFSArray array)
SFSArray is expected to be formatted as follows 0: (str) - name 1: (byte) - type id 2: (*) - valueprotected void
populateArrayWithValue(ISFSArray sfsa)
Populate an SFSArray wih the typed value of this Variableprotected void
setNull()
protected void
setValue(ISFSArray val)
protected void
setValue(ISFSObject val)
protected void
setValue(java.lang.Boolean val)
protected void
setValue(java.lang.Double val)
protected void
setValue(java.lang.Integer val)
protected void
setValue(java.lang.Object val)
protected void
setValue(java.lang.String val)
protected void
setValueFromStringLiteral(VariableType type, java.lang.String literal)
ISFSArray
toSFSArray()
Privatejava.lang.String
toString()
-
-
-
Field Detail
-
name
protected java.lang.String name
-
value
protected java.lang.Object value
-
type
protected VariableType type
-
-
Constructor Detail
-
SFSBuddyVariable
public SFSBuddyVariable(java.lang.String name, java.lang.Object value)
-
SFSBuddyVariable
protected SFSBuddyVariable()
-
SFSBuddyVariable
protected SFSBuddyVariable(java.lang.String name, java.lang.Object value, VariableType type)
-
-
Method Detail
-
newFromSFSArray
public static SFSBuddyVariable newFromSFSArray(ISFSArray array)
SFSArray is expected to be formatted as follows 0: (str) - name 1: (byte) - type id 2: (*) - value- Parameters:
array
-- Returns:
- the RoomVariable
-
setValueFromStringLiteral
protected void setValueFromStringLiteral(VariableType type, java.lang.String literal)
-
isOffline
public boolean isOffline()
Description copied from interface:BuddyVariable
Checks if this is a "offline" variable (persistent), which is available to other Users even when the client is not online.- Specified by:
isOffline
in interfaceBuddyVariable
- Returns:
- true if the variable is persistent
-
getType
public VariableType getType()
Description copied from interface:Variable
Return the data type of the variable- Specified by:
getType
in interfaceVariable
- Returns:
- the data type of the variable
- See Also:
VariableType
-
getBoolValue
public java.lang.Boolean getBoolValue()
Description copied from interface:Variable
Get the value of the variable as Boolean- Specified by:
getBoolValue
in interfaceVariable
- Returns:
- the value of the variable
-
getDoubleValue
public java.lang.Double getDoubleValue()
Description copied from interface:Variable
Get the value of the variable as Double- Specified by:
getDoubleValue
in interfaceVariable
- Returns:
- the value of the variable
-
getIntValue
public java.lang.Integer getIntValue()
Description copied from interface:Variable
Get the value of the variable as Integer- Specified by:
getIntValue
in interfaceVariable
- Returns:
- the value of the variable
-
getSFSArrayValue
public ISFSArray getSFSArrayValue()
Description copied from interface:Variable
Get the value of the variable as SFSArray- Specified by:
getSFSArrayValue
in interfaceVariable
- Returns:
- the value of the variable
-
getSFSObjectValue
public ISFSObject getSFSObjectValue()
Description copied from interface:Variable
Get the value of the variable as SFSObject- Specified by:
getSFSObjectValue
in interfaceVariable
- Returns:
- the value of the variable
-
getStringValue
public java.lang.String getStringValue()
Description copied from interface:Variable
Get the value of the variable as String- Specified by:
getStringValue
in interfaceVariable
- Returns:
- the value of the variable
-
getValue
public java.lang.Object getValue()
Description copied from interface:Variable
Get the value of the variable as Object
-
isNull
public boolean isNull()
Description copied from interface:Variable
Test if a variable is null
-
setNull
protected void setNull()
-
setValue
protected void setValue(java.lang.Boolean val)
-
setValue
protected void setValue(java.lang.Double val)
-
setValue
protected void setValue(java.lang.Integer val)
-
setValue
protected void setValue(ISFSArray val)
-
setValue
protected void setValue(ISFSObject val)
-
setValue
protected void setValue(java.lang.Object val)
-
toSFSArray
public ISFSArray toSFSArray()
Description copied from interface:Variable
Private- Specified by:
toSFSArray
in interfaceVariable
-
populateArrayWithValue
protected void populateArrayWithValue(ISFSArray sfsa)
Populate an SFSArray wih the typed value of this Variable- Parameters:
sfsa
- theSFSArray
-
setValue
protected void setValue(java.lang.String val)
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-