com.artima.place.attribute
Class Name

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

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

A localizable name.

See Also:
Serialized Form

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

Constructor Detail

Name

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

Name

public Name(ResourceBundleLoader loader,
            java.lang.String nameKey,
            java.util.Locale cachedLocale,
            java.lang.String cachedName)
Constructs a new Name with passed resource bundle loader, name key, and cached name (for the passed locale).
Parameters:
loader - the ResourceBundleLoader which can load ResourceBundles for this Name.
nameKey - the String key with which the String resource can be retrieved from a ResourceBundle provided by the ResourceBundleLoader
cachedLocale - the Locale of the name passed as cachedName.
cachedName - the name whose locale is passed as cachedLocale that should be cached by this Name.
Throws:
NullPointerException - if any of passed loader, nameKey, cachedLocale, or cachedName references are null

Name

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

getName

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

getName

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

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

getCache

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

hasResources

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

hasCache

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

getResourceBundleLoader

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

getNameKey

public java.lang.String getNameKey()
Returns the String name key contained in this Name, or null if none exists.
Returns:
a String name key, or null if this object contains name key.