com.artima.place.attribute
Class Description

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

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

A localizable description.

See Also:
Serialized Form

Inner Class Summary
static class Description.Cache
          Contains a String cached description and its Locale, the cache for a Description object.
 
Constructor Summary
Description(java.util.Locale cachedLocale, java.lang.String cachedDescription)
          Constructs a new Description with passed cached description for the passed locale, and no description key resource bundle loader.
Description(ResourceBundleLoader loader, java.lang.String descriptionKey)
          Constructs a new Description with passed resource bundle loader, description key, and no cached description.
Description(ResourceBundleLoader loader, java.lang.String descriptionKey, java.util.Locale cachedLocale, java.lang.String cachedDescription)
          Constructs a new Description with passed resource bundle loader, description key, and cached description (for the passed locale).
 
Method Summary
 java.lang.Object clone()
          Clones this Description.
 boolean equals(java.lang.Object o)
          Compares this Description to the passed object for equality.
 Description.Cache getCache()
          Returns this Description's Cache, or null if none exists.
 java.lang.String getDescription()
          Returns a String description, suitable for presentation to users, appropriate to the default locale.
 java.lang.String getDescription(java.util.Locale desiredLocale)
          Returns a String description, suitable for presentation to users, which represents the best-fit description for the specified locale.
 java.lang.String getDescriptionKey()
          Returns the String description key contained in this Description, or null if none exists.
 ResourceBundleLoader getResourceBundleLoader()
          Returns the ResourceBundleLoader contained in this Description, or null if none exists.
 boolean hasCache()
          Indicates whether this Description object has a String cached description and its Locale.
 int hashCode()
          Returns a hash code for this object.
 boolean hasResources()
          Indicates whether this Description object has a ResourceBundleLoader and String description key.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Description

public Description(ResourceBundleLoader loader,
                   java.lang.String descriptionKey)
Constructs a new Description with passed resource bundle loader, description key, and no cached description.
Parameters:
loader - the ResourceBundleLoader which can load ResourceBundles for this Description.
descriptionKey - 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 descriptionKey references are null

Description

public Description(ResourceBundleLoader loader,
                   java.lang.String descriptionKey,
                   java.util.Locale cachedLocale,
                   java.lang.String cachedDescription)
Constructs a new Description with passed resource bundle loader, description key, and cached description (for the passed locale).
Parameters:
loader - the ResourceBundleLoader which can load ResourceBundles for this Description.
descriptionKey - 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 cachedDescription.
cachedDescription - the description whose locale is passed as cachedLocale that should be cached by this Description.
Throws:
NullPointerException - if any of passed loader, descriptionKey, cachedLocale, or cachedDescription references are null

Description

public Description(java.util.Locale cachedLocale,
                   java.lang.String cachedDescription)
Constructs a new Description with passed cached description for the passed locale, and no description key resource bundle loader. (Because this Description info object contains no resource bundle loader, it also requires no key with which to look up a description resource in a resource bundle.
Parameters:
cachedLocale - the Locale of the description passed as cachedDescription.
cachedDescription - the description, whose locale is passed as cachedLocale that should be cached by this Description.
Throws:
NullPointerException - if either of passed cachedLocale or cachedDescription references are null
Method Detail

getDescription

public java.lang.String getDescription()
Returns a String description, suitable for presentation to users, appropriate to the default locale.
Returns:
a String description, suitable for presentation to users, appropriate to the default locale.
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

getDescription

public java.lang.String getDescription(java.util.Locale desiredLocale)
Returns a String description, suitable for presentation to users, which represents the best-fit description for the specified locale.
Parameters:
desiredLocale - the locale for which an appropriate description is desired.
Returns:
a String description, suitable for presentation to users, appropriate to the passed desired locale.
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 Description to the passed object for equality. To be semantically equal, the class of the passed object must be Description, the passed object's cached description must be semantically equal to this object's cached description, the passed object's description key must be semantically to this object's description key, and the equals method of Description's superclass must return true.
Overrides:
equals in class java.lang.Object
Parameters:
An - object to compare to this Description
Returns:
true if this Description is semantically equal to the passed Description

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 Description.
Overrides:
clone in class java.lang.Object
Returns:
a clone of this object

getCache

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

hasResources

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

hasCache

public boolean hasCache()
Indicates whether this Description object has a String cached description and its Locale.
Returns:
true if this Description object has a String cached description and its Locale.

getResourceBundleLoader

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

getDescriptionKey

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