Class 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 Detail

      • name

        protected java.lang.String name
      • value

        protected java.lang.Object value
    • 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 interface BuddyVariable
        Returns:
        true if the variable is persistent
      • getBoolValue

        public java.lang.Boolean getBoolValue()
        Description copied from interface: Variable
        Get the value of the variable as Boolean
        Specified by:
        getBoolValue in interface Variable
        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 interface Variable
        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 interface Variable
        Returns:
        the value of the variable
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface Variable
      • getSFSArrayValue

        public ISFSArray getSFSArrayValue()
        Description copied from interface: Variable
        Get the value of the variable as SFSArray
        Specified by:
        getSFSArrayValue in interface Variable
        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 interface Variable
        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 interface Variable
        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
        Specified by:
        getValue in interface Variable
        Returns:
        the value of the variable
      • isNull

        public boolean isNull()
        Description copied from interface: Variable
        Test if a variable is null
        Specified by:
        isNull in interface Variable
        Returns:
        true if the 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)
      • populateArrayWithValue

        protected void populateArrayWithValue​(ISFSArray sfsa)
        Populate an SFSArray wih the typed value of this Variable
        Parameters:
        sfsa - the SFSArray
      • setValue

        protected void setValue​(java.lang.String val)
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object