|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.5.0) E13403-06 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.jdeveloper.audit.service.Localizer
public class Localizer
A supplier of localized display strings for Audit objects. A localizer retrieves template strings from a resource bundle and instantiates it using the object as a source of values. Template strings refer to property values of the object by naming them within a pair of curly braces. See instantiate(java.lang.String, java.lang.Object)
and getValue(java.lang.String, int, int, java.lang.Object)
for details.
The typical pattern of usage of a localizer for an object which has user-visible strings is for the object to be created with a localizer instance and for it to define a method which delegates to the localizer for each kind of string associated with the object. For example, a Catgory
has a label and a description, and so has label()
and description()
methods that delegate to the localizer with keys of constructed from the non-localized category name: "category." + name() + ".label"
and "category." + name() + ".label"
, respectively. The creator of a category named "assists", then, has to supply a localizer whose resource bundle supplies strings for "category.assists.label" and "category.assists.description". A class which uses a localizer should document the keys that it constructs and uses. This class is designed to be subclassable, though clients which use resource bundles in typical fashion should not need to do so.
Constructor Summary | |
---|---|
protected |
Localizer(java.lang.String bundleName, java.lang.ClassLoader loader) Creates a localizer. |
Method Summary | |
---|---|
java.util.ResourceBundle |
getBundle() Gets the resource bundle for this localizer. |
protected java.util.ResourceBundle |
getBundle(java.lang.String bundleName, java.lang.ClassLoader loader) Gets a resource bundle. |
java.lang.String |
getBundleName() Gets the name of the resource bundle for this localizer. |
protected static java.lang.Object |
getValue(java.lang.String string, int first, int last, java.lang.Object bean) Gets the value of a property of an object. |
static Localizer |
instance(java.lang.Class bundleClass) Gets a localizer by class. |
static Localizer |
instance(java.lang.String bundleName) Gets a localizer by name. |
static Localizer |
instance(java.lang.String bundleName, java.lang.ClassLoader loader) Gets a localizer by name, using the given Class Loader. |
static java.lang.String |
instantiate(java.lang.String message, java.lang.Object bean) Instantiate a localized string from a template string and an object. |
static java.lang.String |
instantiate(java.lang.String message, java.lang.Object bean, boolean erase) Instantiate a localized string from a template string and an object. |
java.lang.String |
localize(java.lang.String key, java.lang.Object object) Creates a localized string based on a key and an object. |
java.lang.String |
localize(java.lang.String key1, java.lang.String key2, java.lang.Object object) Creates a localized string based on a key, a fallback key, and an object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Localizer(java.lang.String bundleName, java.lang.ClassLoader loader)
getBundle()
to get the bundle using the bundle name and the given Class Loader.
bundleName
- The name of the resource bundle used by this localizer.loader
- The ClassLoader from which to load the resource bundle.Method Detail |
---|
public static Localizer instance(java.lang.String bundleName)
bundleName
- The name of the resource bundle to use.public static Localizer instance(java.lang.String bundleName, java.lang.ClassLoader loader)
bundleName
- The name of the resource bundle to use.loader
- The ClassLoader from which to attempt to load the resource bundle.public static Localizer instance(java.lang.Class bundleClass)
Unless the type is a subclass of ResourceBundle
, the bundle name will be the type name with "Bundle" appended.
bundleClass
- The class of the resource bundle to use.public java.lang.String getBundleName()
public java.util.ResourceBundle getBundle()
ResourceBundle
for this localizer.public java.lang.String localize(java.lang.String key, java.lang.Object object)
instantiate(java.lang.String, java.lang.Object)
).key
- The name of a template string in the resource bundle.object
- An object supplying properties named in the template string.public java.lang.String localize(java.lang.String key1, java.lang.String key2, java.lang.Object object)
instantiate(java.lang.String, java.lang.Object)
).key1
- The name of a template string in the resource bundle.key2
- The fallback name of a template string in the resource bundle.object
- An object supplying properties named in the template strings.protected java.util.ResourceBundle getBundle(java.lang.String bundleName, java.lang.ClassLoader loader) throws java.util.MissingResourceException
Localizer
implementation calls ResourceBundle.getBundle(bundleName)
to get the bundle.bundleName
- The name of the resource bundle.loader
- The class loader from which to load the resource bundle.ResourceBundle
.java.util.MissingResourceException
public static java.lang.String instantiate(java.lang.String message, java.lang.Object bean)
getValue(java.lang.String, int, int, java.lang.Object)
with the property name and the object.public static java.lang.String instantiate(java.lang.String message, java.lang.Object bean, boolean erase)
getValue(java.lang.String, int, int, java.lang.Object)
with the property name and the object.
If erase
is true and getValue
returns null, immediately surrounding pairs of single or double quotes are erased and extra spaces are collapsed. This behavior in many cases allows a template string to instantiate acceptably both when properties are available and when they are not.
protected static java.lang.Object getValue(java.lang.String string, int first, int last, java.lang.Object bean)
Violation
or Map
, the value is the value returned by the getter method corresponding to the property name, or null if no getter method exists or if it throws an exception.Violation
, the value is determined as follows:
Violation
with the indicated index, or null if the index is too large.Violation
, the value is the value of that parameter.Map
, the value is the value returned by Map.get(java.lang.Object)
using the property name as the key.string
- A string containing the property name.first
- The index of the first character of the property name.last
- The index of the first character following the property name.bean
- The object from which to get property values.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.5.0) E13403-06 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |