bibliothek.gui.dock.util
Class PropertyValue<A>

java.lang.Object
  extended by bibliothek.gui.dock.util.PropertyValue<A>
Type Parameters:
A - the type of wrapper value
Direct Known Subclasses:
ButtonContentValue, SilentPropertyValue

public abstract class PropertyValue<A>
extends Object

A wrapper for a value which is either read from DockProperties, or can be set by the client directly.

Author:
Benjamin Sigg

Constructor Summary
PropertyValue(PropertyKey<A> key)
          Creates a new value.
PropertyValue(PropertyKey<A> key, DockController controller)
          Creates a new value.
 
Method Summary
 PropertyKey<A> getKey()
          Gets the key which is used to access the value in DockProperties.
 A getOwnValue()
          Gets the value that was set through setValue(Object).
 DockProperties getProperties()
          Gets the currently observed properties.
 A getValue()
          Gets the current value.
 boolean isAnyValueSet()
          Tells whether any value is set.
 void setKey(PropertyKey<A> key)
          Sets the key which is used to access the value in DockProperties.
 void setProperties(DockController controller)
          Sets the DockProperties that are read from controller.
 void setProperties(DockProperties properties)
          Sets the DockProperties which should be observed.
 void setValue(A value)
          Sets the current value.
 String toString()
           
protected abstract  void valueChanged(A oldValue, A newValue)
          Invoked when the value has been changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyValue

public PropertyValue(PropertyKey<A> key)
Creates a new value.

Parameters:
key - the key used to access the value in DockProperties

PropertyValue

public PropertyValue(PropertyKey<A> key,
                     DockController controller)
Creates a new value.

Parameters:
key - the key used to access the value in DockProperties
controller - the controller from which properties are to be read
Method Detail

setProperties

public void setProperties(DockController controller)
Sets the DockProperties that are read from controller.

Parameters:
controller - the properties, can be null
See Also:
setProperties(DockProperties)

setProperties

public void setProperties(DockProperties properties)
Sets the DockProperties which should be observed.

Parameters:
properties - the new properties, can be null

getProperties

public DockProperties getProperties()
Gets the currently observed properties.

Returns:
the map, or null

getKey

public PropertyKey<A> getKey()
Gets the key which is used to access the value in DockProperties.

Returns:
the key

setKey

public void setKey(PropertyKey<A> key)
Sets the key which is used to access the value in DockProperties.

Parameters:
key - the new key

getValue

public A getValue()
Gets the current value. The result is the argument of setValue(Object) if the argument was not null, or else the value read from the properties.
Note that this method can return null even if the PropertyKey has a non-null default value.

Returns:
the value or null if no value was found at all

getOwnValue

public A getOwnValue()
Gets the value that was set through setValue(Object).

Returns:
the value, might be null

isAnyValueSet

public boolean isAnyValueSet()
Tells whether any value is set.

Returns:
true if not the default value of the key would be returned

setValue

public void setValue(A value)
Sets the current value.

Parameters:
value - the value, null if the value should be read from the properties

valueChanged

protected abstract void valueChanged(A oldValue,
                                     A newValue)
Invoked when the value has been changed.

Parameters:
oldValue - the new value
newValue - the old value

toString

public String toString()
Overrides:
toString in class Object