core
Class Contact

java.lang.Object
  extended bycore.Contact

public class Contact
extends java.lang.Object

A representation of another user's attributes, including presence, network, and subscription information.

Author:
hoela

Constructor Summary
Contact(java.lang.String nickname, java.lang.String address)
           
Contact(java.lang.String username, java.lang.String nickname, java.lang.String address, java.lang.String additionalInfo)
           
Contact(java.lang.String userName, java.lang.String nickname, java.lang.String additionalInfo, java.lang.String address, java.lang.String subscription, boolean pendingIn, boolean pendingOut)
           
 
Method Summary
 java.lang.String getAdditionalInfo()
           
 java.lang.String getAddress()
           
 java.lang.String getNickname()
           
 PresenceType getPresence()
           
 java.lang.String getShow()
           
 java.lang.String getStatus()
           
 java.lang.String getSubscription()
          Returns the subscription status of this user.
 long getTimestamp()
           
 java.lang.String getUserName()
           
 boolean isPendingIn()
          Determines if there are incoming subscription requests pending for this Contact.
 boolean isPendingOut()
          Determines if there are outgoing subscription requests pending for this Contact.
 boolean probe()
          Sets the number of probes sent to this Contact so far.
 void reset()
          Resets the probe variable to indicate that the Contact has recently responded to a probe message.
 void setAdditionalInfo(java.lang.String additionalInfo)
           
 void setAddress(java.lang.String address)
          Care should be taken when using this method.
 void setNickname(java.lang.String nickname)
           
 void setPendingIn(boolean pendingIn)
          Specifies whether or not incoming subscription requests are pending for this Contact.
 void setPendingOut(boolean pendingOut)
          Specifies whether or not outgoing subscription requests are pending for this Contact.
 void setPresence(PresenceType presence)
           
 void setShow(java.lang.String show)
           
 void setStatus(java.lang.String status)
           
 void setSubscription(java.lang.String subscription)
          Sets the subscription status of this user.
 void setTimestamp(long timestamp)
           
 java.lang.String toString()
          This is what is displayed as the text of the Contact list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Contact

public Contact(java.lang.String nickname,
               java.lang.String address)
Parameters:
address -
nickname -

Contact

public Contact(java.lang.String username,
               java.lang.String nickname,
               java.lang.String address,
               java.lang.String additionalInfo)
Parameters:
username - the contact's default username, used for logging in.
nickname - the contact's advertised name, or the name set by the user.
address - the virtual address of the contact.
additionalInfo - additional information advertised by the contact.

Contact

public Contact(java.lang.String userName,
               java.lang.String nickname,
               java.lang.String additionalInfo,
               java.lang.String address,
               java.lang.String subscription,
               boolean pendingIn,
               boolean pendingOut)
Parameters:
userName - the contact's default username, used for logging in.
nickname - the contact's advertised name, or the name set by the user.
additionalInfo - additional information advertised by the contact.
address - the virtual address of the contact.
subscription - the subscription status of the contact.
pendingIn - true if the contact has subscription requests pending in.
pendingOut - true if the contact has subscription requests pending out.
Method Detail

getAddress

public java.lang.String getAddress()
Returns:
Returns the virtual address of this Contact.

getUserName

public java.lang.String getUserName()
Returns:
Returns the Contact's userName.

getPresence

public PresenceType getPresence()
Returns:
Returns the Contact's presence status.

setPresence

public void setPresence(PresenceType presence)
Parameters:
presence - The presence to set.

getShow

public java.lang.String getShow()
Returns:
Returns the away message set by this Contact.

setShow

public void setShow(java.lang.String show)
Parameters:
show - The away message to set for this Contact.

getStatus

public java.lang.String getStatus()
Returns:
Returns the away status of this Contact.

setStatus

public void setStatus(java.lang.String status)
Parameters:
status - The away status to set for this Contact.

getNickname

public java.lang.String getNickname()
Returns:
Returns the Contact's nickname.

getAdditionalInfo

public java.lang.String getAdditionalInfo()
Returns:
Returns the Contact's additional information.

getTimestamp

public long getTimestamp()
Returns:
Returns the timestamp of the last message recieved from this Contact.

setTimestamp

public void setTimestamp(long timestamp)
Parameters:
timestamp - Sets the timestamp of the last message received from this Contact.

setNickname

public void setNickname(java.lang.String nickname)
Parameters:
nickname - The nickname to set for this Contact.

isPendingIn

public boolean isPendingIn()
Determines if there are incoming subscription requests pending for this Contact.

Returns:
true if requests are pending in; false otherwise

setPendingIn

public void setPendingIn(boolean pendingIn)
Specifies whether or not incoming subscription requests are pending for this Contact.

Parameters:
pendingIn - true to set true, false to set false

isPendingOut

public boolean isPendingOut()
Determines if there are outgoing subscription requests pending for this Contact.

Returns:
true if requests are pending out; false otherwise

setPendingOut

public void setPendingOut(boolean pendingOut)
Specifies whether or not outgoing subscription requests are pending for this Contact.

Parameters:
pendingOut - true to set true, false to set false

getSubscription

public java.lang.String getSubscription()
Returns the subscription status of this user. The possible subscriptions are as follows: (similiar to RFC 3921). "both" means that both the user and the contact are subscribed to each other. "from" means that the contact is subscribed to the user, but the user is not subscribed to the contact. "to" means that the user is subscribed to the contact, but the contact is not subscribed to the user. "none" means neither the user nor the contact is subscribed to each other.

Returns:
The subscription status of this user.

setSubscription

public void setSubscription(java.lang.String subscription)
Sets the subscription status of this user.

Parameters:
subscription - the string "both", "to", "from", or "none"

toString

public java.lang.String toString()
This is what is displayed as the text of the Contact list.

Returns:
A String representing this Contact.

setAdditionalInfo

public void setAdditionalInfo(java.lang.String additionalInfo)
Parameters:
additionalInfo - The additional info to set.

probe

public boolean probe()
Sets the number of probes sent to this Contact so far. Increments on each call to indicate whether or not the Contact has recently responded to probe messages.

Returns:
true if this Contact has responded to one of the previous 2 probe messages, false otherwise.

reset

public void reset()
Resets the probe variable to indicate that the Contact has recently responded to a probe message.


setAddress

public void setAddress(java.lang.String address)
Care should be taken when using this method. At the moment, this is only used to change UnknownUser's address in ContactList.

Parameters:
address - the address to set for this Contact.