net.jini.lookup.ui.attribute
Class Locales

java.lang.Object
  |
  +--net.jini.lookup.ui.attribute.Locales

public class Locales
extends java.lang.Object
implements java.io.Serializable

UI attribute that lists the locales supported by a generated UI.

See Also:
Serialized Form

Constructor Summary
Locales(java.util.Set locales)
          Constructs a Locales using the passed Set.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified object (the Object passed in o) with this Locales object for equality.
 java.util.Locale getFirstSupportedLocale(java.util.List locales)
          Iterates through the passed List of Locales and returns the first Locale that is supported by the UI (as defined by isLocaleSupported()), or null, if none of the Locales in the passed array are supported by the UI.
 java.util.Locale getFirstSupportedLocale(java.util.Locale[] locales)
          Looks through the passed array of Locales (in the order they appear in the array) and returns the first Locale that is supported by the UI (as defined by isLocaleSupported()), or null, if none of the Locales in the passed array are supported by the UI.
 java.util.Set getLocales()
          Returns an unmodifiable java.util.Set that contains java.util.Locale objects, one for each locale supported by the UI generated by the UI factory stored in the marshalled object of the same UIDescriptor.
 int hashCode()
          Returns the hash code value for this Locales object.
 boolean isLocaleSupported(java.util.Locale locale)
          Indicates whether or not a locale is supported by the UI generated by the UI factory stored in the marshalled object of the same UIDescriptor.
 java.util.Iterator iterator()
          Returns an iterator over the set of java.util.Locale objects, one for each locale supported by the UI generated by the UI factory stored in the marshalled object of the same UIDescriptor.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Locales

public Locales(java.util.Set locales)
Constructs a Locales using the passed Set. The Set can be mutable or immutable, and must contain only java.util.Locale objects. Each Locale must represent a locale that is supported by the UI generated by the UI factory stored in marshalled form in the same UIDescriptor.
Parameters:
locales - A Set of Locale objects. Each element must be non-null and an instance of java.util.Locale.
Throws:
NullPointerException - if locales is null or any element of locales set is null.
java.lang.IllegalArgumentException - if any non-null element of locales set is not an instance of java.util.Locale.
Method Detail

isLocaleSupported

public boolean isLocaleSupported(java.util.Locale locale)
Indicates whether or not a locale is supported by the UI generated by the UI factory stored in the marshalled object of the same UIDescriptor. This method returns true only if the passed Locale exactly matches a Locale supported by the UI, as defined by the equals() method of class java.util.Locale. For example, imagine the UI supports the "en" (General English) locale, but not the "en_US" (US English) locale. Then, if "en_US" is passed to this method, the method will return false.
Throws:
NullPointerException - if locale is null.

getFirstSupportedLocale

public java.util.Locale getFirstSupportedLocale(java.util.Locale[] locales)
Looks through the passed array of Locales (in the order they appear in the array) and returns the first Locale that is supported by the UI (as defined by isLocaleSupported()), or null, if none of the Locales in the passed array are supported by the UI.
Throws:
NullPointerException - if locales is null.

getFirstSupportedLocale

public java.util.Locale getFirstSupportedLocale(java.util.List locales)
Iterates through the passed List of Locales and returns the first Locale that is supported by the UI (as defined by isLocaleSupported()), or null, if none of the Locales in the passed array are supported by the UI.
Throws:
NullPointerException - if locales is null.

iterator

public java.util.Iterator iterator()
Returns an iterator over the set of java.util.Locale objects, one for each locale supported by the UI generated by the UI factory stored in the marshalled object of the same UIDescriptor. The returned Iterator does not support remove().

getLocales

public java.util.Set getLocales()
Returns an unmodifiable java.util.Set that contains java.util.Locale objects, one for each locale supported by the UI generated by the UI factory stored in the marshalled object of the same UIDescriptor.

equals

public boolean equals(java.lang.Object o)
Compares the specified object (the Object passed in o) with this Locales object for equality. Returns true if the specified object is not null, if the specified object's class is Locales, if the two sets of supported locales are the same size, and if every locale mentioned in the specified Locales object (passed in o) is also mentioned in this Locales object.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns the hash code value for this Locales object.
Overrides:
hashCode in class java.lang.Object