com.oopitis.weather
Class Feature

java.lang.Object
  extended by com.oopitis.weather.Feature

public class Feature
extends java.lang.Object

Objects of this class represent features, or data groups, of weather services. A feature is a group of data that share the same semantics; in other words, features categorize weather information. A feature is associated with a set of weather properties but it does not contain the properties. Different service providers may support different sets of properties for the same feature.

A Feature object is often assigned to a public static final field, in other words, a Java constant. As a constant, a feature has a constant name for users to identify the Java identifier it is assigned to. A feature may also have a locale-sensitive name for display.

See Also:
WeatherService.CONDITIONS, WeatherService.CONDITIONS_MINUTE, WeatherService.CONDITIONS_HOUR, WeatherService.CONDITIONS_DAY, WeatherService.ALERT

Field Summary
protected  java.lang.String resourceBundleName
          The base resource bundle name from the constructor.
protected  java.lang.String resourceKey
          The resource key from the constructor.
 
Constructor Summary
Feature(java.lang.String constantName)
          Constructs a feature constant.
Feature(java.lang.String constantName, java.lang.String resourceBundleName, java.lang.String resourceKey)
          Constructs a feature constant with a locale-sensitive name from resource bundles.
 
Method Summary
 java.lang.String getConstantName()
          Gets the fully qualified Java name of this constant.
 WeatherPropertySet getProperties(WeatherService service)
          Gets the list of properties associated with this feature.
 java.lang.String toString()
          Returns the string representation for the default locale.
 java.lang.String toString(java.util.Locale locale)
          Returns a locale-specific string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resourceBundleName

protected final java.lang.String resourceBundleName
The base resource bundle name from the constructor.


resourceKey

protected final java.lang.String resourceKey
The resource key from the constructor.

Constructor Detail

Feature

public Feature(java.lang.String constantName)
Constructs a feature constant.

Parameters:
constantName - the constant name
Throws:
java.lang.NullPointerException - if the given constant name is null

Feature

public Feature(java.lang.String constantName,
               java.lang.String resourceBundleName,
               java.lang.String resourceKey)
Constructs a feature constant with a locale-sensitive name from resource bundles.

Parameters:
constantName - the constant name
resourceBundleName - the base resource bundle name
resourceKey - the resource key
Throws:
java.lang.NullPointerException - if any of the given arguments is null
Method Detail

getProperties

public WeatherPropertySet getProperties(WeatherService service)
Gets the list of properties associated with this feature. This operation is equivalent to service.getApplicableProperties(this).

Parameters:
service - the weather service that supports this feature
Returns:
the list of properties associated with this feature
Throws:
UnsupportedFeatureException - if this feature is not supported by the given weather service
See Also:
WeatherService.getApplicableProperties(Feature)

getConstantName

public final java.lang.String getConstantName()
Gets the fully qualified Java name of this constant.

Returns:
the fully qualified Java name of this constant

toString

public java.lang.String toString(java.util.Locale locale)
Returns a locale-specific string representation.

Implementation note: Subclasses that override this method without overriding toString() must never invoke toString() directly or indirectly in the implementation. Doing so will result in an infinite loop and eventually a StackOverflowError.

Parameters:
locale - the locale for which the string is prepared; if null, the system default locale is used.
Returns:
the locale-specific string representation or the constant name if this object does not have a locale-sensitive name.
Throws:
java.util.MissingResourceException - if a resource key and bundle name are specified but the key is not found in any variations or the base bundle
See Also:
toString()

toString

public java.lang.String toString()
Returns the string representation for the default locale. This method returns this.toString(Locale.getDefault()) if the value is not null; otherwise the constant name is returned.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this constant for the default locale, or the constant name
See Also:
toString(Locale), Locale.getDefault()