Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber.extensions.mailnotification
Class MailThreadInfo

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.jabber.extensions.mailnotification.MailThreadInfo

public class MailThreadInfo
extends Object

This class represents the "mail-thread-info" element the Google use in their mail notifications to deliver detailed thread information.

Author:
Emil Ivov

Nested Class Summary
 class MailThreadInfo.Sender
          The class describes a single participant in this email thread.
 
Field Summary
static String ELEMENT_NAME
          The name of the "mail-thread-info" element.
static String LABELS_ELEMENT_NAME
          The name of the XML tag element containing a pipe separated list of labels assigned to this thread.
static int PARTICIPATION_NONE
          Indicates that the local user has not participated in this thread.
static int PARTICIPATION_ONE_OF_MANY
          Indicates that the user is one of many recipients listed in the thread.
static int PARTICIPATION_SOLE_RECIPIENT
          PARTICIPATION_SOLE_RECIPIENT indicates that the user is the sole recipient for messages in this thread.
static String SENDERS_ELEMENT_NAME
          The name of the XML tag element containing the list of all senders.
static String SNIPPET_ELEMENT_NAME
          The name of the XML tag element containing a snippet of the thread.
static String SUBJECT_ELEMENT_NAME
          The name of the XML tag element containing the thread subject.
 
Constructor Summary
MailThreadInfo()
           
 
Method Summary
protected  void addSender(MailThreadInfo.Sender sender)
          Adds sender to the list of senders in this thread.
 String createHtmlDescription()
          Creates an html description (table rows) of the specified thread.
 String findOriginator(boolean firstNameOnly)
          Returns the sender that initiated the thread or the first sender in the list if for some reason we couldn't determine the originator.
 long getDate()
          Returns the date of the most recent message in this thread.
 String getLabels()
          Returns a pipe ('|') delimited list of labels applied to this thread.
 int getMessageCount()
          Returns the number of messages in this thread.
 int getParticipation()
          Returns the participation index for this thread.
 int getSenderCount()
          Returns the number of people that have been posting in this thread.
 String getSnippet()
          Returns an html-encoded snippet from the body of the email.
 String getSubject()
          Returns the subject of this e-mail thread.
 String getTid()
          Returns the ID of this thread.
 int getUnreadSenderCount()
          Returns the number of people that have been posting in this thread and that we have unread messages from.
 String getURL()
          Returns an URL linking to this thread.
static MailThreadInfo parse(org.xmlpull.v1.XmlPullParser parser)
          Creates and initializes a MailThreadInfo instance according to the details that come with the parser.
 Iterator<MailThreadInfo.Sender> senders()
          Returns an iterator over a list of one or more sender instances, each of which describes a participant in this thread.
protected  void setDate(long date)
          Sets the date of the most recent message in this thread.
protected  void setLabels(String labels)
          Sets a pipe ('|') delimited list of labels that apply to this thread.
protected  void setMessageCount(int messageCount)
          Sets the number of messages in this thread.
protected  void setParticipation(int participation)
          Specifies the participation index for this thread.
protected  void setSnippet(String snippet)
          Sets an html-encoded snippet from the body of the email.
protected  void setSubject(String subject)
          Sets the subject of this e-mail thread.
protected  void setTid(String tid)
          Specifies the ID of this thread.
protected  void setURL(String url)
          Sets an URL linking to this thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT_NAME

public static final String ELEMENT_NAME
The name of the "mail-thread-info" element.

See Also:
Constant Field Values

SENDERS_ELEMENT_NAME

public static final String SENDERS_ELEMENT_NAME
The name of the XML tag element containing the list of all senders.

See Also:
Constant Field Values

LABELS_ELEMENT_NAME

public static final String LABELS_ELEMENT_NAME
The name of the XML tag element containing a pipe separated list of labels assigned to this thread.

See Also:
Constant Field Values

SUBJECT_ELEMENT_NAME

public static final String SUBJECT_ELEMENT_NAME
The name of the XML tag element containing the thread subject.

See Also:
Constant Field Values

SNIPPET_ELEMENT_NAME

public static final String SNIPPET_ELEMENT_NAME
The name of the XML tag element containing a snippet of the thread.

See Also:
Constant Field Values

PARTICIPATION_NONE

public static final int PARTICIPATION_NONE
Indicates that the local user has not participated in this thread.

See Also:
Constant Field Values

PARTICIPATION_ONE_OF_MANY

public static final int PARTICIPATION_ONE_OF_MANY
Indicates that the user is one of many recipients listed in the thread.

See Also:
Constant Field Values

PARTICIPATION_SOLE_RECIPIENT

public static final int PARTICIPATION_SOLE_RECIPIENT
PARTICIPATION_SOLE_RECIPIENT indicates that the user is the sole recipient for messages in this thread.

See Also:
Constant Field Values
Constructor Detail

MailThreadInfo

public MailThreadInfo()
Method Detail

getParticipation

