com.funambol.mail
Class Address

java.lang.Object
  extended by com.funambol.mail.Address

public class Address
extends java.lang.Object

A class describing the RFC 2822 address specification as per par. 3.4


Field Summary
static int BCC
          Address is used in a BCC recipient
static int CC
          Address is used in a CC recipient
static int FROM
          Address is used in a FROM recipient
static int REPLYTO
          Address is used in a REPLYTO recipient
static int TO
          Address is used in a TO recipient
 
Constructor Summary
Address()
          Default Constructor
Address(int type, java.lang.String address)
          Initializes a new instance of Address, parsing address.
Address(int type, java.lang.String name, java.lang.String address)
          Initializes a new instance of Address
 
Method Summary
 java.lang.String getEmail()
          Accessor method to get this address email field
 java.lang.String getName()
          Accessor method to get this address name field
 int getType()
          Accessor method to get the type of this address
 java.lang.String getVisibleName()
          Accessor method to get this address' visible name representation:
static Address[] parse(int type, java.lang.String addresslist)
          Parses an address list and return an array of Address objects, each representing a recipient.
 void setEmail(java.lang.String email)
          Accessor method to set this address' email
 void setName(java.lang.String name)
          Accessor method to set the name of this address
 void setType(int type)
          Accessor method to set the type of this address
 java.lang.String toString()
          Overloads toString() Object' method to return this address representation in RFC2822 format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FROM

public static final int FROM
Address is used in a FROM recipient

See Also:
Constant Field Values

TO

public static final int TO
Address is used in a TO recipient

See Also:
Constant Field Values

CC

public static final int CC
Address is used in a CC recipient

See Also:
Constant Field Values

BCC

public static final int BCC
Address is used in a BCC recipient

See Also:
Constant Field Values

REPLYTO

public static final int REPLYTO
Address is used in a REPLYTO recipient

See Also:
Constant Field Values
Constructor Detail

Address

public Address()
Default Constructor


Address

public Address(int type,
               java.lang.String address)
        throws MailException
Initializes a new instance of Address, parsing address. If address contains more than one email address, only the first one is used and the others are ignored. Use Adress.parse to get an array of Address from an address list.

Parameters:
type - is the type of this address
address - is the String representation of the address to be parsed
Throws:
MailException - when some error occurs parsing address

Address

public Address(int type,
               java.lang.String name,
               java.lang.String address)
        throws MailException
Initializes a new instance of Address

Parameters:
type - is the type of address
name - is the name of the Address
address - is the email of this address
Throws:
MailException
Method Detail

getType

public int getType()
Accessor method to get the type of this address

Returns:
int representation of this address' type

getVisibleName

public java.lang.String getVisibleName()
Accessor method to get this address' visible name representation:

Returns:
this address name if it is not null, this address email otherwise

getName

public java.lang.String getName()
Accessor method to get this address name field

Returns:
String representation of this address name field

getEmail

public java.lang.String getEmail()
Accessor method to get this address email field

Returns:
String representation of this address email field (may be null)

setType

public void setType(int type)
Accessor method to set the type of this address

Parameters:
type - is the type to be set for this address

setName

public void setName(java.lang.String name)
Accessor method to set the name of this address

Parameters:
name - is the name to be set for this address

setEmail

public void setEmail(java.lang.String email)
              throws MailException
Accessor method to set this address' email

Parameters:
email - is the email string value to be set
Throws:
MailException - if some error occurs while check address' email

parse

public static Address[] parse(int type,
                              java.lang.String addresslist)
                       throws MailException
Parses an address list and return an array of Address objects, each representing a recipient. Use: Address [] list = Address.parse( Address.TO, "John Doe "

Parameters:
addresslist - the comma separated list of addresses
Returns:
an array of Address containing the result, or an empty array if addresslist is empty
Throws:
MailException - if the address is malformed

toString

public java.lang.String toString()
Overloads toString() Object' method to return this address representation in RFC2822 format

Overrides:
toString in class java.lang.Object
Returns:
the string representation of the Address


Copyright © 2001-2009 Funambol.