Joda System API

org.joda.property.impl
Class AbstractProxyBean

java.lang.Object
  |
  +--org.joda.property.impl.AbstractModelElement
        |
        +--org.joda.property.impl.AbstractProxyBean
All Implemented Interfaces:
Bean, Bean.Internal, java.lang.Cloneable, InitializableBean, ModelElement, java.io.Serializable
Direct Known Subclasses:
ProxyBean

public abstract class AbstractProxyBean
extends AbstractModelElement
implements Bean, Bean.Internal, InitializableBean

Standard implementation of a Bean. This class does not implement the nice domain specific methods, but can be subclassed to do so.

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.joda.property.Bean
Bean.Internal
 
Constructor Summary
AbstractProxyBean()
          Constructor.
 
Method Summary
 java.lang.Object cloneDeep()
          Deep clone the bean.
 Bean cloneDeep(IdentityBasedHashMap clonedObjects)
          Clone this bean avoiding recursion.
 boolean equals(java.lang.Object object)
          Equals is implemented to perform a deep equality check on all properties.
 java.lang.Class getBeanType()
          Get the bean's type.
 java.lang.String getIdentifier()
          Get a unique identifier for this object
 Property getProperty(java.lang.String key)
          Get a Property object by name.
 java.util.Map getPropertyMap()
          Get the Map of Property objects.
protected  Bean getThis()
          Get 'this'.
 int hashCode()
          Get the hashCode for the bean.
 void initBeanCreated(BeanInit init)
          Initialize after the constructor
 void setIdentifier(java.lang.String id)
          Set a unique identifier for this 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.ModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 

Constructor Detail

AbstractProxyBean

public AbstractProxyBean()
Constructor.

Method Detail

initBeanCreated

public void initBeanCreated(BeanInit init)
Initialize after the constructor

Specified by:
initBeanCreated in interface InitializableBean

getBeanType

public java.lang.Class getBeanType()
Description copied from interface: Bean
Get the bean's type. This will be a Class object which implements this interface.

Specified by:
getBeanType in interface Bean
Returns:
the bean type
See Also:
Bean.getBeanType()

getThis

protected Bean 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.


getIdentifier

public java.lang.String getIdentifier()
Get a unique identifier for this object

Returns:
unique identifier

setIdentifier

public void setIdentifier(java.lang.String id)
Set a unique identifier for this object


getPropertyMap

public java.util.Map getPropertyMap()
Description copied from interface: Bean
Get the Map of Property objects. The map is modifiable, but care should be taken with this flexibility. It allows extra properties to be dynamically added to a Bean for example. However this also allows a Bean's real properties to be removed! Thus use the modifiability with care.

Specified by:
getPropertyMap in interface Bean
Returns:
the Map of Property objects, keyed by String property name
See Also:
Bean.getPropertyMap()

getProperty

public Property getProperty(java.lang.String key)
Description copied from interface: Bean
Get a Property object by name. If a property does not exist, null will be returned.

Specified by:
getProperty in interface Bean
Parameters:
key - the name of the property to obtain
Returns:
the property, or null if none found
See Also:
Bean.getProperty(String)

equals

public boolean equals(java.lang.Object object)
Equals is implemented to perform a deep equality check on all properties.

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

hashCode

public int hashCode()
Get the hashCode for the bean. Beans should not really be used as keys in HashMaps as they are mutable. (Keys should be immutable, as if the value changes, the HashMap will fail to return the value). Thus this method always returns one (zero generally refers to null).

The effect of this is inefficient HashMaps. The HashMap will fall back to using equals() when the hashCode() is the same. Thus, as long as the objects are not changed, the Map.get() should work.

Specified by:
hashCode in interface Bean
Overrides:
hashCode in class java.lang.Object
Returns:
a suitable hashcode
See Also:
Object.hashCode()

cloneDeep

public java.lang.Object cloneDeep()
Deep clone the bean.

Specified by:
cloneDeep in interface Bean
Returns:
deep clone of this bean
See Also:
Object.clone()

cloneDeep

public Bean cloneDeep(IdentityBasedHashMap clonedObjects)
Description copied from interface: Bean.Internal
Clone this bean avoiding recursion.

Specified by:
cloneDeep in interface Bean.Internal
Parameters:
clonedObjects - the map of original element to cloned element
See Also:
Bean.Internal#cloneDeep(IdentityBasedHashMap)

toString

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

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

Joda System API

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