com.artima.place.info
Class Keywords

java.lang.Object
  |
  +--com.artima.place.info.LocalizableInfo
        |
        +--com.artima.place.info.Keywords
All Implemented Interfaces:
java.lang.Cloneable, Purgable, java.io.Serializable

public class Keywords
extends LocalizableInfo

A bundle of localizable keywords. This information could, for example, be used by search engines spiders when adding this resource to their database.

See Also:
Serialized Form

Constructor Summary
Keywords(java.util.Locale cachedLocale, java.util.Set cachedKeywords)
          Constructs a new Keywords with passed cached keywords for the passed locale, and no keywords key and resource bundle loader.
Keywords(ResourceBundleLoader loader, java.lang.String keywordsKey)
          Constructs a new Keywords with passed resource bundle loader, keywords key, and no cached keywords.
Keywords(ResourceBundleLoader loader, java.lang.String keywordsKey, java.util.Locale cachedLocale, java.util.Set cachedKeywords)
          Constructs a new Keywords with passed resource bundle loader, keywords key, and cached keywords (for the passed locale).
 
Method Summary
 java.lang.Object clone()
          Clones this Keywords.
 boolean equals(java.lang.Object o)
          Compares this Keywords to the passed object for equality.
 java.util.SortedSet getKeywords()
          Returns a SortedSet of keywords, suitable for presentation to users, appropriate to the default locale.
 java.util.SortedSet getKeywords(java.util.Locale desiredLocale)
          Returns a SortedSet of keywords, suitable for presentation to users, which represents the best-fit name for the specified locale.
 int hashCode()
          Returns a hash code for this object.
 void purge()
          Purge away information about undesired locales.
 void purge(java.util.Locale preserveLocale)
          Purge away information about all locales except the passed desired locale.
 
Methods inherited from class com.artima.place.info.LocalizableInfo
clearCachedLocale, clearResourceBundleLoader, compareObjectsOrNull, getBestFitLocale, getBestFitLocale, getCachedLocale, getResourceBundleLoader, getSupportedLocales, hasCachedLocale, hasResourceBundleLoader, setCachedLocale, stripResourceBundleLoader, useCache
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Keywords

public Keywords(ResourceBundleLoader loader,
                java.lang.String keywordsKey)
Constructs a new Keywords with passed resource bundle loader, keywords key, and no cached keywords.
Parameters:
loader - the ResourceBundleLoader which can load ResourceBundles for this Keywords.
keywordsKey - the String key with which the String resource can be retrieved from a ResourceBundle provided by the ResourceBundleLoader

Keywords

public Keywords(ResourceBundleLoader loader,
                java.lang.String keywordsKey,
                java.util.Locale cachedLocale,
                java.util.Set cachedKeywords)
Constructs a new Keywords with passed resource bundle loader, keywords key, and cached keywords (for the passed locale).

The passed Set will not be used as part of the state of this newly constructed object. Rather its contents will be used to initialize an unmodifiable Set which will be returned by getKeywords when the locale passed in cachedLocale is requested.

Parameters:
loader - the ResourceBundleLoader which can load ResourceBundles for this Keywords.
cachedKeywords - a set of keywords that will be stored as part of the state of this object, representing the root locale.
keywordsKey - the String key with which the String resource can be retrieved from a ResourceBundle provided by the ResourceBundleLoader
cachedLocale - the Locale of the description passed as cachedKeywords.
cachedKeywords - the description, whose locale is passed as cachedLocale that should be cached by this Keywords.

Keywords

public Keywords(java.util.Locale cachedLocale,
                java.util.Set cachedKeywords)
Constructs a new Keywords with passed cached keywords for the passed locale, and no keywords key and resource bundle loader. (Because this Keywords info object contains no resource bundle loader, it also requires no key with which to look up a keywords resource in a resource bundle.

The passed Set will not be used as part of the state of this newly constructed object. Rather its contents will be used to initialize an unmodifiable Set which will be returned by getKeywords when the locale passed in cachedLocale is requested.

Parameters:
cachedLocale - the Locale of the description passed as cachedKeywords.
cachedKeywords - the keywords, whose locale is passed as cachedLocale that should be cached by this Keywords.
Method Detail

getKeywords

public java.util.SortedSet getKeywords()
Returns a SortedSet of keywords, suitable for presentation to users, appropriate to the default locale. These keywords can be used by search engines to index the resource.
Throws:
MissingResourceException - if a codebase URL is found to be unusable. (Because URLString enforces well-formedness of all URLs used by this method, this exception probably indicates the protocol was unknown.), or if a ResourceBundle is not found at the expected codebase

getKeywords

public java.util.SortedSet getKeywords(java.util.Locale desiredLocale)
Returns a SortedSet of keywords, suitable for presentation to users, which represents the best-fit name for the specified locale. These keywords can be used by search engines to index the resource.
Throws:
MissingResourceException - if a codebase URL is found to be unusable. (Because URLString enforces well-formedness of all URLs used by this method, this exception probably indicates the protocol was unknown.), or if a ResourceBundle is not found at the expected codebase

purge

public void purge()
Purge away information about undesired locales. If no cache exists, this method first fills the cache based on the default locale. If a cache currently exists, that cache will be left intact. Once a cache is in place, this method will clear the resource bundle loader.
Overrides:
purge in class LocalizableInfo

purge

public void purge(java.util.Locale preserveLocale)
Purge away information about all locales except the passed desired locale. This method first makes sure the cache is appropriate to the passed desired locale. Once the cache is in place, this method will clear the resource bundle loader.
Overrides:
purge in class LocalizableInfo
Parameters:
preserveLocale - a locale to preserve in this Keywords.

equals

public boolean equals(java.lang.Object o)
Compares this Keywords to the passed object for equality. To be semantically equal, the class of the passed object must be Keywords, the passed object's cached keywords must be semantically equal to this object's cached keywords, the passed object's keywords key must be semantically to this object's keywords key, and the equals method of Keywords' superclass must return true.
Overrides:
equals in class LocalizableInfo
Parameters:
An - object to compare to this Keywords
Returns:
true if this Keywords is semantically equal to the passed Keywords

hashCode

public int hashCode()
Returns a hash code for this object.
Overrides:
hashCode in class LocalizableInfo
Returns:
the hash code

clone

public java.lang.Object clone()
Clones this Keywords.
Overrides:
clone in class LocalizableInfo
Returns:
a clone of this object