OverviewSingleDeprecated

jsx3.app

class PropsBundle

Object
->jsx3.lang.Object
  ->jsx3.app.Properties
    ->jsx3.app.PropsBundle

class PropsBundle
extends jsx3.app.Properties
A subclass of jsx3.app.Properties that supports localized properties. Using this class, an application can define properties for a number of locales but only load the properties necessary to display a particular locale. Additionally, this class supports fall-through so that if a property is not defined for a particular locale that locale inherits the value from the next most specific locale.

A properties bundle can consist of one or more XML files. The main file, fileName.ext, contains the properties for the default locale, as well as the properties for any number of other locales, and metadata indicating what locales are available external to the main file. The format of this file is:
<data jsxnamespace="propsbundle" locales="externalLocales">
  <!-- the default locale -->
  <locale>
    <record jsxid="propId" jsxtext="propValue"/>
    ...
  </locale>
  <!-- additional locales -->
  <locale key="en_US">
    <record jsxid="propId" jsxtext="propValueEnUs"/>
    ...
  </locale>
  ...
</data>
externalLocales is a comma-separated list of locales that are available for this properties bundle that are defined in separate files. By spreading a properties bundle over many files, loading a bundle for a single locale is optimized. For each locale, locKey, listed in externalLocales, there must be a file fileName.locKey.ext in the same directory as the main bundle file.

Each external file has the same format as the main file except that the locales attribute of the data tag should not be specified. Any number of locales can be defined. The first locale defined should be the locale explicit in the name of the file. Only more specific locales should follow this locale. For example, file props.es.xml, should start by defining locale es and could continue with locales es_ES and es_MX but should not define locales fr or de.

Since:

3.4

Method Summary
static void
clearCache(strPath : String, objCache : jsx3.app.Cache)
Clears all the data stored in the caches internal to this class.
jsx3.app.Locale
Returns the locale for which this properties object was created.
String
Returns the base path of this properties bundle.
static jsx3.app.PropsBundle
getProps(strBasePath : String | jsx3.net.URI, objLocale : jsx3.util.Locale, objCache : jsx3.app.Cache)
Returns a properties object representing a localized view onto a properties bundle.
Methods Inherited From jsx3.app.Properties
addParent, containsKey, get, getKeys, getParents, loadXML, remove, removeAllParents, removeParent, set
Methods Inherited From jsx3.lang.Object
clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf, toString
Method Detail

clearCache

static void clearCache(strPath : String, objCache : jsx3.app.Cache)
Clears all the data stored in the caches internal to this class. Repeated calls to getProps() consult only these caches. If files have changed on disk this method must be called for the return value of getProps() to reflect these changes.

Parameters:

strPathif provided, only clear out the documents stored for the resource at path strPath.
objCacheif provided in addition to strPath, clear out any documents stored in objCache associated with the resource at path strPath.

getLocale

jsx3.app.Locale getLocale()
Returns the locale for which this properties object was created. The value returned by this method is the value sent to the getProps() method and not necessarily the most specific locale for which the properties in this view are defined.

Returns:

 

See Also:

getProps()

getPath

String getPath()
Returns the base path of this properties bundle.

Returns:

 

getProps

static jsx3.app.PropsBundle getProps(strBasePath : String | jsx3.net.URI, objLocale : jsx3.util.Locale, objCache : jsx3.app.Cache)
Returns a properties object representing a localized view onto a properties bundle.

Parameters:

strBasePaththe relative URI to the main properties file.
objLocalethe locale for which to load the localized properties. If this is not provided, the system locale is used.
objCacheif provided, any loaded XML documents will be placed in this cache.

Returns: