sfs2x.client.entities
Class SFSBuddy

java.lang.Object
  extended by sfs2x.client.entities.SFSBuddy
All Implemented Interfaces:
Buddy

public class SFSBuddy
extends java.lang.Object
implements Buddy

The SFSBuddy object represents a buddy in the current user's buddies list.

A buddy is marked out by the following characteristics.

See Also:
SmartFox.buddyManager, BuddyVariable

Constructor Summary
SFSBuddy(int id, java.lang.String name)
           
SFSBuddy(int id, java.lang.String name, boolean isBlocked)
           
SFSBuddy(int id, java.lang.String name, boolean isBlocked, boolean isTemp)
          Creates a new SFSBuddy instance.
 
Method Summary
 void clearVolatileVariables()
          *Private*
 boolean containsVariable(java.lang.String varName)
          Indicates whether this buddy has the specified Buddy Variable set or not.
static Buddy fromSFSArray(com.smartfoxserver.v2.entities.data.ISFSArray arr)
           
 int getId()
          Indicates the id of this buddy.
 java.lang.String getName()
          Indicates the name of this buddy.
 java.lang.String getNickName()
          Returns the nickname of this buddy.
 java.util.List<BuddyVariable> getOfflineVariables()
          Retrieves the list of persistent Buddy Variables of this buddy.
 java.util.List<BuddyVariable> getOnlineVariables()
          Retrieves the list of non-persistent Buddy Variables of this buddy.
 java.lang.String getState()
          Returns the custom state of this buddy.
 BuddyVariable getVariable(java.lang.String varName)
          Retrieves a Buddy Variable from its name.
 java.util.List<BuddyVariable> getVariables()
          Returns a list of BuddyVariable objects associated with the buddy.
 boolean isBlocked()
          Indicates whether this buddy is blocked in the current user's buddies list or not.
 boolean isOnline()
          Indicates whether this buddy is temporary (non-persistent) in the current user's buddies list or not.
 boolean isTemp()
          Return true if the Buddy is temporary (not persistent)
 void removeVariable(java.lang.String varName)
          *Private*
 void setBlocked(boolean blocked)
          *Private*
 void setId(int id)
          *Private*
 void setVariable(BuddyVariable bVar)
          *Private*
 void setVariables(java.util.List<BuddyVariable> variables)
          *Private*
 java.lang.String toString()
          Returns a string that contains the buddy name and id.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SFSBuddy

public SFSBuddy(int id,
                java.lang.String name,
                boolean isBlocked,
                boolean isTemp)
Creates a new SFSBuddy instance.

NOTE: developers never instantiate a SFSBuddy manually: this is done by the SmartFoxServer 2X API internally.

Parameters:
id - The buddy id.
name - The buddy name.
isBlocked - If true, the buddy being created is blocked by the current user.
isTemp - If true, the buddy being created is temporary in the current client.

SFSBuddy

public SFSBuddy(int id,
                java.lang.String name,
                boolean isBlocked)

SFSBuddy

public SFSBuddy(int id,
                java.lang.String name)
Method Detail

fromSFSArray

public static Buddy fromSFSArray(com.smartfoxserver.v2.entities.data.ISFSArray arr)

getId

public int getId()
Description copied from interface: Buddy
Indicates the id of this buddy. This is equal to the id assigned by SmartFoxServer to the corresponding user.

Specified by:
getId in interface Buddy
See Also:
User.getId()

getName

public java.lang.String getName()
Description copied from interface: Buddy
Indicates the name of this buddy. This is equal to the name of the corresponding user.

Specified by:
getName in interface Buddy
See Also:
User.getName()

isBlocked

public boolean isBlocked()
Description copied from interface: Buddy
Indicates whether this buddy is blocked in the current user's buddies list or not. A buddy can be blocked by means of a BlockBuddyRequest request.

Specified by:
isBlocked in interface Buddy
See Also:
BlockBuddyRequest

isOnline

public boolean isOnline()
Description copied from interface: Buddy
Indicates whether this buddy is temporary (non-persistent) in the current user's buddies list or not.

Specified by:
isOnline in interface Buddy

isTemp

public boolean isTemp()
Description copied from interface: Buddy
Return true if the Buddy is temporary (not persistent)

Specified by:
isTemp in interface Buddy

getState

public java.lang.String getState()
Description copied from interface: Buddy
Returns the custom state of this buddy. Examples of custom states are "Available", "Busy", "Be right back", etc. If the custom state is not set, null is returned.

The list of available custom states is returned by the IBuddyManager.buddyStates property.

Specified by:
getState in interface Buddy
See Also:
IBuddyManager.getBuddyStates()

getNickName

public java.lang.String getNickName()
Description copied from interface: Buddy
Returns the nickname of this buddy. If the nickname is not set, null is returned.

Specified by:
getNickName in interface Buddy

getVariables

public java.util.List<BuddyVariable> getVariables()
Description copied from interface: Buddy
Returns a list of BuddyVariable objects associated with the buddy.

Specified by:
getVariables in interface Buddy
See Also:
BuddyVariable, Buddy.getVariable(String)

getVariable

public BuddyVariable getVariable(java.lang.String varName)
Description copied from interface: Buddy
Retrieves a Buddy Variable from its name.

Specified by:
getVariable in interface Buddy
Parameters:
varName - The name of the Buddy Variable to be retrieved.
Returns:
The BuddyVariable object representing the Buddy Variable, or null if no Buddy Variable with the passed name is associated with this buddy.
See Also:
Buddy.getVariables(), SetBuddyVariablesRequest

containsVariable

public boolean containsVariable(java.lang.String varName)
Description copied from interface: Buddy
Indicates whether this buddy has the specified Buddy Variable set or not.

Specified by:
containsVariable in interface Buddy
Parameters:
varName - The name of the Buddy Variable whose existance must be checked.
Returns:
true if a Buddy Variable with the passed name is set for this buddy.

getOfflineVariables

public java.util.List<BuddyVariable> getOfflineVariables()
Description copied from interface: Buddy
Retrieves the list of persistent Buddy Variables of this buddy.

Specified by:
getOfflineVariables in interface Buddy
Returns:
An array of BuddyVariable objects.
See Also:
BuddyVariable.isOffline

getOnlineVariables

public java.util.List<BuddyVariable> getOnlineVariables()
Description copied from interface: Buddy
Retrieves the list of non-persistent Buddy Variables of this buddy.

Specified by:
getOnlineVariables in interface Buddy
Returns:
An array of BuddyVariable objects.
See Also:
BuddyVariable.isOffline

setVariable

public void setVariable(BuddyVariable bVar)
Description copied from interface: Buddy
*Private*

Specified by:
setVariable in interface Buddy

setVariables

public void setVariables(java.util.List<BuddyVariable> variables)
*Private*

Specified by:
setVariables in interface Buddy

setId

public void setId(int id)
Description copied from interface: Buddy
*Private*

Specified by:
setId in interface Buddy

setBlocked

public void setBlocked(boolean blocked)
*Private*

Specified by:
setBlocked in interface Buddy

removeVariable

public void removeVariable(java.lang.String varName)
*Private*

Specified by:
removeVariable in interface Buddy

clearVolatileVariables

public void clearVolatileVariables()
*Private*

Specified by:
clearVolatileVariables in interface Buddy

toString

public java.lang.String toString()
Returns a string that contains the buddy name and id.

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