Class MailToBuilder
java.lang.Object
com.ptc.windchill.enterprise.mail.MailToBuilder
Builder for creating mail-client specific compliant
mailto: links following guidelines from RFC-2368. The mail-client
is used to process differences between some of the major Email
clients such as Microsoft Outlook and Mozilla Thunderbird.
On certain platforms, such as Microsoft Windows, mailto links can only be processed if their total length is less than a defined characters limit (see
All header keys and values will be escaped in the URI Query string.
Supported API: true
On certain platforms, such as Microsoft Windows, mailto links can only be processed if their total length is less than a defined characters limit (see
CHARACTER_LIMIT). By default,
the MailToBuilder will enforce this character limit on calls to
toString( ) unless otherwise stated through the constructor
MailToBuilder( boolean ). If the limit is exceeded, a
StringIndexOutOfBoundsException will be thrown from calls to
toString( ).
All header keys and values will be escaped in the URI Query string.
Supported API: true
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new mailto builder.MailToBuilder(boolean enforceLimit) Creates a new mailto builder that will conditionally enforce the character limit on mailto creation. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a header key/value pair to the generated mailto link.voidaddRecipient(String email) Add the specified recipient's Email to the list of recipients.voidaddRecipients(Collection<String> emails) Add the collection of recipients.Return all current recipients.static StringRetrieves the separator character for use with the user's preferred Email client.booleanWhether the character limit is enforced for mailto generation.voidoutput(StringBuilder buf) Will output the mailto link to the specified buffer in an URI-compliant manner.voidSets the body header of the mailto link.voidsetCharacterLimitEnforced(boolean enforce) Set whether the character limit is enforced for mailto generation.voidsetSubject(String subject) Sets the subject header of the mailto link.toString()Convert the MailToBuilder to a URI-compliant string.
-
Constructor Details
-
MailToBuilder
Creates a new mailto builder. The user's preferred Email client will be used to setup the mailto link separator.
Supported API: true- Throws:
WTException- Thrown if an error occurs obtaining the users preferred Email client.
-
MailToBuilder
Creates a new mailto builder that will conditionally enforce the character limit on mailto creation. The user's preferred Email client will be used to setup the mailto link separator.
Supported API: true- Parameters:
enforceLimit- Whether to enforce the character limit- Throws:
WTException- Thrown if an error occurs obtaining the users preferred Email client.
-
-
Method Details
-
isCharacterLimitEnforced
public boolean isCharacterLimitEnforced()Whether the character limit is enforced for mailto generation.
Supported API: true- Returns:
- The enforcement flag.
-
setCharacterLimitEnforced
public void setCharacterLimitEnforced(boolean enforce) Set whether the character limit is enforced for mailto generation.
Supported API: true- Parameters:
enforce-
-
addRecipient
Add the specified recipient's Email to the list of recipients.
Supported API: true- Parameters:
email- The recipient's email to add
-
addRecipients
Add the collection of recipients.
Supported API: true- Parameters:
emails- Collection of emails to add as recipients.
-
getRecipients
Return all current recipients.
Supported API: true- Returns:
- The list of recipient Emails.
-
addHeader
Add a header key/value pair to the generated mailto link. Both the key and value will be URI encoded. The output will be separated by a '='.
Supported API: true- Parameters:
key- The key of the headervalue- The value of the header.
-
setSubject
Sets the subject header of the mailto link. The subject will be URI encoded.
Supported API: true- Parameters:
subject- The subject to add.
-
setBody
Sets the body header of the mailto link. The body will be URI encoded.
Supported API: true- Parameters:
body-
-
output
Will output the mailto link to the specified buffer in an URI-compliant manner. If no recipients are present, the content of the mailto link will start with the "?" query string.
Note: This method does not enforce the character limit. It only outputs a URI-compliant mailto link. ThetoString()method should be used to generate mailto links for most usages.
Supported API: true- Parameters:
buf- The string builder to append the mailto link to.
-
toString
Convert the MailToBuilder to a URI-compliant string. If the character limit is being enforced, and the generated URI-compliant string exceeds the character limit aStringIndexOutOfBoundsExceptionwill be thrown.
Supported API: true- Overrides:
toStringin classObject- Returns:
- The generated string for the URI-compliant mailto link.
- Throws:
StringIndexOutOfBoundsException- output exceeds character limit if enabled.
-
getSeparator
Retrieves the separator character for use with the user's preferred Email client. The preference/PreferredEmailClientwill be checked for a valid known email client and the correct separator returned.
If no preference is defined, or it is not a known Email client, the valueW3C_SEPARATORwill be used.
Supported API: true- Returns:
- The defined separator for the user's preferred Email client.
- Throws:
WTException- Thrown if the preferred client can not be determined.- See Also:
-