Movatterモバイル変換


[0]ホーム

URL:


         


Class InternetAddress

java.lang.Object  |  +--javax.mail.Address        |        +--javax.mail.internet.InternetAddress

public classInternetAddress
extendsAddress

This class models an RFC822 address.


address
           
encodedPersonal
          The RFC 2047 encoded version of the personal name.
personal
          The personal name.
 
InternetAddress()
          Default constructor.
InternetAddress(java.lang.String address)
          Constructor.
InternetAddress(java.lang.String address, java.lang.String personal)
          Construct an InternetAddress given the address and personal name.
InternetAddress(java.lang.String address, java.lang.String personal, java.lang.String charset)
          Construct an InternetAddress given the address and personal name.
 
equals(java.lang.Object a)
          The equality operator.
getAddress()
          Get the email address.
getLocalAddress(Session session)
          Return an InternetAddress object representing the current user.
getPersonal()
          Get the personal name.
getType()
          Return the type of this address.
hashCode()
          Compute a hash code for the address.
parse(java.lang.String addresslist)
          Parse the given comma separated sequence of addresses into InternetAddress objects.
parse(java.lang.String s, boolean strict)
          Parse the given sequence of addresses into InternetAddress objects.
setAddress(java.lang.String address)
          Set the email address.
setPersonal(java.lang.String name)
          Set the personal name.
setPersonal(java.lang.String name, java.lang.String charset)
          Set the personal name.
toString()
          Convert this address into a RFC 822 / RFC 2047 encoded address.
toString(Address[] addresses)
          Convert the given array of InternetAddress objects into a comma separated sequence of address strings.
toString(Address[] addresses, int used)
          Convert the given array of InternetAddress objects into a comma separated sequence of address strings.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

address

protected java.lang.Stringaddress

personal

protected java.lang.Stringpersonal
The personal name.

encodedPersonal

protected java.lang.StringencodedPersonal
The RFC 2047 encoded version of the personal name.

This field and thepersonal field track each other, so if a subclass sets one of these fields directly, it should set the other tonull, so that it is suitably recomputed.

InternetAddress

publicInternetAddress()
Default constructor.

InternetAddress

publicInternetAddress(java.lang.String address)                throwsAddressException
Constructor.

Parse the given string and create an InternetAddress.

Parameters:
address - the address in RFC822 format
Throws:
AddressException - if the parse failed

InternetAddress

publicInternetAddress(java.lang.String address,                       java.lang.String personal)                throws java.io.UnsupportedEncodingException
Construct an InternetAddress given the address and personal name. The address is assumed to be a syntactically valid RFC822 address.
Parameters:
address - the address in RFC822 format
personal - the personal name

InternetAddress

publicInternetAddress(java.lang.String address,                       java.lang.String personal,                       java.lang.String charset)                throws java.io.UnsupportedEncodingException
Construct an InternetAddress given the address and personal name. The address is assumed to be a syntactically valid RFC822 address.
Parameters:
address - the address in RFC822 format
personal - the personal name
charset - the charset for the name

getType

public java.lang.StringgetType()
Return the type of this address. The type of an InternetAddress is "rfc822".
Overrides:
getType in classAddress
Following copied from class:javax.mail.Address
Returns:
address type
See Also:
InternetAddress

setAddress

public voidsetAddress(java.lang.String address)
Set the email address.
Parameters:
address - email address

setPersonal

public voidsetPersonal(java.lang.String name,                        java.lang.String charset)                 throws java.io.UnsupportedEncodingException
Set the personal name. If the name contains non US-ASCII characters, then the name will be encoded using the specified charset as per RFC 2047. If the name contains only US-ASCII characters, no encoding is done and the name is used as is.

Parameters:
name - personal name
charset - charset to be used to encode the name as per RFC 2047.
Throws:
java.io.UnsupportedEncodingException - if the charset encoding fails.
See Also:
setPersonal(String)

setPersonal

