org.apache.cocoon.i18n
Class XMLResourceBundle

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.i18n.XMLResourceBundle
All Implemented Interfaces:
Component, LogEnabled, Bundle

public class XMLResourceBundle
extends AbstractLogEnabled
implements Bundle

Implementation of Bundle interface for XML resources. Represents a single XML message bundle.

XML format for this resource bundle implementation is the following:

 <catalogue xml:lang="en">
   <message key="key1">Message <br/> Value 1</message>
   <message key="key2">Message <br/> Value 1</message>
   ...
 </catalogue>
 

Value can be any well formed XML snippet and it will be cached by the key specified in the attribute key. Objects returned by this Bundle implementation are instances of the ParamSaxBuffer class.

If value for a key is not present in this bundle, parent bundle will be queried.

Version:
$Id: XMLResourceBundle.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Apache Cocoon Team

Field Summary
static String AT_KEY
          XML bundle message element's key attribute name
static String EL_CATALOGUE
          XML bundle root element name
static String EL_MESSAGE
          XML bundle message element name
protected  Bundle parent
          Parent of the current bundle
protected  Map values
          Objects stored in the bundle
 
Fields inherited from interface org.apache.cocoon.i18n.Bundle
ROLE
 
Constructor Summary
XMLResourceBundle(String sourceURI, Locale locale, Bundle parent)
          Construct a bundle.
 
Method Summary
 Locale getLocale()
          Gets the locale of the bundle.
 Object getObject(String key)
          Get an instance of the ParamSaxBuffer associated with the key.
 String getSourceURI()
          Gets the source URI of the bundle.
 String getString(String key)
          Get a string representation of the value object by key.
 SourceValidity getValidity()
          Gets the validity of the bundle.
protected  boolean reload(SourceResolver resolver, long interval)
          (Re)Loads the XML bundle if necessary, based on the source URI.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EL_CATALOGUE

public static final String EL_CATALOGUE
XML bundle root element name

See Also:
Constant Field Values

EL_MESSAGE

public static final String EL_MESSAGE
XML bundle message element name

See Also:
Constant Field Values

AT_KEY

public static final String AT_KEY
XML bundle message element's key attribute name

See Also:
Constant Field Values

parent

protected Bundle parent
Parent of the current bundle


values

protected Map values
Objects stored in the bundle

Constructor Detail

XMLResourceBundle

public XMLResourceBundle(String sourceURI,
                         Locale locale,
                         Bundle parent)
Construct a bundle.

Parameters:
sourceURI - source URI of the XML bundle
locale - locale
parent - parent bundle of this bundle
Method Detail

reload

protected boolean reload(SourceResolver resolver,
                         long interval)
(Re)Loads the XML bundle if necessary, based on the source URI.

Returns:
true if reloaded successfully

getLocale

public Locale getLocale()
Gets the locale of the bundle.

Returns:
the locale

getSourceURI

public String getSourceURI()
Gets the source URI of the bundle.

Returns:
the source URI

getValidity

public SourceValidity getValidity()
Gets the validity of the bundle.

Returns:
the validity

getObject

public Object getObject(String key)
Get an instance of the ParamSaxBuffer associated with the key.

Specified by:
getObject in interface Bundle
Parameters:
key - the key
Returns:
the value, or null if no value associated with the key.

getString

public String getString(String key)
Get a string representation of the value object by key.

Specified by:
getString in interface Bundle
Parameters:
key - the key
Returns:
the string value, or null if no value associated with the key.


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.