public int getParticipation()
Returns the participation index for this thread. The participation index is a number indicating the local user's participation level in this thread: PARTICIPATION_NONE indicates that the user has not participated; PARTICIPATION_ONE_OF_MANY indicates that the user is one of many recipients listed in the thread; PARTICIPATION_SOLE_RECIPIENT indicates that the user is the sole recipient for messages in this thread.

Returns:
one of the PARTICIPATION_XXX values defines in this class and indicating whether the local is the sole, one of many or not a participant of this thread.

setParticipation

protected void setParticipation(int participation)
Specifies the participation index for this thread. The participation index is a number indicating the local user's participation level in this thread: PARTICIPATION_NONE indicates that the user has not participated; PARTICIPATION_ONE_OF_MANY indicates that the user is one of many recipients listed in the thread; PARTICIPATION_SOLE_RECIPIENT indicates that the user is the sole recipient for messages in this thread.

Parameters:
participation - one of the PARTICIPATION_XXX values defines in this class and indicating whether the local is the sole, one of many or not a participant of this thread.

senders

public Iterator<MailThreadInfo.Sender> senders()
Returns an iterator over a list of one or more sender instances, each of which describes a participant in this thread.

Returns:
an iterator over a list of one or more sender instances, each of which describes a participant in this thread.

getSenderCount

public int getSenderCount()
Returns the number of people that have been posting in this thread.

Returns:
the number of people that have been posting in this thread.

getUnreadSenderCount

public int getUnreadSenderCount()
Returns the number of people that have been posting in this thread and that we have unread messages from.

Returns:
the number of people that have been posting in this thread and that we have unread messages from.

findOriginator

public String findOriginator(boolean firstNameOnly)
Returns the sender that initiated the thread or the first sender in the list if for some reason we couldn't determine the originator.

Parameters:
firstNameOnly - use only first name
Returns:
the sender that initiated the thread or the first sender in the list if for some reason we couldn't determine the originator.

addSender

protected void addSender(MailThreadInfo.Sender sender)
Adds sender to the list of senders in this thread.

Parameters:
sender - the sender that we are adding.

getMessageCount

public int getMessageCount()
Returns the number of messages in this thread.

Returns:
the number of messages in this thread.

setMessageCount

protected void setMessageCount(int messageCount)
Sets the number of messages in this thread.

Parameters:
messageCount - the number of messages in this thread.

getDate

public long getDate()
Returns the date of the most recent message in this thread.

Returns:
a timestamp of the most recent message, in milliseconds since the UNIX epoch.

setDate

protected void setDate(long date)
Sets the date of the most recent message in this thread.

Parameters:
date - a timestamp of the most recent message in this thread.

getURL

public String getURL()
Returns an URL linking to this thread. It is important to distinguish between this URL and the one returned by the MailboxIQ which points to the whole mailbox.

Returns:
the URL linking to this particular thread.

setURL

protected void setURL(String url)
Sets an URL linking to this thread. It is important to distinguish between this URL and the one returned by the MailboxIQ which points to the whole mailbox.

Parameters:
url - the URL linking to this particular thread.

getLabels

public String getLabels()
Returns a pipe ('|') delimited list of labels applied to this thread.

Returns:
a pipe ('|') delimited list of labels applied to this thread.

setLabels

protected void setLabels(String labels)
Sets a pipe ('|') delimited list of labels that apply to this thread.

Parameters:
labels - a pipe ('|') delimited list of labels that apply to this thread.

getTid

public String getTid()
Returns the ID of this thread.

Returns:
the ID of this thread.

setTid

protected void setTid(String tid)
Specifies the ID of this thread.

Parameters:
tid - the ID of this thread.

getSubject

public String getSubject()
Returns the subject of this e-mail thread.

Returns:
the subject of this e-mail thread.

setSubject

protected void setSubject(String subject)
Sets the subject of this e-mail thread.

Parameters:
subject - the subject of this e-mail thread.

getSnippet

public String getSnippet()
Returns an html-encoded snippet from the body of the email.

Returns:
an html-encoded snippet from the body of the email.

setSnippet

protected void setSnippet(String snippet)
Sets an html-encoded snippet from the body of the email.

Parameters:
snippet - an html-encoded snippet from the body of the email.

parse

public static MailThreadInfo parse(org.xmlpull.v1.XmlPullParser parser)
                            throws org.xmlpull.v1.XmlPullParserException,
                                   NumberFormatException,
                                   IOException
Creates and initializes a MailThreadInfo instance according to the details that come with the parser.

Parameters:
parser - the parse that we are to read the MailThreadInfo from.
Returns:
the newly created MailThreadInfo instance.
Throws:
org.xmlpull.v1.XmlPullParserException - if something goes wrong while parsing the document.
NumberFormatException - in case we fail to parse any of the elements that we expect to be numerical.
IOException - in case reading the input xml fails.

createHtmlDescription

public String createHtmlDescription()
Creates an html description (table rows) of the specified thread.

Returns:
an html description of thread

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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