Joda System API

org.joda.property.impl.type
Class DefaultClassProperty

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

public class DefaultClassProperty
extends AbstractProperty
implements ClassProperty

Default implementation of a Class property.

Data is stored in the associated PropertyData object as a Class object. This is immutable so can be directly returned.

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.joda.property.Property
Property.Internal
 
Constructor Summary
DefaultClassProperty()
          Constructor
 
Method Summary
protected  java.lang.Class convertObjectToClass(java.lang.Object object)
          Convert an Object to a Class, throwing an exception if unable to convert.
 java.lang.Class get()
          Get the property's value as a Class.
protected  java.lang.Class getInternal()
          Get the property as a Class
 java.lang.Class getPropertyType()
          Get the type of the property.
 java.lang.Object newInstance()
          Create a new instance of the class.
 void set(java.lang.Object propertyValue)
          Set the property's value as an object.
protected  void setInternal(java.lang.Class newValue)
          Set the property value as a Class
 java.lang.Class toClass()
          Get the property's value as a Class.
 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, convertObject, createClonedProperty, data, equals, equalsValue, firePropertyChange, firePropertyChange, getContentName, getContentType, getPropertyName, getThis, hashCode, initBeanCreated, initPropertyCreated, 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

DefaultClassProperty

public DefaultClassProperty()
Constructor

Method Detail

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.Class getInternal()
Get the property as a Class

Returns:
the stored value

setInternal

protected void setInternal(java.lang.Class newValue)
Set the property value as a Class

Parameters:
newValue - the value to store

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()

toClass

public java.lang.Class toClass()
Description copied from interface: ClassProperty
Get the property's value as a Class.

Specified by:
toClass in interface ClassProperty
Returns:
the property value as a Class
See Also:
ClassProperty.toClass()

get

public java.lang.Class get()
Description copied from interface: ClassProperty
Get the property's value as a Class.

Specified by:
get in interface ClassProperty
Returns:
the property value as a Class
See Also:
ClassProperty.get()

convertObjectToClass

protected java.lang.Class convertObjectToClass(java.lang.Object object)
Convert an Object to a Class, throwing an exception if unable to convert.

Parameters:
object - the value to convert
Returns:
the converted boolean

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)

newInstance

public java.lang.Object newInstance()
Description copied from interface: ClassProperty
Create a new instance of the class.

Specified by:
newInstance in interface ClassProperty
Returns:
a new instance of the class
See Also:
ClassProperty.newInstance()

Joda System API

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