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.Stringnameprotected VariableTypetypeprotected java.lang.Objectvalue
-
Constructor Summary
Constructors Modifier Constructor Description protectedSFSBuddyVariable()SFSBuddyVariable(java.lang.String name, java.lang.Object value)protectedSFSBuddyVariable(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.Objectclone()java.lang.BooleangetBoolValue()Get the value of the variable as Booleanjava.lang.DoublegetDoubleValue()Get the value of the variable as Doublejava.lang.IntegergetIntValue()Get the value of the variable as Integerjava.lang.StringgetName()ISFSArraygetSFSArrayValue()Get the value of the variable as SFSArrayISFSObjectgetSFSObjectValue()Get the value of the variable as SFSObjectjava.lang.StringgetStringValue()Get the value of the variable as StringVariableTypegetType()Return the data type of the variablejava.lang.ObjectgetValue()Get the value of the variable as ObjectbooleanisNull()Test if a variable is nullbooleanisOffline()Checks if this is a "offline" variable (persistent), which is available to other Users even when the client is not online.static SFSBuddyVariablenewFromSFSArray(ISFSArray array)SFSArray is expected to be formatted as follows 0: (str) - name 1: (byte) - type id 2: (*) - valueprotected voidpopulateArrayWithValue(ISFSArray sfsa)Populate an SFSArray wih the typed value of this Variableprotected voidsetNull()protected voidsetValue(ISFSArray val)protected voidsetValue(ISFSObject val)protected voidsetValue(java.lang.Boolean val)protected voidsetValue(java.lang.Double val)protected voidsetValue(java.lang.Integer val)protected voidsetValue(java.lang.Object val)protected voidsetValue(java.lang.String val)protected voidsetValueFromStringLiteral(VariableType type, java.lang.String literal)ISFSArraytoSFSArray()Privatejava.lang.StringtoString()
-
-
-
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:BuddyVariableChecks if this is a "offline" variable (persistent), which is available to other Users even when the client is not online.- Specified by:
isOfflinein interfaceBuddyVariable- Returns:
- true if the variable is persistent
-
getType
public VariableType getType()
Description copied from interface:VariableReturn the data type of the variable- Specified by:
getTypein interfaceVariable- Returns:
- the data type of the variable
- See Also:
VariableType
-
getBoolValue
public java.lang.Boolean getBoolValue()
Description copied from interface:VariableGet the value of the variable as Boolean- Specified by:
getBoolValuein interfaceVariable- Returns:
- the value of the variable
-
getDoubleValue
public java.lang.Double getDoubleValue()
Description copied from interface:VariableGet the value of the variable as Double- Specified by:
getDoubleValuein interfaceVariable- Returns:
- the value of the variable
-
getIntValue
public java.lang.Integer getIntValue()
Description copied from interface:VariableGet the value of the variable as Integer- Specified by:
getIntValuein interfaceVariable- Returns:
- the value of the variable
-
getSFSArrayValue
public ISFSArray getSFSArrayValue()
Description copied from interface:VariableGet the value of the variable as SFSArray- Specified by:
getSFSArrayValuein interfaceVariable- Returns:
- the value of the variable
-
getSFSObjectValue
public ISFSObject getSFSObjectValue()
Description copied from interface:VariableGet the value of the variable as SFSObject- Specified by:
getSFSObjectValuein interfaceVariable- Returns:
- the value of the variable
-
getStringValue
public java.lang.String getStringValue()
Description copied from interface:VariableGet the value of the variable as String- Specified by:
getStringValuein interfaceVariable- Returns:
- the value of the variable
-
getValue
public java.lang.Object getValue()
Description copied from interface:VariableGet the value of the variable as Object
-
isNull
public boolean isNull()
Description copied from interface:VariableTest 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:VariablePrivate- Specified by:
toSFSArrayin 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:
clonein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-