Package com.atlassian.jira.util
Class EmailFormatterImpl
java.lang.Object
com.atlassian.jira.util.EmailFormatterImpl
- All Implemented Interfaces:
EmailFormatter
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
emailVisible
(ApplicationUser user) Emails are visible by user if email visibility is set to show (public) or mask (masked) or user (show to logged in users only)formatEmail
(ApplicationUser user, ApplicationUser currentUser) Formatsuser
's email address for the purpose of displaying it tocurrentUser
, as determined by theAPKeys.JIRA_OPTION_EMAIL_VISIBLE
setting.formatEmail
(String email, boolean isCurrentUserLoggedIn) Formats an email address for the purpose of displaying it to a user as determined by theAPKeys.JIRA_OPTION_EMAIL_VISIBLE
setting.formatEmail
(String email, ApplicationUser currentUser) Formats an email address for the purpose of displaying it to a user as determined by theAPKeys.JIRA_OPTION_EMAIL_VISIBLE
setting.formatEmailAsLink
(String email, ApplicationUser currentUser) Returns a HTML link for the e-mail if appropriate.
-
Field Details
-
VISIBILITY_PUBLIC
- See Also:
-
VISIBILITY_USER
- See Also:
-
VISIBILITY_MASKED
- See Also:
-
VISIBILITY_HIDE
- See Also:
-
-
Constructor Details
-
EmailFormatterImpl
-
-
Method Details
-
emailVisible
Emails are visible by user if email visibility is set to show (public) or mask (masked) or user (show to logged in users only)- Specified by:
emailVisible
in interfaceEmailFormatter
- Parameters:
user
- the user to which email addresses will be shown, ornull
if no user is logged in (browsing anonymously)- Returns:
true
if email addresses should be visible (even if they will be masked);false
otherwise
-
formatEmail
Description copied from interface:EmailFormatter
Formatsuser
's email address for the purpose of displaying it tocurrentUser
, as determined by theAPKeys.JIRA_OPTION_EMAIL_VISIBLE
setting.This convenience method is exactly equivalent to
formatEmail(user.getEmailAddress(), currentUser != null)
, except that it isnull
-safe.- Specified by:
formatEmail
in interfaceEmailFormatter
- Parameters:
user
- owner of the email address to format and display (null
is permitted)currentUser
- the user to which email addresses will be shown, ornull
if no user is logged in (browsing anonymously)- Returns:
- the formatted email address;
null
if eitheruser
isnull
orcurrentUser
is not permitted to see email addresses
-
formatEmail
Description copied from interface:EmailFormatter
Formats an email address for the purpose of displaying it to a user as determined by theAPKeys.JIRA_OPTION_EMAIL_VISIBLE
setting.Setting Behaviour "show"
The email is shown as-is to everyone. "user"
The email is shown as-is to users that are logged in, but not shown to anonymous users. "mask"
The email is shown to all users with the e-mail address slightly obscured, such that "user@example.com"
appears as"user at example dot com"
, instead- Specified by:
formatEmail
in interfaceEmailFormatter
- Parameters:
email
- The email address to show/mask/hide.isCurrentUserLoggedIn
-true
if a user is currently logged in;false
if the user is browsing anonymously- Returns:
- the formatted email address;
null
if eitheremail
isnull
or the user is not permitted to see email addresses
-
formatEmail
Description copied from interface:EmailFormatter
Formats an email address for the purpose of displaying it to a user as determined by theAPKeys.JIRA_OPTION_EMAIL_VISIBLE
setting.This convenience method is exactly equivalent to
formatEmail(email, currentUser != null)
.- Specified by:
formatEmail
in interfaceEmailFormatter
- Parameters:
email
- The email address to show/mask/hide.currentUser
- The user viewing the email address.- Returns:
- the formatted email address;
null
if eitheremail
isnull
or the user is not permitted to see email addresses
-
formatEmailAsLink
Returns a HTML link for the e-mail if appropriate. REMEMBER not to escape the string returned by this method as this method does this already!- Specified by:
formatEmailAsLink
in interfaceEmailFormatter
- Returns:
<a href="foo@bar.com">foo@bar.com</a>
(public),foo at bar.com
(masked), or an empty string (""
) if eitheremail
isnull
or the user is not permitted to see email addresses
-