|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.endeca.portlet.util.LanguageUtils
public class LanguageUtils
This class provides portlet's access to messages stored in resource bundles. Three main uses are available for these methods:
getAllPortletMessages(PortletRequest)
or
instance method getAllPortletMessages()
and pull messages from the resulting map as
necessary, relying on replaceMessageTokens(String, Object[])
for token substitution
on demand.
Field Summary | |
---|---|
static java.lang.String |
REQUEST_ATTRIBUTE_PORTLET_CONFIG
Name of request attribute that holds the PortletConfig class. |
Constructor Summary | |
---|---|
LanguageUtils(javax.portlet.PortletRequest request)
Constructor for using an instance of LanguageUtils without passing the request to each static method call. |
Method Summary | |
---|---|
java.util.Map<java.lang.String,java.lang.String> |
getAllPortletMessages()
Invokes getAllPortletMessages(PortletRequest) . |
static java.util.Map<java.lang.String,java.lang.String> |
getAllPortletMessages(javax.portlet.PortletRequest request)
Retrieves all messages available in a resource bundle for the invoking portlet. |
static java.lang.String |
getMessage(javax.portlet.PortletRequest request,
java.lang.String messageName)
Retrieves a message with no parameter subtitution. |
static java.lang.String |
getMessage(javax.portlet.PortletRequest request,
java.lang.String messageName,
java.lang.Object[] params)
Retrieves a message from a resource bundle, substituting the specified parameters for tokens in the message string. |
java.lang.String |
getMessage(java.lang.String messageName)
Convenience instance-specific wrapper of getMessage(PortletRequest, String) . |
java.lang.String |
getMessage(java.lang.String messageName,
java.lang.Object[] params)
Convenience instance-specific wrapper of getMessage(PortletRequest, String, Object[]) . |
static java.lang.String |
replaceMessageTokens(java.lang.String message,
java.lang.Object[] params)
Substitutes parameters for tokens in the message string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String REQUEST_ATTRIBUTE_PORTLET_CONFIG
PortletConfig
class.
JSR 286 spec requires the portlet container to make the portlet config available in
the PortletRequest under this attribute name.
Constructor Detail |
---|
public LanguageUtils(javax.portlet.PortletRequest request)
request
- PortletRequest for the portlet whose resource bundle will be accessed.Method Detail |
---|
public java.lang.String getMessage(java.lang.String messageName)
getMessage(PortletRequest, String)
.
Uses the instance's PortletRequest as the first argument.
messageName
- Name of message to retrieve from resource bundle.
public java.lang.String getMessage(java.lang.String messageName, java.lang.Object[] params)
getMessage(PortletRequest, String, Object[])
.
Uses the instance's PortletRequest as the first argument.
messageName
- Name of message to retrieve from resource bundle.params
- Array of parameters to substitute for tokens in the message string.
public java.util.Map<java.lang.String,java.lang.String> getAllPortletMessages()
getAllPortletMessages(PortletRequest)
. Uses
the instance's PortletRequest as the first argument.
public static java.lang.String getMessage(javax.portlet.PortletRequest request, java.lang.String messageName)
getMessage(PortletRequest, String, Object[])
with a null params argument.
request
- PortletRequest for the portlet whose resource bundle will be accessed.messageName
- Name of message to retrieve from resource bundle.
public static java.lang.String getMessage(javax.portlet.PortletRequest request, java.lang.String messageName, java.lang.Object[] params)
MessageFormat
class for details about parameter substitution.
request
- PortletRequest for the portlet whose resource bundle will be accessed.messageName
- Name of message to retrieve from resource bundle.params
- Parameters to substitute for tokens in the message.
MessageFormat.format(String, Object...)
public static java.util.Map<java.lang.String,java.lang.String> getAllPortletMessages(javax.portlet.PortletRequest request)
replaceMessageTokens(String, Object[])
.
This method may be used to load (and potentially cache) messages for a portlet
and avoid repeated calls to load the same strings from the resource bundle.
request
- PortletRequest for portlet whose resource bundle will be loaded.
public static java.lang.String replaceMessageTokens(java.lang.String message, java.lang.Object[] params)
MessageFormat
class for details about parameter substitution.
message
- Message with tokens to replace.params
- Parameters to substitute for tokens in the message.
MessageFormat.format(String, Object...)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |