javax.mail.internet
Class NewsAddress


java.lang.Object

  |

  +--javax.mail.Address

        |

        +--javax.mail.internet.NewsAddress


public class NewsAddress
extends Address

This class models an RFC1036 newsgroup address.


Field Summary
protected  java.lang.String host
           
protected  java.lang.String newsgroup
           
 
Constructor Summary
NewsAddress()
          Default constructor.
NewsAddress(java.lang.String newsgroup)
          Construct a NewsAddress with the given newsgroup.
NewsAddress(java.lang.String newsgroup, java.lang.String host)
          Construct a NewsAddress with the given newsgroup and host.
 
Method Summary
 boolean equals(java.lang.Object a)
          The equality operator.
 java.lang.String getHost()
          Get the host.
 java.lang.String getNewsgroup()
          Get the newsgroup.
 java.lang.String getType()
          Return the type of this address.
 int hashCode()
          Compute a hash code for the address.
static NewsAddress[] parse(java.lang.String newsgroups)
          Parse the given comma separated sequence of newsgroup into NewsAddress objects.
 void setHost(java.lang.String host)
          Set the host.
 void setNewsgroup(java.lang.String newsgroup)
          Set the newsgroup.
 java.lang.String toString()
          Convert this address into a RFC 1036 address.
static java.lang.String toString(Address[] addresses)
          Convert the given array of NewsAddress objects into a comma separated sequence of address strings.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

newsgroup


protected java.lang.String newsgroup

host


protected java.lang.String host
Constructor Detail

NewsAddress


public NewsAddress()
Default constructor.

NewsAddress


public NewsAddress(java.lang.String newsgroup)
Construct a NewsAddress with the given newsgroup.
Parameters:
newsgroup - the newsgroup

NewsAddress


public NewsAddress(java.lang.String newsgroup,

                   java.lang.String host)
Construct a NewsAddress with the given newsgroup and host.
Parameters:
newsgroup - the newsgroup
host - the host
Method Detail

getType


public java.lang.String getType()
Return the type of this address. The type of a NewsAddress is "news".
Overrides:
getType in class Address

setNewsgroup


public void setNewsgroup(java.lang.String newsgroup)
Set the newsgroup.
Parameters:
newsgroup - the newsgroup

getNewsgroup


public java.lang.String getNewsgroup()
Get the newsgroup.
Returns:
newsgroup

setHost


public void setHost(java.lang.String host)
Set the host.
Parameters:
host - the host

getHost


public java.lang.String getHost()
Get the host.
Returns:
host

toString


public java.lang.String toString()
Convert this address into a RFC 1036 address.
Returns:
newsgroup
Overrides:
toString in class Address

equals


public boolean equals(java.lang.Object a)
The equality operator.
Overrides:
equals in class Address

hashCode


public int hashCode()
Compute a hash code for the address.
Overrides:
hashCode in class java.lang.Object

toString


public static java.lang.String toString(Address[] addresses)
Convert the given array of NewsAddress objects into a comma separated sequence of address strings. The resulting string contains only US-ASCII characters, and hence is mail-safe.
Parameters:
addresses - array of NewsAddress objects
Returns:
comma separated address strings
Throws:
ClassCastException, - if any address object in the given array is not a NewsAddress objects. Note that this is a RuntimeException.

parse


public static NewsAddress[] parse(java.lang.String newsgroups)

                           throws AddressException
Parse the given comma separated sequence of newsgroup into NewsAddress objects.
Parameters:
newsgroups - comma separated newsgroup string
Returns:
array of NewsAddress objects
Throws:
AddressException - if the parse failed