SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol
Class AccountID

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AccountID
Direct Known Subclasses:
AccountIDGibberishImpl, DictAccountID, GibberishAccountID, IcqAccountID, IrcAccountID, JabberAccountID, MockAccountID, MsnAccountID, RssAccountID, SipAccountID, SSHAccountID, YahooAccountID, ZeroconfAccountID

public abstract class AccountID
extends Object

The AccountID is an account identifier that, uniquely represents a specific user account over a specific protocol. The class needs to be extended by every protocol implementation because of its protected constructor. The reason why this constructor is protected is mostly avoiding confusion and letting people (using the protocol provider service) believe that they are the ones who are supposed to instantiate the accountid class.

Every instance of the ProtocolProviderService, created through the ProtocolProviderFactory is assigned an AccountID instance, that uniquely represents it and whose string representation (obtained through the getAccountUID() method) can be used for identification of persistently stored account details.

Account id's are guaranteed to be different for different accounts and in the same time are bound to be equal for multiple installations of the same account.

Author:
Emil Ivov, Lubomir Marinov

Field Summary
protected  Map<String,String> accountProperties
          Contains all implementation specific properties that define the account.
 
Constructor Summary
protected AccountID(String userID, Map<String,String> accountProperties, String protocolName, String serviceName)
          Creates an account id for the specified provider userid and accountProperties.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this account id.
 String getAccountAddress()
          Returns a string that could be directly used (or easily converted to) an address that other users of the protocol can use to communicate with us.
 Map<String,String> getAccountProperties()
          Returns a Map containing protocol and implementation account initialization properties.
 Object getAccountProperty(Object key)
           
 boolean getAccountPropertyBoolean(Object key, boolean defaultValue)
           
 int getAccountPropertyInt(Object key, int defaultValue)
          Gets the value of a specific property as a signed decimal integer.
 String getAccountPropertyString(Object key)
           
 String getAccountUniqueID()
          Returns a String uniquely identifying this account, guaranteed to remain the same across multiple installations of the same account and to always be unique for differing accounts.
 String getDisplayName()
          Returns a name that can be displayed to the user when referring to this account.
 String getProtocolDisplayName()
          Returns the display name of the protocol.
 String getProtocolName()
          Returns the name of the protocol.
 String getService()
          Returns the name of the service that defines the context for this account.
 String getUserID()
          Returns the user id associated with this account.
 int hashCode()
          Returns a hash code value for the object.
 boolean isEnabled()
          Indicates if this account is currently enabled.
 void putAccountProperty(String key, String value)
          Adds a property to the map of properties for this account identifier.
 void setAccountProperties(Map<String,String> accountProperties)
          Set the account properties.
 String toString()
          Returns a string representation of this account id (same as calling getAccountUniqueID()).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

accountProperties

protected Map<String,String> accountProperties
Contains all implementation specific properties that define the account. The exact names of the keys are protocol (and sometimes implementation) specific. Currently, only String property keys and values will get properly stored. If you need something else, please consider converting it through custom accessors (get/set) in your implementation.

Constructor Detail

AccountID

protected AccountID(String userID,
                    Map<String,String> accountProperties,
                    String protocolName,
                    String serviceName)
Creates an account id for the specified provider userid and accountProperties.

Parameters:
userID - a String that uniquely identifies the user.
accountProperties - a Map containing any other protocol and implementation specific account initialization properties
protocolName - the name of the protocol implemented by the provider that this id is meant for.
serviceName - the name of the service (e.g. iptel.org, jabber.org, icq.com) that this account is registered with.
Method Detail

getUserID

public String getUserID()
Returns the user id associated with this account.

Returns:
A String identifying the user inside this particular service.

getDisplayName

public String getDisplayName()
Returns a name that can be displayed to the user when referring to this account.

Returns:
A String identifying the user inside this particular service.

getProtocolDisplayName

public String getProtocolDisplayName()
Returns the display name of the protocol.

Returns:
the display name of the protocol

getProtocolName

public String getProtocolName()
Returns the name of the protocol.

Returns:
the name of the protocol

getAccountUniqueID

public String getAccountUniqueID()
Returns a String uniquely identifying this account, guaranteed to remain the same across multiple installations of the same account and to always be unique for differing accounts.

Returns:
String

getAccountProperties

public Map<String,String> getAccountProperties()
Returns a Map containing protocol and implementation account initialization properties.

Returns:
a Map containing protocol and implementation account initialization properties.

getAccountProperty

public Object getAccountProperty(Object key)

getAccountPropertyBoolean

public boolean getAccountPropertyBoolean(Object key,
                                         boolean defaultValue)

getAccountPropertyInt

public int getAccountPropertyInt(Object key,
                                 int defaultValue)
Gets the value of a specific property as a signed decimal integer. If the specified property key is associated with a value in this AccountID, the string representation of the value is parsed into a signed decimal integer according to the rules of Integer.parseInt(String) . If parsing the value as a signed decimal integer fails or there is no value associated with the specified property key, defaultValue is returned.

Parameters:
key - the key of the property to get the value of as a signed decimal integer
defaultValue - the value to be returned if parsing the value of the specified property key as a signed decimal integer fails or there is no value associated with the specified property key in this AccountID
Returns:
the value of the property with the specified key in this AccountID as a signed decimal integer; defaultValue if parsing the value of the specified property key fails or no value is associated in this AccountID with the specified property name

getAccountPropertyString

public String getAccountPropertyString(Object key)

putAccountProperty

public void putAccountProperty(String key,
                               String value)
Adds a property to the map of properties for this account identifier.

Parameters:
key - the key of the property
value - the property value

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this account id.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
hashCode(), Hashtable

toString

public String toString()
Returns a string representation of this account id (same as calling getAccountUniqueID()).

Overrides:
toString in class Object
Returns:
a string representation of this account id.

getService

public String getService()
Returns the name of the service that defines the context for this account. Often this name would be an sqdn or even an ipaddress but this would not always be the case (e.g. p2p providers may return a name that does not directly correspond to an IP address or host name).

Returns:
the name of the service that defines the context for this account.

getAccountAddress

public String getAccountAddress()
Returns a string that could be directly used (or easily converted to) an address that other users of the protocol can use to communicate with us. By default this string is set to userid@servicename. Protocol implementors should override it if they'd need it to respect a different syntax.

Returns:
a String in the form of userid@service that other protocol users should be able to parse into a meaningful address and use it to communicate with us.

isEnabled

public boolean isEnabled()
Indicates if this account is currently enabled.

Returns:
true if this account is enabled, false - otherwise.

setAccountProperties

public void setAccountProperties(Map<String,String> accountProperties)
Set the account properties.

Parameters:
accountProperties - the properties of the account

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.