com.google.gwt.i18n.rebind
Class AbstractResource

java.lang.Object
  extended by com.google.gwt.i18n.rebind.AbstractResource
Direct Known Subclasses:
AnnotationsResource

public abstract class AbstractResource
extends java.lang.Object

AbstractResource serves the same purpose as java ResourceBundle/PropertyResourceBundle.

Each Resource belongs to a resource tree, indicated by the path attribute.

AbstractResource uses a Factory pattern rather than a single static method to load itself given an abstract string path.

One advanced feature which should not be used outside the core GWT system is that resources can have more than one parent, for instance pets_en_US could have pets_en as one parent and animals_en_US as another. The alternative parents have lower precedence than any primary parent. Each alternative parent is associated with a separate resource tree.


Nested Class Summary
static class AbstractResource.MissingResourceException
          Exception indicating a required resource was not found.
static class AbstractResource.ResourceList
          Encapsulates an ordered set of resources to search for translations.
 
Field Summary
static int REPORT_KEYS_THRESHOLD
          Error messages concerning missing keys should include the defined keys if the number of keys is below this threshold.
 
Constructor Summary
AbstractResource(GwtLocale matchLocale)
           
 
Method Summary
 java.util.Collection<java.lang.String> getExtensions(java.lang.String key)
           
 java.lang.String getRequiredString(java.lang.String key)
          Get a string and fail if not present.
 java.lang.String getRequiredStringExt(java.lang.String key, java.lang.String extension)
          Get a string (with optional extension) and fail if not present.
 java.lang.String getString(java.lang.String key)
          Get a key.
abstract  java.lang.String getStringExt(java.lang.String key, java.lang.String extension)
          Get a key with an extension.
 java.util.Set<java.lang.String> keySet()
          Keys associated with this resource.
 boolean notEmpty()
           
 java.lang.String toString()
           
 java.lang.String toVerboseString()
          A multi-line representation of this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REPORT_KEYS_THRESHOLD

public static final int REPORT_KEYS_THRESHOLD
Error messages concerning missing keys should include the defined keys if the number of keys is below this threshold.

See Also:
Constant Field Values
Constructor Detail

AbstractResource

public AbstractResource(GwtLocale matchLocale)
Method Detail

getExtensions

public java.util.Collection<java.lang.String> getExtensions(java.lang.String key)
Parameters:
key -

getRequiredString

public final java.lang.String getRequiredString(java.lang.String key)
Get a string and fail if not present.

Parameters:
key -
Returns:
the requested string

getRequiredStringExt

public final java.lang.String getRequiredStringExt(java.lang.String key,
                                                   java.lang.String extension)
Get a string (with optional extension) and fail if not present.

Parameters:
key -
extension -
Returns:
the requested string

getString

public final java.lang.String getString(java.lang.String key)
Get a key.

Parameters:
key - key to lookup
Returns:
the string for the given key or null if not found
See Also:
ResourceBundle.getString(java.lang.String)

getStringExt

public abstract java.lang.String getStringExt(java.lang.String key,
                                              java.lang.String extension)
Get a key with an extension. Identical to getString() if extension is null.

Parameters:
key - to lookup
extension - extension of the key, nullable
Returns:
string or null

keySet

public java.util.Set<java.lang.String> keySet()
Keys associated with this resource.

Returns:
keys

notEmpty

public boolean notEmpty()
Returns:
true if this resource has any keys

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toVerboseString

public java.lang.String toVerboseString()
A multi-line representation of this object.

Returns:
verbose string