org.apache.james.mime4j.field.address
Class Mailbox

java.lang.Object
  extended by org.apache.james.mime4j.field.address.Address
      extended by org.apache.james.mime4j.field.address.Mailbox
All Implemented Interfaces:
java.io.Serializable

public class Mailbox
extends Address

Represents a single e-mail address.

See Also:
Serialized Form

Constructor Summary
Mailbox(DomainList route, java.lang.String localPart, java.lang.String domain)
          Creates an unnamed mailbox with a route.
Mailbox(java.lang.String name, DomainList route, java.lang.String localPart, java.lang.String domain)
          Creates a named mailbox with a route.
Mailbox(java.lang.String localPart, java.lang.String domain)
          Creates an unnamed mailbox without a route.
Mailbox(java.lang.String name, java.lang.String localPart, java.lang.String domain)
          Creates a named mailbox without a route.
 
Method Summary
protected  void doAddMailboxesTo(java.util.List<Mailbox> results)
          Adds any mailboxes represented by this address into the given List.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this mailbox.
 java.lang.String getAddress()
          Returns the address in the form localPart@domain.
 java.lang.String getDisplayString(boolean includeRoute)
          Formats the address as a human readable string, not including the route.
 java.lang.String getDomain()
          Returns the right part of the e-mail address (after "@").
 java.lang.String getEncodedString()
          Returns a string representation of this address that can be used for transport purposes.
 java.lang.String getLocalPart()
          Returns the left part of the e-mail address (before "@").
 java.lang.String getName()
          Returns the name of the mailbox or null if it does not have a name.
 DomainList getRoute()
          Returns the route list.
 int hashCode()
           
static Mailbox parse(java.lang.String rawMailboxString)
          Parses the specified raw string into a mailbox address.
 
Methods inherited from class org.apache.james.mime4j.field.address.Address
getDisplayString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mailbox

public Mailbox(java.lang.String localPart,
               java.lang.String domain)
Creates an unnamed mailbox without a route. Routes are obsolete.

Parameters:
localPart - The part of the e-mail address to the left of the "@".
domain - The part of the e-mail address to the right of the "@".

Mailbox

public Mailbox(DomainList route,
               java.lang.String localPart,
               java.lang.String domain)
Creates an unnamed mailbox with a route. Routes are obsolete.

Parameters:
route - The zero or more domains that make up the route. May be null.
localPart - The part of the e-mail address to the left of the "@".
domain - The part of the e-mail address to the right of the "@".

Mailbox

public Mailbox(java.lang.String name,
               java.lang.String localPart,
               java.lang.String domain)
Creates a named mailbox without a route. Routes are obsolete.

Parameters:
name - the name of the e-mail address. May be null.
localPart - The part of the e-mail address to the left of the "@".
domain - The part of the e-mail address to the right of the "@".

Mailbox

public Mailbox(java.lang.String name,
               DomainList route,
               java.lang.String localPart,
               java.lang.String domain)
Creates a named mailbox with a route. Routes are obsolete.

Parameters:
name - the name of the e-mail address. May be null.
route - The zero or more domains that make up the route. May be null.
localPart - The part of the e-mail address to the left of the "@".
domain - The part of the e-mail address to the right of the "@".
Method Detail

parse

public static Mailbox parse(java.lang.String rawMailboxString)
Parses the specified raw string into a mailbox address.

Parameters:
rawMailboxString - string to parse.
Returns:
a Mailbox object for the specified string.
Throws:
java.lang.IllegalArgumentException - if the raw string does not represent a single mailbox address.

getName

public java.lang.String getName()
Returns the name of the mailbox or null if it does not have a name.


getRoute

public DomainList getRoute()
Returns the route list. If the mailbox does not have a route an empty domain list is returned.


getLocalPart

public java.lang.String getLocalPart()
Returns the left part of the e-mail address (before "@").


getDomain

public java.lang.String getDomain()
Returns the right part of the e-mail address (after "@").


getAddress

public java.lang.String getAddress()
Returns the address in the form localPart@domain.

Returns:
the address part of this mailbox.

getDisplayString

public java.lang.String getDisplayString(boolean includeRoute)
Description copied from class: Address
Formats the address as a human readable string, not including the route. The resulting string is intended for display purposes only and cannot be used for transport purposes. For example, if the unparsed address was <"Joe Cheng"@joecheng.com> this method would return which is not valid for transport; the local part would need to be re-quoted.

Specified by:
getDisplayString in class Address
Parameters:
includeRoute - true if the route should be included if it exists, false otherwise.
Returns:
a string representation of this address intended to be displayed.

getEncodedString

public java.lang.String getEncodedString()
Description copied from class: Address
Returns a string representation of this address that can be used for transport purposes. The route is never included in this representation because routes are obsolete and RFC 5322 states that obsolete syntactic forms MUST NOT be generated.

Specified by:
getEncodedString in class Address
Returns:
a string representation of this address intended for transport purposes.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this mailbox.

An object is considered to be equal to this mailbox if it is an instance of class Mailbox that holds the same address as this one. The domain is considered to be case-insensitive but the local-part is not (because of RFC 5321: the local-part of a mailbox MUST BE treated as case sensitive).

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to test for equality.
Returns:
true if the specified object is a Mailbox that holds the same address as this one.

doAddMailboxesTo

protected final void doAddMailboxesTo(java.util.List<Mailbox> results)
Description copied from class: Address
Adds any mailboxes represented by this address into the given List. Must be overridden by concrete subclasses.

Specified by:
doAddMailboxesTo in class Address


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.