|
|||||||||
| Home >> All >> javax >> mail >> [ internet overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.mail.internet
Class InternetAddress

java.lang.Objectjavax.mail.Address
javax.mail.internet.InternetAddress
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class InternetAddress
- extends javax.mail.Address
- implements java.lang.Cloneable
- extends javax.mail.Address
A representation of an Internet email address as specified by RFC822 in conjunction with a human-readable personal name that can be encoded as specified by RFC2047. A typical address is "user@host.domain" and personal name "Joe User"
- Version:
- $Rev: 149170 $ $Date: 2005-01-30 14:21:08 -0800 (Sun, 30 Jan 2005) $
| Field Summary | |
protected java.lang.String |
address
The address in RFC822 format. |
private static byte[] |
CHARMAP
|
protected java.lang.String |
encodedPersonal
The personal name in RFC2047 format. |
private static byte |
FLG_CONTROL
|
private static byte |
FLG_SPACE
|
private static byte |
FLG_SPECIAL
|
protected java.lang.String |
personal
The personal name as a Java String. |
| Constructor Summary | |
InternetAddress()
|
|
InternetAddress(java.lang.String address)
|
|
InternetAddress(java.lang.String address,
boolean strict)
|
|
InternetAddress(java.lang.String address,
java.lang.String personal)
|
|
InternetAddress(java.lang.String address,
java.lang.String personal,
java.lang.String charset)
|
|
| Method Summary | |
java.lang.Object |
clone()
Clone this object. |
boolean |
equals(java.lang.Object o)
Compares two addresses for equality. |
private int |
expectPhrase(java.lang.String s,
int index)
|
private int |
expectWord(java.lang.String s,
int index)
|
java.lang.String |
getAddress()
Return the address. |
private java.lang.String |
getEncodedPersonal()
Return the encoded form of the personal name. |
InternetAddress[] |
getGroup(boolean strict)
Return the members of a group address. |
static InternetAddress |
getLocalAddress(javax.mail.Session session)
Return an InternetAddress representing the current user. |
java.lang.String |
getPersonal()
Return the personal name. |
java.lang.String |
getType()
Return the type of this address. |
int |
hashCode()
Return the hashCode for this address. |
private static void |
init(InternetAddress addr,
java.lang.String text)
|
private static boolean |
isAtom(char c)
|
boolean |
isGroup()
Return true is this address is an RFC822 group address in the format phrase ":" [#mailbox] ";". |
private static boolean |
isSpace(char c)
|
static InternetAddress[] |
parse(java.lang.String addresses)
Parse addresses out of the string with basic checking. |
static InternetAddress[] |
parse(java.lang.String addresses,
boolean strict)
Parse addresses out of the string. |
private static InternetAddress[] |
parse(java.lang.String addresses,
boolean strict,
boolean veryStrict)
Parse addresses with increasing degrees of RFC822 compliance checking. |
(package private) static void |
parseHeader(java.util.List target,
java.lang.String addresses,
boolean strict,
boolean veryStrict)
|
static InternetAddress[] |
parseHeader(java.lang.String addresses,
boolean strict)
Parse addresses out of the string. |
private java.lang.StringBuffer |
quote(java.lang.StringBuffer buf,
java.lang.String text)
Add RFC822 quotes to a String if needed. |
void |
setAddress(java.lang.String address)
Set the address. |
void |
setPersonal(java.lang.String name)
Set the personal name. |
void |
setPersonal(java.lang.String name,
java.lang.String charset)
Set the personal name. |
private int |
skipComment(java.lang.String s,
int index)
|
private int |
skipSpace(java.lang.String s,
int index)
|
java.lang.String |
toString()
Return a string representation of this address using only US-ASCII characters. |
static java.lang.String |
toString(javax.mail.Address[] addresses)
Convert the supplied addresses into a single String of comma-separated text as produced by toString() 55 . |
static java.lang.String |
toString(javax.mail.Address[] addresses,
int used)
Convert the supplies addresses into a String of comma-separated text, inserting line-breaks between addresses as needed to restrict the line length to 72 characters. |
java.lang.String |
toUnicodeString()
Return a string representation of this address using Unicode characters. |
void |
validate()
|
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
address
protected java.lang.String address
- The address in RFC822 format.
encodedPersonal
protected java.lang.String encodedPersonal
- The personal name in RFC2047 format.
Subclasses must ensure that this field is updated if the personal field
is updated; alternatively, it can be invalidated by setting to null
which will cause it to be recomputed.
personal
protected java.lang.String personal
- The personal name as a Java String.
Subclasses must ensure that this field is updated if the encodedPersonal field
is updated; alternatively, it can be invalidated by setting to null
which will cause it to be recomputed.
CHARMAP
private static final byte[] CHARMAP
FLG_SPECIAL
private static final byte FLG_SPECIAL
- See Also:
- Constant Field Values
FLG_CONTROL
private static final byte FLG_CONTROL
- See Also:
- Constant Field Values
FLG_SPACE
private static final byte FLG_SPACE
- See Also:
- Constant Field Values
| Constructor Detail |
InternetAddress
public InternetAddress()
InternetAddress
public InternetAddress(java.lang.String address) throws AddressException
InternetAddress
public InternetAddress(java.lang.String address, boolean strict) throws AddressException
InternetAddress
public InternetAddress(java.lang.String address, java.lang.String personal) throws java.io.UnsupportedEncodingException
InternetAddress
public InternetAddress(java.lang.String address, java.lang.String personal, java.lang.String charset) throws java.io.UnsupportedEncodingException
| Method Detail |
clone
public java.lang.Object clone()
- Clone this object.
getType
public java.lang.String getType()
- Return the type of this address.
setAddress
public void setAddress(java.lang.String address)
- Set the address.
No validation is performed; validate() can be used to check if it is valid.
setPersonal
public void setPersonal(java.lang.String name, java.lang.String charset) throws java.io.UnsupportedEncodingException
- Set the personal name.
The name is first checked to see if it can be encoded; if this fails then an
UnsupportedEncodingException is thrown and no fields are modified.
setPersonal
public void setPersonal(java.lang.String name) throws java.io.UnsupportedEncodingException
- Set the personal name.
The name is first checked to see if it can be encoded using
MimeUtility.encodeWord(String)55 ; if this fails then an UnsupportedEncodingException is thrown and no fields are modified.
getAddress
public java.lang.String getAddress()
- Return the address.
getPersonal
public java.lang.String getPersonal()
- Return the personal name.
If the personal field is null, then an attempt is made to decode the encodedPersonal
field using
MimeUtility.decodeWord(String)55 ; if this is sucessful, then the personal field is updated with that value and returned; if there is a problem decoding the text then the raw value from encodedPersonal is returned.
getEncodedPersonal
private java.lang.String getEncodedPersonal()
- Return the encoded form of the personal name.
If the encodedPersonal field is null, then an attempt is made to encode the
personal field using
MimeUtility.encodeWord(String)55 ; if this is successful then the encodedPersonal field is updated with that value and returned; if there is a problem encoding the text then null is returned.
quote
private java.lang.StringBuffer quote(java.lang.StringBuffer buf, java.lang.String text)
- Add RFC822 quotes to a String if needed.
It is assumed the text passed in has already been converted to US-ASCII.
toString
public java.lang.String toString()
- Return a string representation of this address using only US-ASCII characters.
toUnicodeString
public java.lang.String toUnicodeString()
- Return a string representation of this address using Unicode characters.
equals
public boolean equals(java.lang.Object o)
- Compares two addresses for equality.
We define this as true if the other object is an InternetAddress
and the two values returned by getAddress() are equal in a
case-insensitive comparison.
hashCode
public int hashCode()
- Return the hashCode for this address.
We define this to be the hashCode of the address after conversion to lowercase.
isGroup
public boolean isGroup()
- Return true is this address is an RFC822 group address in the format
phrase ":" [#mailbox] ";". We check this by seeing stripping the leading phrase (which, for tolerance, we consider optional) and then checking if the first and last characters are ':' and ';' respectively.
getGroup
public InternetAddress[] getGroup(boolean strict) throws AddressException
- Return the members of a group address.
If strict is true and the address does not contain an initial phrase then an AddressException is thrown.
Otherwise the phrase is skipped and the remainder of the address is checked to see if it is a group.
If it is, the content and strict flag are passed to parseHeader to extract the list of addresses;
if it is not a group then null is returned.
getLocalAddress
public static InternetAddress getLocalAddress(javax.mail.Session session)
- Return an InternetAddress representing the current user.
If session is not null, we first look for an address specified in its
"mail.from" property; if this is not set, we look at its "mail.user"
and "mail.host" properties and if both are not null then an address of
the form "${mail.user}@${mail.host}" is created.
If this fails to give an address, then an attempt is made to create
an address by combining the value of the "user.name" System property
with the value returned from InetAddress.getLocalHost().getHostName().
Any SecurityException raised accessing the system property or any
UnknownHostException raised getting the hostname are ignored.
Finally, an attempt is made to convert the value obtained above to
an InternetAddress. If this fails, then null is returned.
toString
public static java.lang.String toString(javax.mail.Address[] addresses)
- Convert the supplied addresses into a single String of comma-separated text as
produced by toString() 55 .
No line-break detection is performed.
toString
public static java.lang.String toString(javax.mail.Address[] addresses, int used)
- Convert the supplies addresses into a String of comma-separated text,
inserting line-breaks between addresses as needed to restrict the line
length to 72 characters. Splits will only be introduced between addresses
so an address longer than 71 characters will still be placed on a single
line.
parse
public static InternetAddress[] parse(java.lang.String addresses) throws AddressException
- Parse addresses out of the string with basic checking.
parse
public static InternetAddress[] parse(java.lang.String addresses, boolean strict) throws AddressException
- Parse addresses out of the string.
parseHeader
public static InternetAddress[] parseHeader(java.lang.String addresses, boolean strict) throws AddressException
- Parse addresses out of the string.
parse
private static InternetAddress[] parse(java.lang.String addresses, boolean strict, boolean veryStrict) throws AddressException
- Parse addresses with increasing degrees of RFC822 compliance checking.
parseHeader
static void parseHeader(java.util.List target, java.lang.String addresses, boolean strict, boolean veryStrict) throws AddressException
init
private static void init(InternetAddress addr, java.lang.String text)
validate
public void validate()
throws AddressException
expectPhrase
private int expectPhrase(java.lang.String s, int index)
expectWord
private int expectWord(java.lang.String s, int index)
skipSpace
private int skipSpace(java.lang.String s, int index)
skipComment
private int skipComment(java.lang.String s, int index)
isSpace
private static boolean isSpace(char c)
isAtom
private static boolean isAtom(char c)
|
|||||||||
| Home >> All >> javax >> mail >> [ internet overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC