Joda System API

org.joda.property.impl.link
Class DefaultLinkProperty

java.lang.Object
  |
  +--org.joda.property.impl.AbstractModelElement
        |
        +--org.joda.property.impl.AbstractProperty
              |
              +--org.joda.property.impl.link.DefaultLinkProperty
All Implemented Interfaces:
InitializableProperty, LinkingProperty, LinkProperty, ModelElement, Property, Property.Internal, java.io.Serializable

public class DefaultLinkProperty
extends AbstractProperty
implements LinkProperty

Standard link view implementation which links one Bean to another.

This view does not hold the link, it simply provides convenient methods to manipulate the link. The method node() refers to the parent bean.

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.joda.property.Property
Property.Internal
 
Constructor Summary
DefaultLinkProperty()
          Constructor.
 
Method Summary
protected  Bean createBean(java.lang.Class intface)
          Create a new child ModelProperty given an interface.
protected  Property createClonedProperty(Bean bean)
          Create a clone of this property, ignoring the data contents
 Bean getBean()
          Get the bean that this link points to, that may be null
 Bean getBean(boolean createIfNull)
          Get the Bean that is currently linked, optionally creating it.
 java.util.List getBeanList()
          Get the beans being linked to as a list.
 java.lang.String getContentName()
          Get the name of the linked bean
 java.lang.Class getContentType()
          Get the type of the linked bean
protected  Bean getInternal()
          Get the bean that this LinkProperty wraps
 java.lang.Class getPropertyType()
          Get the type that this property is.
 void initPropertyCreated(PropertyInit init)
          Initialize the link, after the constructor
protected  void populateClonedProperty(IdentityBasedHashMap clonedObjects, Property property)
          Populate the clone of this property with the same data as this one
 void set(java.lang.Object bean)
          Set the link to be the passed in bean
protected  void setInternal(Bean bean)
          Internal method used to change the bean being linked.
 Bean setNew()
          Create a new Bean of the correct type replacing the current underlying node in the node tree.
 Bean setNew(java.lang.Class type)
          Create a new Bean of a specific type replacing the the current underlying node in the node tree.
 java.lang.Object toObject()
          Get the property's value as an object.
 java.lang.String toString()
          Get a debug string representing this object.
 
Methods inherited from class org.joda.property.impl.AbstractProperty
addPropertyChangeListener, bean, checkArgumentNotNull, checkModifiable, checkValueNotNull, checkValueNotNull, cloneDeep, convertObject, data, equals, equalsValue, firePropertyChange, firePropertyChange, getPropertyName, getThis, hashCode, initBeanCreated, isModifiable, isNull, isReadOnly, removePropertyChangeListener, setModifiable, setReadOnly, toDataString
 
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
addPropertyChangeListener, bean, equals, equalsValue, firePropertyChange, getPropertyName, hashCode, isModifiable, isNull, isReadOnly, removePropertyChangeListener, setModifiable, setReadOnly
 
Methods inherited from interface org.joda.property.ModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 

Constructor Detail

DefaultLinkProperty

public DefaultLinkProperty()
Constructor.

Method Detail

initPropertyCreated

public void initPropertyCreated(PropertyInit init)
Initialize the link, after the constructor

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

getContentName

public java.lang.String getContentName()
Get the name of the linked bean

Specified by:
getContentName in interface Property
Overrides:
getContentName in class AbstractProperty
Returns:
the bean name

getContentType

public java.lang.Class getContentType()
Get the type of the linked bean

Specified by:
getContentType in interface Property
Overrides:
getContentType in class AbstractProperty
Returns:
the bean type

getBean

public Bean getBean()
Get the bean that this link points to, that may be null

Specified by:
getBean in interface LinkProperty
Returns:
the bean

getBean

public Bean getBean(boolean createIfNull)
Get the Bean that is currently linked, optionally creating it.

Specified by:
getBean in interface LinkProperty
Parameters:
createIfNull - create a new bean if one does not exist
Returns:
the linked bean

set

public void set(java.lang.Object bean)
Set the link to be the passed in bean

Specified by:
set in interface LinkProperty
Specified by:
set in class AbstractProperty
Parameters:
bean - the bean to set the link to

createBean

protected Bean createBean(java.lang.Class intface)
Create a new child ModelProperty given an interface.

Parameters:
intface - the interface to create
Returns:
the newly created ModelProperty

setNew

public Bean setNew()
Description copied from interface: LinkProperty
Create a new Bean of the correct type replacing the current underlying node in the node tree.

Specified by:
setNew in interface LinkProperty
Returns:
the object created
See Also:
LinkProperty.setNew()

setNew

public Bean setNew(java.lang.Class type)
Description copied from interface: LinkProperty
Create a new Bean of a specific type replacing the the current underlying node in the node tree. The interface must be the same or a subinterface of the type of the Bean.

Specified by:
setNew in interface LinkProperty
Parameters:
type - the interface to create a Bean for
Returns:
the object created
See Also:
LinkProperty.setNew(Class)

getInternal

protected Bean getInternal()
Get the bean that this LinkProperty wraps

Returns:
the bean

setInternal

protected void setInternal(Bean bean)
Internal method used to change the bean being linked.

Parameters:
bean - the bean to set the link to

getPropertyType

public java.lang.Class getPropertyType()
Description copied from interface: Property
Get the type that this property is. A method String getFoo() has a property type of String.class.

Specified by:
getPropertyType in interface Property
Returns:
the type of the property
See Also:
Property.getPropertyType()

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

getBeanList

public java.util.List getBeanList()
Description copied from interface: LinkingProperty
Get the beans being linked to as a list. The list will be an unmodifiable copy of the real list.

Specified by:
getBeanList in interface LinkingProperty
Returns:
the list of beans
See Also:
LinkingProperty.getBeanList()

createClonedProperty

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

Overrides:
createClonedProperty in class AbstractProperty
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

Overrides:
populateClonedProperty in class AbstractProperty
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 representing this object.

Specified by:
toString in interface Property
Overrides:
toString in class AbstractProperty
Returns:
debug string

Joda System API

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