Joda System API

org.joda.property.impl
Class AbstractProperty

java.lang.Object
  |
  +--org.joda.property.impl.AbstractModelElement
        |
        +--org.joda.property.impl.AbstractProperty
All Implemented Interfaces:
InitializableProperty, ModelElement, Property, Property.Internal, java.io.Serializable
Direct Known Subclasses:
AbstractBooleanicProperty, AbstractDateTimeProperty, AbstractListProperty, AbstractMapProperty, AbstractNumericProperty, DefaultClassProperty, DefaultLinkProperty, DefaultLocaleProperty, DefaultObjectProperty, DefaultStringProperty

public abstract class AbstractProperty
extends AbstractModelElement
implements Property, Property.Internal, InitializableProperty

Standard implementation of the basic read only property.

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.joda.property.Property
Property.Internal
 
Constructor Summary
protected AbstractProperty()
          Constructor
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a listener to the list of those receiving change events.
 Bean bean()
          Get the bean which owns this property.
protected  void checkArgumentNotNull(java.lang.Object object)
          Check whether the argument to a property method is null or not, throwing the appropriate exception if not.
protected  void checkModifiable()
          Check whether the property is currently modifiable or not, throwing the appropriate exception if not.
protected  void checkValueNotNull()
          Check whether the property is currently null or not, throwing the appropriate exception if not.
protected  void checkValueNotNull(java.lang.Object object)
          Check whether the property is currently null or not, throwing the appropriate exception if not.
 void cloneDeep(IdentityBasedHashMap clonedObjects, Bean bean)
          Clone this property avoiding recursion.
protected  java.lang.Object convertObject(java.lang.Object object)
          Convert an object, typically passed in as a parameter, to the underlying type for this property.
protected  Property createClonedProperty(Bean bean)
          Create a clone of this property, ignoring the data contents
 PropertyData data()
          Get the property data acting as the data store.
 boolean equals(java.lang.Object object)
          Equals compares the Property to another property.
 boolean equalsValue(java.lang.Object object)
          EqualsValue compares the value of the property to another object.
 void firePropertyChange(java.lang.Object oldValue, java.lang.Object newValue)
          Fire a value changed event for the property.
protected  void firePropertyChange(java.beans.PropertyChangeEvent ev)
           
 java.lang.String getContentName()
          Get the name of this property without the 'List' or 'Link' suffixes.
 java.lang.Class getContentType()
          Get the type of the content of the property type.
 java.lang.String getPropertyName()
          Get the name of this property.
protected  Property getThis()
          Get 'this'.
 int hashCode()
          Get the hashCode for the property in line with the spec.
 void initBeanCreated(PropertyInit init)
          Initialize after the bean has been completed.
 void initPropertyCreated(PropertyInit init)
          Initialize after the constructor.
 boolean isModifiable()
          Get whether the property is currently modifiable or not.
 boolean isNull()
          Test if the property currently set to null.
 boolean isReadOnly()
          Get whether the property is never modifiable.
protected  void populateClonedProperty(IdentityBasedHashMap clonedObjects, Property property)
          Populate the clone of this property with the same data as this one
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove the specified listener from the list currently receiving change events.
abstract  void set(java.lang.Object propertyValue)
          Set the property's value as an object.
 void setModifiable(boolean modifiable)
          Set whether the property is currently modifiable or not.
 void setReadOnly()
          Set the property as never modifiable.
 java.lang.String toDataString()
           
abstract  java.lang.Object toObject()
          Get the property's value as an object.
 java.lang.String toString()
          Get a debug string for the property.
 
Methods inherited from class org.joda.property.impl.AbstractModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.property.Property
getPropertyType
 
Methods inherited from interface org.joda.property.ModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 

Constructor Detail

AbstractProperty

protected AbstractProperty()
Constructor

Method Detail

initPropertyCreated

public void initPropertyCreated(PropertyInit init)
Initialize after the constructor.

Specified by:
initPropertyCreated in interface InitializableProperty

initBeanCreated

public void initBeanCreated(PropertyInit init)
Initialize after the bean has been completed.

Specified by:
initBeanCreated in interface InitializableProperty

bean

public Bean bean()
Get the bean which owns this property.

Specified by:
bean in interface Property
Returns:
the owning bean

data

public PropertyData data()
Get the property data acting as the data store. This is not on the interface as all access should be through the property.

Returns:
the data storage object

toObject

public abstract java.lang.Object toObject()
Description copied from interface: Property
Get the property's value as an object. The object type will be appropriate for the type of property. The object will either be immutable or a clone of the real object.

This method has strong semantics such that where a and b are properties of the same type, it must be true that:
b.set( a.toObject() ); a.equals(b);
In other words, the object contains all the data necessary to recreate the property's value.

Specified by:
toObject in interface Property
Returns:
an Object representing the property's value
See Also:
Property.toObject()

toDataString

public java.lang.String toDataString()
See Also:
DataProperty.toDataString()

isNull

public boolean isNull()
Description copied from interface: Property
Test if the property currently set to null. This will give better performance for some properties than testing toObject() == null.

Specified by:
isNull in interface Property
Returns:
true if the property value is null
See Also:
Property.isNull()

set

public abstract void set(java.lang.Object propertyValue)
Description copied from interface: Property
Set the property's value as an object. The object type should be appropriate for the type of property. If necessary, the object will be cloned before it is stored internally. Implementations will recognise as many types of object passed in as possible. Null should always be accepted, primitive types will be reset back to zero/false.

