org.millstone.base.data.util
Class ObjectProperty

java.lang.Object
  |
  +--org.millstone.base.data.util.ObjectProperty
All Implemented Interfaces:
Property, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeNotifier

public class ObjectProperty
extends java.lang.Object
implements Property, Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier

A simple data object containing one typed value. This class is a straightforward implementation of the the Property interface.

Since:
3.0
Version:
3.0.3
Author:
IT Mill Ltd.

Nested Class Summary
 
Nested classes inherited from class org.millstone.base.data.Property
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeEvent, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Constructor Summary
ObjectProperty(java.lang.Object value)
          Creates a new instance of ObjectProperty with the given value.
ObjectProperty(java.lang.Object value, java.lang.Class type)
          Creates a new instance of ObjectProperty with the given value and type.
ObjectProperty(java.lang.Object value, java.lang.Class type, boolean readOnly)
          Creates a new instance of ObjectProperty with the given value, type and read-only mode status.
 
Method Summary
 void addListener(Property.ReadOnlyStatusChangeListener listener)
          Registers a new read-only status change listener for this Property.
 void addListener(Property.ValueChangeListener listener)
          Registers a new value change listener for this ObjectProperty.
 java.lang.Class getType()
          Returns the type of the ObjectProperty.
 java.lang.Object getValue()
          Gets the value stored in the Property.
 boolean isReadOnly()
          Tests if the Property is in read-only mode.
 void removeListener(Property.ReadOnlyStatusChangeListener listener)
          Remove a previously registered read-only status change listener.
 void removeListener(Property.ValueChangeListener listener)
          Remove a previously registered value change listener.
 void setReadOnly(boolean newStatus)
          Sets the Property's read-only mode to the specified status.
 void setValue(java.lang.Object newValue)
          Set the value of the property.
 java.lang.String toString()
          Returns the value of the ObjectProperty in human readable textual format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectProperty

public ObjectProperty(java.lang.Object value)
Creates a new instance of ObjectProperty with the given value. The type of the property is automatically initialized to be the type of the given value.

Parameters:
value - Initial value of the Property

ObjectProperty

public ObjectProperty(java.lang.Object value,
                      java.lang.Class type)
Creates a new instance of ObjectProperty with the given value and type.

Parameters:
value - Initial value of the Property
type - The type of the value. The value must be assignable to given type

ObjectProperty

public ObjectProperty(java.lang.Object value,
                      java.lang.Class type,
                      boolean readOnly)
Creates a new instance of ObjectProperty with the given value, type and read-only mode status.

Parameters:
value - Initial value of the property.
type - The type of the value. value must be assignable to this type.
readOnly - Sets the read-only mode.
Method Detail

getType

public final java.lang.Class getType()
Returns the type of the ObjectProperty. The methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue.

Specified by:
getType in interface Property
Returns:
type of the Property

getValue

public java.lang.Object getValue()
Gets the value stored in the Property.

Specified by:
getValue in interface Property
Returns:
the value stored in the Property

toString

public java.lang.String toString()
Returns the value of the ObjectProperty in human readable textual format. The return value should be assignable to the setValue method if the Property is not in read-only mode.

Specified by:
toString in interface Property
Overrides:
toString in class java.lang.Object
Returns:
String representation of the value stored in the ObjectProperty

isReadOnly

public boolean isReadOnly()
Tests if the Property is in read-only mode. In read-only mode calls to the method setValue will throw ReadOnlyExceptions and will not modify the value of the Property.

Specified by:
isReadOnly in interface Property
Returns:
true if the Property is in read-only mode, false if it's not

setReadOnly

public void setReadOnly(boolean newStatus)
Sets the Property's read-only mode to the specified status.

Specified by:
setReadOnly in interface Property
Parameters:
newStatus - new read-only status of the Property

setValue

public void setValue(java.lang.Object newValue)
              throws Property.ReadOnlyException,
                     Property.ConversionException
Set the value of the property. This method supports setting from Strings if either String is directly assignable to property type, or the type class contains a string constructor.

Specified by:
setValue in interface Property
Parameters:
newValue - New value of the property.
Throws:
Property.ReadOnlyException - if the object is in read-only mode
Property.ConversionException - if newValue can't be converted into the Property's native type directly or through String
Property.ConversionException - if newValue can't be converted into the Property's native type directly or through String
Property.ReadOnlyException - if the object is in read-only mode

removeListener

public void removeListener(Property.ValueChangeListener listener)
Remove a previously registered value change listener.

Specified by:
removeListener in interface Property.ValueChangeNotifier
Parameters:
listener - listener to be removed

addListener

public void addListener(Property.ValueChangeListener listener)
Registers a new value change listener for this ObjectProperty.

Specified by:
addListener in interface Property.ValueChangeNotifier
Parameters:
listener - the new Listener to be registered

addListener

public void addListener(Property.ReadOnlyStatusChangeListener listener)
Registers a new read-only status change listener for this Property.

Specified by:
addListener in interface Property.ReadOnlyStatusChangeNotifier
Parameters:
listener - the new Listener to be registered

removeListener

public void removeListener(Property.ReadOnlyStatusChangeListener listener)
Remove a previously registered read-only status change listener.

Specified by:
removeListener in interface Property.ReadOnlyStatusChangeNotifier
Parameters:
listener - listener to be removed


Copyright © 2000,2001,2002 IT Mill Ltd. All Rights Reserved.