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

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

public abstract class Address
extends java.lang.Object
implements java.io.Serializable

The abstract base for classes that represent RFC2822 addresses. This includes groups and mailboxes.

See Also:
Serialized Form

Constructor Summary
Address()
           
 
Method Summary
protected abstract  void doAddMailboxesTo(java.util.List<Mailbox> results)
          Adds any mailboxes represented by this address into the given List.
 java.lang.String getDisplayString()
          Formats the address as a human readable string, not including the route.
abstract  java.lang.String getDisplayString(boolean includeRoute)
          Formats the address as a human readable string, not including the route.
abstract  java.lang.String getEncodedString()
          Returns a string representation of this address that can be used for transport purposes.
static Address parse(java.lang.String rawAddressString)
          Parses the specified raw string into an address.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Address

public Address()
Method Detail

doAddMailboxesTo

protected abstract void doAddMailboxesTo(java.util.List<Mailbox> results)
Adds any mailboxes represented by this address into the given List. Must be overridden by concrete subclasses.


getDisplayString

public final java.lang.String getDisplayString()
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.

Returns:
a string representation of this address intended to be displayed
See Also:
getDisplayString(boolean)

getDisplayString

public abstract java.lang.String getDisplayString(boolean includeRoute)
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.

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 abstract java.lang.String getEncodedString()
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.

Returns:
a string representation of this address intended for transport purposes.

parse

public static Address parse(java.lang.String rawAddressString)
Parses the specified raw string into an address.

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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