public voidsetPersonal(java.lang.String name)                 throws java.io.UnsupportedEncodingException
Set the personal name. If the name contains non US-ASCII characters, then the name will be encoded using the platform's default charset. If the name contains only US-ASCII characters, no encoding is done and the name is used as is.

Parameters:
name - personal name
Throws:
java.io.UnsupportedEncodingException - if the charset encoding fails.
See Also:
setPersonal(String name, String charset)

getAddress

public java.lang.StringgetAddress()
Get the email address.
Returns:
email address

getPersonal

public java.lang.StringgetPersonal()
Get the personal name. If the name is encoded as per RFC 2047, it is decoded and converted into Unicode. If the decoding or convertion fails, the raw data is returned as is.
Returns:
personal name

toString

public java.lang.StringtoString()
Convert this address into a RFC 822 / RFC 2047 encoded address. The resulting string contains only US-ASCII characters, and hence is mail-safe.
Overrides:
toString in classAddress
Returns:
possibly encoded address string

equals

public booleanequals(java.lang.Object a)
The equality operator.
Overrides:
equals in classAddress
Following copied from class:javax.mail.Address
Parameters:
address - Address object

hashCode

public inthashCode()
Compute a hash code for the address.
Overrides:
hashCode in classjava.lang.Object

toString

public static java.lang.StringtoString(Address[] addresses)
Convert the given array of InternetAddress objects into a comma separated sequence of address strings. The resulting string contains only US-ASCII characters, and hence is mail-safe.

Parameters:
addresses - array of InternetAddress objects
Returns:
comma separated address strings
Throws:
ClassCastException, - if any address object in the given array is not an InternetAddress objects. Notethat this is a RuntimeException.

toString

public static java.lang.StringtoString(Address[] addresses,                                        int used)
Convert the given array of InternetAddress objects into a comma separated sequence of address strings. The resulting string contains only US-ASCII characters, and hence is mail-safe.

The 'used' parameter specifies the number of character positions already taken up in the field into which the resulting address sequence string is to be inserted. Its used to determine the line-break positions in the resulting address sequence string.

Parameters:
addresses - array of InternetAddress objects
used - number of character positions already used, inthe field into which the address string is tobe inserted.
Returns:
comma separated address strings
Throws:
ClassCastException, - if any address object in the given array is not an InternetAddress objects. Notethat this is a RuntimeException.

getLocalAddress

public staticInternetAddressgetLocalAddress(Session session)
Return an InternetAddress object representing the current user. The entire email address may be specified in the "mail.from" property. If not set, the "mail.user" and "mail.host" properties are tried. If those are not set, the "user.name" property andInetAddress.getLocalHost method are tried. Security exceptions that may occur while accessing this information are ignored. If it is not possible to determine an email address, null is returned.
Parameters:
session - Session object used for property lookup
Returns:
current user's email address

parse

public staticInternetAddress[]parse(java.lang.String addresslist)                               throwsAddressException
Parse the given comma separated sequence of addresses into InternetAddress objects. Addresses must follow RFC822 syntax.
Parameters:
addresslist - comma separated address strings
Returns:
array of InternetAddress objects
Throws:
AddressException - if the parse failed

parse

public staticInternetAddress[]parse(java.lang.String s,                                      boolean strict)                               throwsAddressException
Parse the given sequence of addresses into InternetAddress objects. Ifstrict is false, simple email addresses separated by spaces are also allowed. Ifstrict is true, many (but not all) of the RFC822 syntax rules are enforced. In particular, even ifstrict is true, addresses composed of simple names (with no "@domain" part) are allowed. Such "illegal" addresses are not uncommon in real messages.

Non-strict parsing is typically used when parsing a list of mail addresses entered by a human. Strict parsing is typically used when parsing address headers in mail messages.

Parameters:
addresslist - comma separated address strings
strict - enforce RFC822 syntax
Returns:
array of InternetAddress objects
Throws:
AddressException - if the parse failed

         


[8]ページ先頭

©2009-2025 Movatter.jp