org.opencms.xml
Class CmsXmlMessages

java.lang.Object
  extended by org.opencms.i18n.CmsMessages
      extended by org.opencms.xml.CmsXmlMessages

public class CmsXmlMessages
extends CmsMessages

The xml messages overwrite some methods of the general CmsMessages class to get keys from an individual configuration file.

As fallback if no file was specified or no value was found for the desired key, a common CmsMessages object is used to get the localized value.

Since:
6.5.4
Version:
$Revision: 1.7 $
Author:
Andreas Zahner

Field Summary
 
Fields inherited from class org.opencms.i18n.CmsMessages
KEY_SHORT_SUFFIX, UNKNOWN_KEY_EXTENSION
 
Constructor Summary
CmsXmlMessages(CmsMessages messages, java.lang.String configurationFileName, java.lang.String pathPrefix, java.util.Locale locale)
          Constructor, with parameters.
CmsXmlMessages(java.lang.String bundleName, java.lang.String configurationFileName, java.lang.String pathPrefix, java.util.Locale locale)
          Constructor, with parameters.
 
Method Summary
protected  java.lang.String getConfigValue(java.lang.String key)
          Returns the value for the given key from the configuration file.
protected  java.lang.String getConfigValue(java.lang.String key, java.lang.Object[] args)
          Returns the substituted value for the given key and arguments from the configuration file.
 CmsMessages getMessages()
          Returns the messages.
protected  boolean hasConfigValue(java.lang.String key)
          Checks if the given key is provided in the configuration file.
protected  void initLocalizationContent(java.lang.String configurationFileName)
          Initializes the content used for localizing the output.
