NASA World Wind

gov.nasa.worldwind.avlist
Class AVListImpl

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
All Implemented Interfaces:
AVList
Direct Known Subclasses:
BasicNetworkStatus, LineBuilder, PickedObject, UserFacingIcon, WWObjectImpl

public class AVListImpl
extends Object
implements AVList

An implementation class for the AVList interface. Classes implementing AVList can subclass or aggreate this class to provide default AVList functionality. This class maintains a hash table of attribute-value pairs.

This class implements a notification mechanism for attribute-value changes. The mechanism provides a means for objects to observe attribute changes or queries for certain keys without explicitly monitoring all keys. See PropertyChangeSupport.


Field Summary
protected  PropertyChangeSupport changeSupport
          Available to sub-classes for further exposure of property-change functionality.
 
Constructor Summary
AVListImpl()
          Creates an empty attribute-value list.
AVListImpl(Object sourceBean)
          Constructor enabling aggregation
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds the specified all-property property change listener that will be called for all list changes.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds a property change listener for the specified key.
 AVList clearList()
           
 AVList copy()
          Returns a shallow copy of this AVList instance: the keys and values themselves are not cloned.
 void firePropertyChange(PropertyChangeEvent propertyChangeEvent)
          Calls all registered property change listeners with the specified property change event.
 void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Calls all property change listeners associated with the specified key.
static Double getDoubleValue(AVList avList, String key)
           
static Double getDoubleValue(AVList avList, String key, Double defaultValue)
           
 Set<Map.Entry<String,Object>> getEntries()
           
static Integer getIntegerValue(AVList avList, String key)
           
static Integer getIntegerValue(AVList avList, String key, Integer defaultValue)
           
static Long getLongValue(AVList avList, String key)
           
static Long getLongValue(AVList avList, String key, Long defaultValue)
           
static String getStringValue(AVList avList, String key)
           
static String getStringValue(AVList avList, String key, String defaultValue)
           
 String getStringValue(String key)
          Returns the value for a specified key.
 Object getValue(String key)
          Returns the value for a specified key.
 Collection<Object> getValues()
           
 boolean hasKey(String key)
          Indicates whether a key is in the collection.
 void removeKey(String key)
          Removes a specified key from the collection if the key exists, otherwise returns without affecting the collection.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the specified all-property property change listener.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Removes a property change listener associated with the specified key.
 void setValue(String key, Object value)
          Adds a key/value pair to the list.
 void setValues(AVList list)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeSupport

protected final PropertyChangeSupport changeSupport
Available to sub-classes for further exposure of property-change functionality.

Constructor Detail

AVListImpl

public AVListImpl()
Creates an empty attribute-value list.


AVListImpl

public AVListImpl(Object sourceBean)
Constructor enabling aggregation

Parameters:
sourceBean - The bean to be given as the soruce for any events.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: AVList
Adds the specified all-property property change listener that will be called for all list changes.

Specified by:
addPropertyChangeListener in interface AVList
Parameters:
listener - the listener to call.
See Also:
PropertyChangeSupport

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Description copied from interface: AVList
Adds a property change listener for the specified key.

Specified by:
addPropertyChangeListener in interface AVList
Parameters:
propertyName - the key to associate the listener with.
listener - the listener to associate with the key.
See Also:
PropertyChangeSupport

clearList

public final AVList clearList()
Specified by:
clearList in interface AVList

copy

public AVList copy()
Description copied from interface: AVList
Returns a shallow copy of this AVList instance: the keys and values themselves are not cloned.

Specified by:
copy in interface AVList
Returns:
a shallow copy of this AVList.

firePropertyChange

public void firePropertyChange(PropertyChangeEvent propertyChangeEvent)
Description copied from interface: AVList
Calls all registered property change listeners with the specified property change event.

Specified by:
firePropertyChange in interface AVList
Parameters:
propertyChangeEvent - the event
See Also:
PropertyChangeSupport

firePropertyChange

public void firePropertyChange(String propertyName,
                               Object oldValue,
                               Object newValue)
Description copied from interface: AVList
Calls all property change listeners associated with the specified key. No listeners are called if odValue and newValue are equal and non-null.

Specified by:
firePropertyChange in interface AVList
Parameters:
propertyName - the key
oldValue - the value associated with the key before the even causing the firing.
newValue - the new value associated with the key.
See Also:
PropertyChangeSupport

getDoubleValue

public static Double getDoubleValue(AVList avList,
                                    String key)

getDoubleValue

public static Double getDoubleValue(AVList avList,
                                    String key,
                                    Double defaultValue)

getEntries

public Set<Map.Entry<String,Object>> getEntries()
Specified by:
getEntries in interface AVList

getIntegerValue

public static Integer getIntegerValue(AVList avList,
                                      String key)

getIntegerValue

public static Integer getIntegerValue(AVList avList,
                                      String key,
                                      Integer defaultValue)

getLongValue

public static Long getLongValue(AVList avList,
                                String key)

getLongValue

public static Long getLongValue(AVList avList,
                                String key,
                                Long defaultValue)

getStringValue

public static String getStringValue(AVList avList,
                                    String key)

getStringValue

public static String getStringValue(AVList avList,
                                    String key,
                                    String defaultValue)

getStringValue

public final String getStringValue(String key)
Description copied from interface: AVList
Returns the value for a specified key. The value must be a String.

Specified by:
getStringValue in interface AVList
Parameters:
key - the attribute name. May not be null.
Returns:
the attribute value if one exists in the collection, otherwise null.

getValue

public final Object getValue(String key)
Description copied from interface: AVList
Returns the value for a specified key.

Specified by:
getValue in interface AVList
Parameters:
key - the attribute name. May not be null.
Returns:
the attribute value if one exists in the collection, otherwise null.

getValues

public final Collection<Object> getValues()
Specified by:
getValues in interface AVList

hasKey

public final boolean hasKey(String key)
Description copied from interface: AVList
Indicates whether a key is in the collection.

Specified by:
hasKey in interface AVList
Parameters:
key - the attribute name. May not be null.
Returns:
true if the key exists in the collection, otherwise false.

removeKey

public final void removeKey(String key)
Description copied from interface: AVList
Removes a specified key from the collection if the key exists, otherwise returns without affecting the collection.

Specified by:
removeKey in interface AVList
Parameters:
key - the attribute name. May not be null.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: AVList
Removes the specified all-property property change listener.

Specified by:
removePropertyChangeListener in interface AVList
Parameters:
listener - the listener to remove.
See Also:
PropertyChangeSupport

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Description copied from interface: AVList
Removes a property change listener associated with the specified key.

Specified by:
removePropertyChangeListener in interface AVList
Parameters:
propertyName - the key associated with the change listener.
listener - the listener to remove.
See Also:
PropertyChangeSupport

setValue

public final void setValue(String key,
                           Object value)
Description copied from interface: AVList
Adds a key/value pair to the list. Replaces an existing key/value pair if the list already contains the key.

Specified by:
setValue in interface AVList
Parameters:
key - the attribute name. May not be null.
value - the attribute value. May be null, in which case any existing value for the key is removed from the collection.

setValues

public final void setValues(AVList list)
Specified by:
setValues in interface AVList

NASA World Wind