|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.resources.impl.ResourcesBase
org.apache.commons.resources.impl.CollectionResourcesBase
org.apache.commons.resources.impl.XMLResources
public class XMLResources
Concrete implementation of
Resources that wraps a family
(one per Locale of XML documents that share a base URL
and have name suffixes reflecting the Locale for which
the document's messages apply. Resources are looked up in a hierarchy
XML documents in a manner identical to that performed by
java.util.ResourceBundle.getBundle()..
The base URL passed to our constructor must contain the base name
of the XML document family.
For example, if the configuration URL is passed as
http://localhost/foo/Bar, the resources for the
en_US Locale would be stored under URL
http://localhost/foo/Bar_en_US.xml, and the default
resources would be stored in
http://localhost/foo/Bar.xml.
The required structure of the XML documents is very simple:
<resources>.<resource> element.<resource> element, the id
attribute contains the resource key, and the body contains a
string representation of the value.
| Constructor Summary | |
|---|---|
XMLResources(String name,
String base)
Create a new Resources instance with the specified
logical name and base resource URL. |
|
| Method Summary | |
|---|---|
protected Map |
getLocaleMap(String baseUrl,
Locale locale)
Return a Map containing the name-value mappings for
the specified base URL and requested Locale, if there
are any. |
| Methods inherited from class org.apache.commons.resources.impl.CollectionResourcesBase |
|---|
destroy, getDefaultLocale, getKeys, getLocaleList, getLocaleMap, getLocaleSuffix, getObject, setDefaultLocale |
| Methods inherited from class org.apache.commons.resources.impl.ResourcesBase |
|---|
getBufferSize, getBytes, getInputStream, getName, getReader, getString, init, isReturnNull, setBufferSize, setReturnNull |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLResources(String name,
String base)
Create a new Resources instance with the specified
logical name and base resource URL.
name - Logical name of the new instancebase - Base URL of the family of properties files that contain
the resource keys and values| Method Detail |
|---|
protected Map getLocaleMap(String baseUrl,
Locale locale)
Return a Map containing the name-value mappings for
the specified base URL and requested Locale, if there
are any. If there are no defined mappings for the specified
Locale, return an empty Map instead.
Concrete subclasses must override this method to perform the
appropriate lookup. A typical implementation will construct an
absolute URL based on the specified base URL and Locale,
retrieve the specified resource file (if any), and parse it into
a Map structure.
Caching of previously retrieved Maps (if any) should
be performed by callers of this method. Therefore, this method should
always attempt to retrieve the specified resource and load it
appropriately.
getLocaleMap in class CollectionResourcesBasebaseUrl - Base URL of the resource files for this Resources
instancelocale - Locale for which name-value mappings
are requested
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||