protected  void initPathPrefix(java.lang.String pathPrefix)
          Initializes the (optional) xPath prefix to the element nodes.
 java.lang.String key(java.lang.String keyName)
          Returns the localized resource String from the configuration file, if not found or set from the resource bundle.
 java.lang.String key(java.lang.String key, java.lang.Object arg0)
          Returns the localized resource String from the configuration file, if not found or set from the resource bundle.
 java.lang.String key(java.lang.String key, java.lang.Object[] args)
          Returns the localized resource String from the configuration file, if not found or set from the resource bundle.
 java.lang.String key(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1)
          Returns the localized resource String from the configuration file, if not found or set from the resource bundle.
 java.lang.String key(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
          Returns the localized resource String from the configuration file, if not found or set from the resource bundle.
 java.lang.String keyDefault(java.lang.String keyName, java.lang.String defaultValue)
          Returns the localized resource String from the configuration file, if not found or set from the resource bundle.
 void setMessages(CmsMessages messages)
          Sets the messages.
 
Methods inherited from class org.opencms.i18n.CmsMessages
equals, formatUnknownKey, getBundleName, getDate, getDate, getDate, getDateTime, getDateTime, getDateTime, getLocale, getResourceBundle, getString, hashCode, isInitialized, isUnknownKey, key, keyWithParams, setBundleName, setLocale, setResourceBundle, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CmsXmlMessages

public CmsXmlMessages(CmsMessages messages,
                      java.lang.String configurationFileName,
                      java.lang.String pathPrefix,
                      java.util.Locale locale)
Constructor, with parameters.

Creates the necessary member objects using the passed arguments.

Parameters:
messages - the messages object to use as fallback
configurationFileName - the absolute path (including site root!) to the configuration file containing localized keys
pathPrefix - the (optional) xPath prefix to the element nodes
locale - the locale to use for localization

CmsXmlMessages

public CmsXmlMessages(java.lang.String bundleName,
                      java.lang.String configurationFileName,
                      java.lang.String pathPrefix,
                      java.util.Locale locale)
Constructor, with parameters.

Creates the necessary member objects using the passed arguments.

Parameters:
bundleName - the name of the ResourceBundle to use
configurationFileName - the absolute path (including site root!) to the configuration file containing localized keys
pathPrefix - the (optional) xPath prefix to the element nodes
locale - the locale to use for localization
Method Detail

getMessages

public CmsMessages getMessages()
Returns the messages.

Returns:
the messages

key

public java.lang.String key(java.lang.String keyName)
Returns the localized resource String from the configuration file, if not found or set from the resource bundle.

Overrides:
key in class CmsMessages
Parameters:
keyName - the key for the desired string
Returns:
the resource string for the given key
See Also:
CmsMessages.key(java.lang.String)

key

public java.lang.String key(java.lang.String key,
                            java.lang.Object arg0)
Returns the localized resource String from the configuration file, if not found or set from the resource bundle.

Overrides:
key in class CmsMessages
Parameters:
key - the message key
arg0 - the message argument
Returns:
the selected localized message for the initialized resource bundle and locale
See Also:
CmsMessages.key(java.lang.String, java.lang.Object)

key

public java.lang.String key(java.lang.String key,
                            java.lang.Object arg0,
                            java.lang.Object arg1)
Returns the localized resource String from the configuration file, if not found or set from the resource bundle.

Overrides:
key in class CmsMessages
Parameters:
key - the message key
arg0 - the first message argument
arg1 - the second message argument
Returns:
the selected localized message for the initialized resource bundle and locale
See Also:
CmsMessages.key(java.lang.String, java.lang.Object, java.lang.Object)

key

public java.lang.String key(java.lang.String key,
                            java.lang.Object arg0,
                            java.lang.Object arg1,
                            java.lang.Object arg2)
Returns the localized resource String from the configuration file, if not found or set from the resource bundle.

Overrides:
key in class CmsMessages
Parameters:
key - the message key
arg0 - the first message argument
arg1 - the second message argument
arg2 - the third message argument
Returns:
the selected localized message for the initialized resource bundle and locale
See Also:
CmsMessages.key(java.lang.String, java.lang.Object, java.lang.Object, java.lang.Object)

key

public java.lang.String key(java.lang.String key,
                            java.lang.Object[] args)
Returns the localized resource String from the configuration file, if not found or set from the resource bundle.

Overrides:
key in class CmsMessages
Parameters:
key - the message key
args - the message arguments
Returns:
the selected localized message for the initialized resource bundle and locale
See Also:
CmsMessages.key(java.lang.String, java.lang.Object[])

keyDefault

public java.lang.String keyDefault(java.lang.String keyName,
                                   java.lang.String defaultValue)
Returns the localized resource String from the configuration file, if not found or set from the resource bundle.

Overrides:
keyDefault in class CmsMessages
Parameters:
keyName - the key for the desired string
defaultValue - the default value in case the key does not exist in the bundle
Returns:
the resource string for the given key it it exists, or the given default if not
See Also:
CmsMessages.keyDefault(java.lang.String, java.lang.String)

setMessages

public void setMessages(CmsMessages messages)
Sets the messages.

Parameters:
messages - the messages

getConfigValue

protected java.lang.String getConfigValue(java.lang.String key)
Returns the value for the given key from the configuration file.

Parameters:
key - the key to get the value for
Returns:
the value for the given key

getConfigValue

protected java.lang.String getConfigValue(java.lang.String key,
                                          java.lang.Object[] args)
Returns the substituted value for the given key and arguments from the configuration file.

Parameters:
key - the key to get the value for
args - the arguments that should be substituted
Returns:
the substituted value for the given key and arguments

hasConfigValue

protected boolean hasConfigValue(java.lang.String key)
Checks if the given key is provided in the configuration file.

Parameters:
key - the key to check
Returns:
true if the given key is provided in the configuration file, otherwise false

initLocalizationContent

protected void initLocalizationContent(java.lang.String configurationFileName)
Initializes the content used for localizing the output.

Parameters:
configurationFileName - the absolute path including site root to the configuration file containing localized keys

initPathPrefix

protected void initPathPrefix(java.lang.String pathPrefix)
Initializes the (optional) xPath prefix to the element nodes.

Parameters:
pathPrefix - the (optional) xPath prefix to the element nodes