com.artima.place.attribute
Class Keywords

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

public class Keywords
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

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

Inner Class Summary
static class Keywords.Cache
          Contains a set of cached keywords Set and its Locale, the cache for a Keywords object.
 
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.
 Keywords.Cache getCache()
          Returns this Keywords's Cache, or null if none exists.
 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 keywords for the specified locale.
 java.lang.String getKeywordsKey()
          Returns the String keywords key contained in this Keywords, or null if none exists.
 ResourceBundleLoader getResourceBundleLoader()
          Returns the ResourceBundleLoader contained in this Keywords, or null if none exists.
 boolean hasCache()
          Indicates whether this Keywords object has a String cached keywords and their Locale.
 int hashCode()
          Returns a hash code for this object.
 boolean hasResources()
          Indicates whether this Keywords object has a ResourceBundleLoader and String keywords key.
 
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
Throws:
NullPointerException - if either of the passed loader or keywordsKey references are null

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.
Throws:
NullPointerException - if any of passed loader, keywordsKey, cachedLocale, or cachedKeywords references are null

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.
Throws:
NullPointerException - if any of passed cachedLocale, or cachedKeywords references are null
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 keywords for the specified locale. These keywords can be used by search engines to index the resource.
Throws:
NullPointerException - if passed desiredLocale is null
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

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 java.lang.Object
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 java.lang.Object
Returns:
the hash code

clone

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

getCache

public Keywords.Cache getCache()
Returns this Keywords's Cache, or null if none exists. This method will return null only if this Keywords object contains no cached String keywords. Otherwise, this method will return a Keywords.Cache object containing this object's cached String keywords and the Locale of that cached keywords (the "cached locale").
Returns:
a reference to the Keywords.Cache, which contains this object's cached keywords and locale, or null if this object contains no cache

hasResources

public boolean hasResources()
Indicates whether this Keywords object has a ResourceBundleLoader and String keywords key.
Returns:
true if this Keywords object has a ResourceBundleLoader and String keywords key.

hasCache

public boolean hasCache()
Indicates whether this Keywords object has a String cached keywords and their Locale.
Returns:
true if this Keywords object has a String cached keywords and their Locale.

getResourceBundleLoader

public ResourceBundleLoader getResourceBundleLoader()
Returns the ResourceBundleLoader contained in this Keywords, or null if none exists.
Returns:
a ResourceBundleLoader, or null if this object contains no ResourceBundleLoader.

getKeywordsKey

public java.lang.String getKeywordsKey()
Returns the String keywords key contained in this Keywords, or null if none exists.
Returns:
a String keywords key, or null if this object contains no keywords key.