public class InternetAddress extends Address implements java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
address
The string representation of the address.
|
protected java.lang.String |
encodedPersonal
The RFC 2047 encoded version of the personal name.
|
protected java.lang.String |
personal
The personal name.
|
| Constructor and Description |
|---|
InternetAddress()
Constructor for an empty address.
|
InternetAddress(java.lang.String address)
Constructor with an RFC 822 string representation of the address.
|
InternetAddress(java.lang.String address,
boolean strict)
Constructor with an RFC 822 string representation of the address.
|
InternetAddress(java.lang.String address,
java.lang.String personal)
Constructor with an address and personal name.
|
InternetAddress(java.lang.String address,
java.lang.String personal,
java.lang.String charset)
Construct with an address and personal name.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Returns a copy of this address.
|
boolean |
equals(java.lang.Object other) |
java.lang.String |
getAddress()
Returns the email address.
|
InternetAddress[] |
getGroup(boolean strict)
Returns the members of a group address.
|
static InternetAddress |
getLocalAddress(Session session)
Returns an InternetAddress object representing the current user.
|
java.lang.String |
getPersonal()
Returns the personal name.
|
java.lang.String |
getType()
Returns the type of this address.
|
int |
hashCode() |
boolean |
isGroup()
Indicates whether this address is an RFC 822 group address.
|
static InternetAddress[] |
parse(java.lang.String addresslist)
Parses the given comma-separated sequence of RFC 822 addresses into
InternetAddresses.
|
static InternetAddress[] |
parse(java.lang.String addresslist,
boolean strict)
Parses the given comma-separated sequence of RFC 822 addresses into
InternetAddresses.
|
static InternetAddress[] |
parseHeader(java.lang.String addresslist,
boolean strict)
Parses the given comma-separated sequence of RFC 822 addresses into
InternetAddresses.
|
void |
setAddress(java.lang.String address)
Sets the email address.
|
void |
setPersonal(java.lang.String name)
Sets the personal name.
|
void |
setPersonal(java.lang.String name,
java.lang.String charset)
Sets the personal name.
|
java.lang.String |
toString()
Returns the RFC 822 / RFC 2047 string representation of this address.
|
static java.lang.String |
toString(Address[] addresses)
Converts the given array of InternetAddresses into a comma-separated
sequence of address strings.
|
static java.lang.String |
toString(Address[] addresses,
int used)
Converts the given array of InternetAddresses into a comma-separated
sequence of address strings.
|
java.lang.String |
toUnicodeString()
Returns the RFC 822 string representation of this address.
|
void |
validate()
Validate this address according to the syntax rules of RFC 822.
|
protected java.lang.String address
protected java.lang.String personal
protected java.lang.String encodedPersonal
public InternetAddress()
public InternetAddress(java.lang.String address)
throws AddressException
address - the address in RFC 822 formatAddressException - if the parse failedpublic InternetAddress(java.lang.String address,
boolean strict)
throws AddressException
address - the address in RFC 822 formatstrict - enforce RFC 822 syntaxAddressException - if the parse failedpublic InternetAddress(java.lang.String address,
java.lang.String personal)
throws java.io.UnsupportedEncodingException
address - the address in RFC 822 formatpersonal - the personal namejava.io.UnsupportedEncodingExceptionpublic InternetAddress(java.lang.String address,
java.lang.String personal,
java.lang.String charset)
throws java.io.UnsupportedEncodingException
address - the address in RFC 822 formatpersonal - the personal namecharset - the charset for the personal namejava.io.UnsupportedEncodingExceptionpublic java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.String getType()
InternetAddress is "rfc822".public boolean isGroup()
public InternetAddress[] getGroup(boolean strict) throws AddressException
null.AddressException - if a parse error occurspublic void setAddress(java.lang.String address)
public void setPersonal(java.lang.String name,
java.lang.String charset)
throws java.io.UnsupportedEncodingException
name - the personal namecharset - the charset to be used for any encodingUnsupportedEncodingException - if charset encoding failsjava.io.UnsupportedEncodingExceptionpublic void setPersonal(java.lang.String name)
throws java.io.UnsupportedEncodingException
name - the personal namejava.io.UnsupportedEncodingException - if charset encoding failspublic java.lang.String getAddress()
public java.lang.String getPersonal()
public void validate()
throws AddressException
AddressException - if the address is invalidpublic java.lang.String toString()
public java.lang.String toUnicodeString()
public int hashCode()
hashCode in class java.lang.Objectpublic static java.lang.String toString(Address[] addresses)
addresses - the InternetAddressesjava.lang.ClassCastException - if any of the specified addresses is not
an InternetAddresspublic static java.lang.String toString(Address[] addresses, int used)
addresses - the InternetAddressesused - the number of character positions already used, in the
field into which the address string is to be insertedjava.lang.ClassCastException - if any of the specified addresses is not
an InternetAddresspublic static InternetAddress getLocalAddress(Session session)
mail.frommail.user or
user.name, and mail.hostuser.name and the hostname of
localhost as determined by InetAddress.getLocalHostsession - the sessionpublic static InternetAddress[] parse(java.lang.String addresslist) throws AddressException
addresslist - the comma-separated addressesAddressException - if the parse failedpublic static InternetAddress[] parse(java.lang.String addresslist, boolean strict) throws AddressException
strict is false, simple email addresses separated by
spaces are also allowed. If strict is true, many (but not
all) of the RFC 822 syntax rules are enforced.
Even if strict is true, addresses composed of simple
names (with no "@domain" part) are allowed.addresslist - the comma-separated addressesstrict - whether to enforce RFC 822 syntaxAddressException - if the parse failedpublic static InternetAddress[] parseHeader(java.lang.String addresslist, boolean strict) throws AddressException
strict is false, simple email addresses separated by
spaces are also allowed. If strict is true, many (but not
all) of the RFC 822 syntax rules are enforced.addresslist - the comma-separated addressesstrict - whether to enforce RFC 822 syntaxAddressException - if the parse failed© Copyright 2003, 2004 The Free Software Foundation, All rights reserved