If a String is passed in, it can be parsed in various ways. If the results of toDataString() are passed in, it must reconstitute the original value.

Specified by:
set in interface Property
Parameters:
propertyValue - an Object to set the property's value to
See Also:
Property.set(Object)

isReadOnly

public boolean isReadOnly()
Get whether the property is never modifiable.

Specified by:
isReadOnly in interface Property
Returns:
true if modifiable

setReadOnly

public void setReadOnly()
Set the property as never modifiable.

Specified by:
setReadOnly in interface Property

isModifiable

public boolean isModifiable()
Get whether the property is currently modifiable or not.

Specified by:
isModifiable in interface Property
Returns:
true if modifiable

setModifiable

public void setModifiable(boolean modifiable)
Set whether the property is currently modifiable or not.

Specified by:
setModifiable in interface Property
Parameters:
modifiable - true if object should be modifiable
Returns:
modifiable true to set the state to modifiable

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: Property
Add a listener to the list of those receiving change events. No action occurs if null is passed in.

Specified by:
addPropertyChangeListener in interface Property
Parameters:
listener - a listener to add to the list
See Also:
Property.addPropertyChangeListener(PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: Property
Remove the specified listener from the list currently receiving change events. No action occurs if the listener is not in the list.

Specified by:
removePropertyChangeListener in interface Property
Parameters:
listener - a listener to remove from the list
See Also:
Property.removePropertyChangeListener(PropertyChangeListener)

firePropertyChange

public void firePropertyChange(java.lang.Object oldValue,
                               java.lang.Object newValue)
Description copied from interface: Property
Fire a value changed event for the property. This method is rarely called by applications. Coded beans must call it in a set method.

Specified by:
firePropertyChange in interface Property
See Also:
Property.firePropertyChange(Object,Object)

firePropertyChange

protected void firePropertyChange(java.beans.PropertyChangeEvent ev)
See Also:
Property.set(Object)

getPropertyName

public java.lang.String getPropertyName()
Get the name of this property. A method such as getFoo() will lead to a name of 'foo' and so on.

Specified by:
getPropertyName in interface Property
Returns:
the name of the property

getContentName

public java.lang.String getContentName()
Get the name of this property without the 'List' or 'Link' suffixes.

Specified by:
getContentName in interface Property
Returns:
the effective name of the property

getContentType

public java.lang.Class getContentType()
Get the type of the content of the property type. This is used for Lists and Maps. Here it just returns the property type.

Specified by:
getContentType in interface Property
Returns:
the content type of the property

cloneDeep

public void cloneDeep(IdentityBasedHashMap clonedObjects,
                      Bean bean)
Clone this property avoiding recursion. The bean is supplied and should be populated with data from this property. If the property is dynamic, a property should be added to the bean.

Specified by:
cloneDeep in interface Property.Internal
Parameters:
clonedObjects - the map of original element to cloned element
bean - the bean that owns the property

createClonedProperty

protected Property createClonedProperty(Bean bean)
Create a clone of this property, ignoring the data contents

Parameters:
bean - the bean that owns the property

populateClonedProperty

protected void populateClonedProperty(IdentityBasedHashMap clonedObjects,
                                      Property property)
Populate the clone of this property with the same data as this one

Parameters:
clonedObjects - the map of original element to cloned element
property - the property to clone the data into

toString

public java.lang.String toString()
Get a debug string for the property.

Specified by:
toString in interface Property
Overrides:
toString in class java.lang.Object
Returns:
debug string, never null

hashCode

public final int hashCode()
Get the hashCode for the property in line with the spec.

Specified by:
hashCode in interface Property
Overrides:
hashCode in class java.lang.Object
Returns:
integer hashcode
See Also:
Object.hashCode()

equals

public final boolean equals(java.lang.Object object)
Equals compares the Property to another property.

Specified by:
equals in interface Property
Overrides:
equals in class java.lang.Object
Parameters:
object - the object to check against
Returns:
true if equals

equalsValue

public boolean equalsValue(java.lang.Object object)
EqualsValue compares the value of the property to another object. The input parameter is type converted to the correct type if possible. Thus NumericProperty.equalsValue will accept any Number object, a String that can be parsed into a number or another property.

Specified by:
equalsValue in interface Property
Parameters:
object - the object to check against
Returns:
true if equals

checkValueNotNull

protected void checkValueNotNull(java.lang.Object object)
Check whether the property is currently null or not, throwing the appropriate exception if not.


checkValueNotNull

protected void checkValueNotNull()
Check whether the property is currently null or not, throwing the appropriate exception if not.


checkModifiable

protected void checkModifiable()
Check whether the property is currently modifiable or not, throwing the appropriate exception if not.


checkArgumentNotNull

protected void checkArgumentNotNull(java.lang.Object object)
Check whether the argument to a property method is null or not, throwing the appropriate exception if not.


convertObject

protected java.lang.Object convertObject(java.lang.Object object)
Convert an object, typically passed in as a parameter, to the underlying type for this property.

Parameters:
object - input object
Returns:
the converted object
Throws:
ConversionPropertyException - if the conversion fails

getThis

protected Property getThis()
Get 'this'. This can be overriden to provide an alternate this object, typically for Proxy implementations. Note that this method cannot be used in a constructor.


Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.