|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.artima.place.info.LocalizableInfo
A bundle of localizable information suitable for delivery across a network.
Constructor Summary | |
LocalizableInfo(java.util.Locale cachedLocale)
Constructs a new LocalizableInfo with passed cached
Locale and no ResourceBundleLoader . |
|
LocalizableInfo(ResourceBundleLoader loader)
Construct a LocalizableInfo with specified
ResourceBundleLoader . |
|
LocalizableInfo(ResourceBundleLoader loader,
java.util.Locale cachedLocale)
Constructs a new CachableInfo with passed
ResourceBundleLoader and cached Locale . |
Method Summary | |
void |
clearCachedLocale()
Nulls out the reference to the cached Locale contained
in this LocalizableInfo , if any. |
void |
clearResourceBundleLoader()
Nulls out the reference to the ResourceBundleLoader
contained in this LocalizableInfo , if any. |
java.lang.Object |
clone()
Clones this LocalizableInfo . |
static boolean |
compareObjectsOrNull(java.lang.Object o1,
java.lang.Object o2)
Utility method that returns true only if the two passed objects references are both null, or the objects are semantically equal. |
boolean |
equals(java.lang.Object o)
Compares this LocalizableInfo to the passed object for
equality. |
java.util.Locale |
getBestFitLocale()
Returns the best-fit locale for the default locale. |
java.util.Locale |
getBestFitLocale(java.util.Locale desiredLocale)
Returns the best-fit locale for the specified locale. |
java.util.Locale |
getCachedLocale()
Gets a reference to the cached Locale contained in this
LocalizableInfo , if one exists. |
protected ResourceBundleLoader |
getResourceBundleLoader()
Gives subclasses a reference to the ResourceBundleLoader
contained in this LocalizableInfo . |
java.util.Set |
getSupportedLocales()
Returns an unmodifiable set of Locale s which are directly
supported by this LocalizableInfo . |
boolean |
hasCachedLocale()
Indicates whether or not this LocalizableInfo contains
a cached Locale . |
int |
hashCode()
Returns a hash code for this object. |
boolean |
hasResourceBundleLoader()
Indicates whether or not this LocalizableInfo contains
a ResourceBundleLoader . |
abstract void |
purge()
Purge away information about undesired locales. |
abstract void |
purge(java.util.Locale preserveLocale)
Purge away information about any locales other than the passed Locale . |
protected void |
setCachedLocale(java.util.Locale cachedLocale)
Validates and sets the cached Locale to the passed
Locale . |
void |
stripResourceBundleLoader(java.util.Set preserveLocales)
Replaces the resource bundle with a new one that contains only the locales in the passed set. |
protected boolean |
useCache(java.util.Locale desiredLocale)
Indicates whether or not the cached locale, if any exists, should be used given a desired locale. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LocalizableInfo(ResourceBundleLoader loader)
LocalizableInfo
with specified
ResourceBundleLoader
. Because
ResourceBundleLoader
is immutable, the passed loader
may be used as part of the state of this object. The new
LocalizableInfo
object will start its life with no
locales cache.loader
- the ResourceBundleLoader
which can load
ResourceBundle
s for this
LocalizableInfo
.public LocalizableInfo(java.util.Locale cachedLocale)
LocalizableInfo
with passed cached
Locale
and no ResourceBundleLoader
.cachedLocale
- the Locale
for which information
will be cached by subclasses.public LocalizableInfo(ResourceBundleLoader loader, java.util.Locale cachedLocale)
CachableInfo
with passed
ResourceBundleLoader
and cached Locale
.loader
- the ResourceBundleLoader
which can load
ResourceBundle
s for this
LocalizableInfo
.cachedLocale
- the Locale
for which information
will be cached by subclasses.Method Detail |
protected final void setCachedLocale(java.util.Locale cachedLocale)
Locale
to the passed
Locale
.cachedLocale
- the Locale
for which information
is cached by subclasses.protected final ResourceBundleLoader getResourceBundleLoader()
ResourceBundleLoader
contained in this LocalizableInfo
.ResourceBundleLoader
, or
null
if this LocalizableInfo
contains
no ResourceBundleLoader
public final java.util.Locale getCachedLocale()
Locale
contained in this
LocalizableInfo
, if one exists.Locale
, or
null
if this LocalizableInfo
contains
no cached Locale
public java.util.Set getSupportedLocales()
Locale
s which are directly
supported by this LocalizableInfo
. The returned set will
definitely include the empty (or root) Locale
.public java.util.Locale getBestFitLocale()
public java.util.Locale getBestFitLocale(java.util.Locale desiredLocale)
desiredLocale
- the locale for which to determine a best-fit.public final boolean hasResourceBundleLoader()
LocalizableInfo
contains
a ResourceBundleLoader
. This LocalizableInfo
will contain no ResourceBundleLoader
if it was
constructed with the constructor that takes only a cached
Locale
, or if its ResourceBundleLoader
was
cleared by the clearResourceBundleLoader
method.true
if this LocalizableInfo
contains a ResourceBundleLoader
.public final void clearResourceBundleLoader()
ResourceBundleLoader
contained in this LocalizableInfo
, if any. This can be
invoked by the purge
methods of subclasses that keep a
cache of the desired locale and wish to eliminate all record of the
full localizable information contained in the
ResourceBundleLoader
.
If this LocalizableInfo
contains no cached
Locale
, then this method will fail with an
IllegalStateException
. If no cached locale exists, then
clearing the ResourceBundleLoader
would eliminate all
possibility of getting localized information from this
LocalizableInfo
. To avoid this exception, invoke this
method only if the hasCachedLocale
method returns
true
. In the absence of a cached Locale
,
the locales supported by the ResourceBundleLoader
can be
reduced by calling the stripResourceBundleLoader
method.
If this LocalizableInfo
already contains no
ResourceBundleLoader
, this method throws no exception
and has no effect.
public final void stripResourceBundleLoader(java.util.Set preserveLocales)
Locale
, the empty locale from the current
ResourceBundleLoader
will be included in the stripped
ResourceBundleLoader
anyway. If the length of the passed
set is zero, only the empty Locale
will be contained in
the stripped ResourceBundleLoader
. All
Locale
s contained in the passed Set
must
be directly supported by the ResourceBundleLoader
, i.e.,
must be included in the Set
returned by the
getSupportedLocales
method of the
ResourceBundleLoader
.preserveLocales
- a set of locales to preserve in the
ResourceBundleLoader
(all others will be removed).NullPointerException
- if the ResourceBundleLoader
contained in this LocalizableInfo
has already been
cleared, or if the passed Set
reference is
null
java.lang.IllegalArgumentException
- if any of the elements contained in
the passed Set
are not Locale
s, or if
any of the Locale
s contained in the passed
Set
are not directly supported by the
ResourceBundleLoader
.public final boolean hasCachedLocale()
LocalizableInfo
contains
a cached Locale
. This LocalizableInfo
will
contain no cached Locale
if it was constructed with the
constructor that takes only a ResourceBundleLoader
and
its cached Locale
hasn't been installed via the
setCachedLocale
method, or if a cached
Locale
was cleared by the clearCachedLocale
method.LocalizableInfo
contains a cached
Locale
.public final void clearCachedLocale()
Locale
contained
in this LocalizableInfo
, if any.
If this LocalizableInfo
contains no
ResourceBundleLoader
, then this method will fail with an
IllegalStateException
. If no
ResourceBundleLoader
exists, then clearing the cached
Locale
would eliminate all possibility of getting
localized information from this LocalizableInfo
. To
avoid this exception, invoke this method only if the
hasResourceBundleLoader
method
returns true
.
If this LocalizableInfo
already contains no
cached Locale
, this method throws no exception and has
no effect.
protected boolean useCache(java.util.Locale desiredLocale)
desiredLocale
- the desire locale against which to check for
the appropriateness of the cached locale.true
if the cached locale is the most
appropriate (best-fit) supported locale for the passed desired
locale.public abstract void purge()
ResourceBundleLoader
entirely by invoking
clearResourceBundleLoader
. Subclasses that do not use
a cache may strip away undesired locales from the
ResourceBundleLoader
via the
stripResourceBundleLoader
method. Subclasses must assume
the desired locale is the default locale.
In short, the contract of this method is: eliminate extraneous information about undesired locales, and keep only the ability to get at the desired locale, which is the current default locale.
purge
in interface Purgable
public abstract void purge(java.util.Locale preserveLocale)
Locale
. Subclasses can decide how best to implement this
method. Subclasses that use caches may eliminate the
ResourceBundleLoader
entirely by invoking
clearResourceBundleLoader
. Subclasses that do not use a
cache may strip away undesired locales from the
ResourceBundleLoader
via the
stripResourceBundleLoader
method.
In short, the contract of this method is: eliminate extraneous information about undesired locales, and keep only the ability to get at the desired locale, which is passed as a parameter to this method.
purge
in interface Purgable
preserveLocale
- a locale to preserve in the
ResourceBundleLoader
(all others will be removed).public boolean equals(java.lang.Object o)
LocalizableInfo
to the passed object for
equality. To be semantically equal, the passed object must be an
instanceof LocalizableInfo
, both
ResourceBundleLoaders
must be either null
or
semantically equal, and both cached Locales must
either be null
or semantically equal.equals
in class java.lang.Object
An
- object to compare to this LocalizableInfo
true
if this LocalizableInfo
is
semantically equal to the passed LocalizableInfo
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
LocalizableInfo
. This method merely returns
the reference returned by its superclass's clone
method.
This class's instance variable hold references to two objects, a
ResourceBundleLoader
and a cached Locale
.
Because ResourceBundleLoader
and Locale
objects are immutable, this method need not clone them in the process
of cloning the LocalizableInfo
. Although this class is
not itself immutable, the only state changes it supports involve
replacing the ResourceBundleLoader
or the cached
Locale
. Since this method merely returns the result of
Object
's implementation of clone
, its only
real effect is to make clone
public.clone
in class java.lang.Object
public static boolean compareObjectsOrNull(java.lang.Object o1, java.lang.Object o2)
o1
- an object to compare to o2o2
- an object to compare to o1
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |