Joda System API

org.joda.property.impl.type
Class DefaultObjectProperty

java.lang.Object
  |
  +--org.joda.property.impl.AbstractModelElement
        |
        +--org.joda.property.impl.AbstractProperty
              |
              +--org.joda.property.impl.type.DefaultObjectProperty
All Implemented Interfaces:
DataProperty, InitializableProperty, ModelElement, ObjectProperty, Property, Property.Internal, java.io.Serializable

public class DefaultObjectProperty
extends AbstractProperty
implements ObjectProperty

Default implementation of a non-typed immutable property. The immutable aspect is important as it means the object doesn't have to be cloned on the way in and out.

Data is stored in the associated PropertyData object as the passed in type.

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.joda.property.Property
Property.Internal
 
Field Summary
 
Fields inherited from interface org.joda.property.type.ObjectProperty
DEFAULT_TYPE
 
Constructor Summary
DefaultObjectProperty()
          Constructor
 
Method Summary
 java.lang.Object convertObject(java.lang.Object object)
          Convert an object, typically passed in as a parameter, to the underlying type for this property.
 java.lang.Object get()
          Get the contents of the property
protected  java.lang.Object getInternal()
          Get the property as a generic object
 java.lang.Class getPropertyType()
          Get the type of the property.
 void initPropertyCreated(PropertyInit init)
          Initialisation
 void set(java.lang.Object propertyValue)
          Set the property's value as an object.
protected  void setInternal(java.lang.Object newValue)
          Set the property value as a generic object
 java.lang.Object toObject()
          Get the property's value as an object.
 
Methods inherited from class org.joda.property.impl.AbstractProperty
addPropertyChangeListener, bean, checkArgumentNotNull, checkModifiable, checkValueNotNull, checkValueNotNull, cloneDeep, createClonedProperty, data, equals, equalsValue, firePropertyChange, firePropertyChange, getContentName, getContentType, getPropertyName, getThis, hashCode, initBeanCreated, isModifiable, isNull, isReadOnly, populateClonedProperty, removePropertyChangeListener, setModifiable, setReadOnly, toDataString, toString
 
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.type.DataProperty
toDataString
 
Methods inherited from interface org.joda.property.Property
addPropertyChangeListener, bean, equals, equalsValue, firePropertyChange, getContentName, getContentType, getPropertyName, hashCode, isModifiable, isNull, isReadOnly, removePropertyChangeListener, setModifiable, setReadOnly, toString
 
Methods inherited from interface org.joda.property.ModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 

Constructor Detail

DefaultObjectProperty

public DefaultObjectProperty()
Constructor

Method Detail

initPropertyCreated

public void initPropertyCreated(PropertyInit init)
Initialisation

Specified by:
initPropertyCreated in interface InitializableProperty
Overrides:
initPropertyCreated in class AbstractProperty

getPropertyType

public java.lang.Class getPropertyType()
Get the type of the property. A method String getFoo() has a property type of String.class.

Specified by:
getPropertyType in interface Property
Returns:
the property type

getInternal

protected java.lang.Object getInternal()
Get the property as a generic object

Returns:
the stored value

setInternal

protected void setInternal(java.lang.Object newValue)
Set the property value as a generic object

Parameters:
newValue - the value to store

get

public java.lang.Object get()
Description copied from interface: ObjectProperty
Get the contents of the property

Specified by:
get in interface ObjectProperty
Returns:
property value
See Also:
ObjectProperty.get()

toObject

public 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
Specified by:
toObject in class AbstractProperty
Returns:
an Object representing the property's value
See Also:
Property#toObject()

convertObject

public java.lang.Object convertObject(java.lang.Object object)
Description copied from class: AbstractProperty
Convert an object, typically passed in as a parameter, to the underlying type for this property.

Overrides:
convertObject in class AbstractProperty
Parameters:
object - input object
Returns:
the converted object
See Also:
AbstractProperty.convertObject(Object)

set

public 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
Specified by:
set in class AbstractProperty
Parameters:
propertyValue - an Object to set the property's value to
See Also:
Property#set(Object)

Joda System API

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