public class InternetAddress extends Address implements Cloneable
Modifier and Type | Field and Description |
---|---|
protected String |
address
The address in RFC822 format.
|
protected String |
encodedPersonal
The personal name in RFC2047 format.
|
protected String |
personal
The personal name as a Java String.
|
Constructor and Description |
---|
InternetAddress() |
InternetAddress(String address) |
InternetAddress(String address,
boolean strict) |
InternetAddress(String address,
String personal) |
InternetAddress(String address,
String personal,
String charset) |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Clone this object.
|
boolean |
equals(Object o)
Compares two addresses for equality.
|
String |
getAddress()
Return the address.
|
InternetAddress[] |
getGroup(boolean strict)
Return the members of a group address.
|
static InternetAddress |
getLocalAddress(Session session)
Return an InternetAddress representing the current user.
|
String |
getPersonal()
Return the personal name.
|
String |
getType()
Return the type of this address.
|
int |
hashCode()
Return the hashCode for this address.
|
boolean |
isGroup()
Return true is this address is an RFC822 group address in the format
phrase ":" [#mailbox] ";" . |
static InternetAddress[] |
parse(String addresses)
Parse addresses out of the string with basic checking.
|
static InternetAddress[] |
parse(String addresses,
boolean strict)
Parse addresses out of the string.
|
static InternetAddress[] |
parseHeader(String addresses,
boolean strict)
Parse addresses out of the string.
|
void |
setAddress(String address)
Set the address.
|
void |
setPersonal(String name)
Set the personal name.
|
void |
setPersonal(String name,
String charset)
Set the personal name.
|
String |
toString()
Return a string representation of this address using only US-ASCII characters.
|
static String |
toString(Address[] addresses)
Convert the supplied addresses into a single String of comma-separated text as
produced by
toString() . |
static String |
toString(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.
|
String |
toUnicodeString()
Return a string representation of this address using Unicode characters.
|
void |
validate()
Validate the address portion of an internet address to ensure
validity.
|
protected String address
protected String encodedPersonal
protected String personal
public InternetAddress()
public InternetAddress(String address) throws AddressException
AddressException
public InternetAddress(String address, boolean strict) throws AddressException
AddressException
public InternetAddress(String address, String personal) throws UnsupportedEncodingException
UnsupportedEncodingException
public InternetAddress(String address, String personal, String charset) throws UnsupportedEncodingException
UnsupportedEncodingException
public Object clone()
public String getType()
public void setAddress(String address)
address
- the address to setpublic void setPersonal(String name, String charset) throws UnsupportedEncodingException
name
- the new personal namecharset
- the charset to use; see MimeUtilityencodeWord
UnsupportedEncodingException
- if the name cannot be encodedpublic void setPersonal(String name) throws UnsupportedEncodingException
MimeUtility.encodeWord(String)
; if this fails then an
UnsupportedEncodingException is thrown and no fields are modified.name
- the new personal nameUnsupportedEncodingException
- if the name cannot be encodedpublic String getAddress()
public String getPersonal()
MimeUtility.decodeWord(String)
; 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.public String toString()
public String toUnicodeString()
public boolean equals(Object o)
public int hashCode()
public boolean isGroup()
phrase ":" [#mailbox] ";"
.
We check this by using the presense of a ':' character in the address, and a
';' as the very last character.public InternetAddress[] getGroup(boolean strict) throws AddressException
strict
- whether strict RFC822 checking should be performedAddressException
- if there was a problem parsing the headerpublic static InternetAddress getLocalAddress(Session session)
session
- used to obtain mail propertiespublic static String toString(Address[] addresses)
toString()
.
No line-break detection is performed.addresses
- the array of addresses to convertpublic static String toString(Address[] addresses, int used)
addresses
- the array of addresses to convertused
- the starting columnpublic static InternetAddress[] parse(String addresses) throws AddressException
addresses
- the addresses to parseAddressException
- if addresses checking failspublic static InternetAddress[] parse(String addresses, boolean strict) throws AddressException
addresses
- the addresses to parsestrict
- if true perform detailed checking, if false just perform basic checkingAddressException
- if address checking failspublic static InternetAddress[] parseHeader(String addresses, boolean strict) throws AddressException
addresses
- the addresses to parsestrict
- if true perform detailed checking, if false perform little checkingAddressException
- if address checking failspublic void validate() throws AddressException
AddressException
Copyright © 2013. All rights reserved.