org.apache.cayenne.property
Class BaseClassDescriptor

java.lang.Object
  extended by org.apache.cayenne.property.BaseClassDescriptor
All Implemented Interfaces:
ClassDescriptor
Direct Known Subclasses:
EntityDescriptor

public abstract class BaseClassDescriptor
extends java.lang.Object
implements ClassDescriptor

A superclass of Cayenne ClassDescriptors. Defines all main bean descriptor parameters and operations. Subclasses would provide methods to initialize the descriptor.

Since:
1.2
Author:
Andrus Adamchik

Field Summary
protected  java.util.Map declaredProperties
           
protected  java.lang.Class objectClass
           
protected  PropertyAccessor persistenceStateProperty
           
protected  java.util.Map subclassDescriptors
           
protected  ClassDescriptor superclassDescriptor
           
protected  java.util.Map valueHolderProperties
           
 
Constructor Summary
BaseClassDescriptor(ClassDescriptor superclassDescriptor)
          Creates an uncompiled BaseClassDescriptor.
 
Method Summary
 java.lang.Object createObject()
          Creates a new instance of a class described by this object.
 Property getDeclaredProperty(java.lang.String propertyName)
          Returns a Java Bean property descriptor matching property name or null if no such property is found.
 java.lang.Class getObjectClass()
          Returns a bean class mapped by this descriptor.
 java.util.Iterator getProperties()
          Returns an Iterator over descriptor properties.
 Property getProperty(java.lang.String propertyName)
          Recursively looks up property descriptor in this class descriptor and all superclass descriptors.
 ClassDescriptor getSubclassDescriptor(java.lang.Class objectClass)
          Returns the most "specialized" descriptor for a given class.
 ClassDescriptor getSuperclassDescriptor()
          Returns a descriptor of the mapped superclass or null if the descriptor's entity sits at the top of inheritance hierarchy.
 void injectValueHolders(java.lang.Object object)
          Invokes 'prepareForAccess' of a super descriptor and then invokes 'prepareForAccess' of each declared property.
 boolean isFault(java.lang.Object object)
          Returns true if an object is not fully resolved.
 boolean isValid()
          Returns true if a descriptor is initialized and ready for operation.
 void shallowMerge(java.lang.Object from, java.lang.Object to)
          Copies object properties from one object to another.
 boolean visitProperties(PropertyVisitor visitor)
          Passes the visitor to all properties "visit" method, terminating properties walk through in case one of the properties returns false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

superclassDescriptor

protected ClassDescriptor superclassDescriptor

objectClass

protected java.lang.Class objectClass

declaredProperties

protected java.util.Map declaredProperties

valueHolderProperties

protected java.util.Map valueHolderProperties

subclassDescriptors

protected java.util.Map subclassDescriptors

persistenceStateProperty

protected PropertyAccessor persistenceStateProperty
Constructor Detail

BaseClassDescriptor

public BaseClassDescriptor(ClassDescriptor superclassDescriptor)
Creates an uncompiled BaseClassDescriptor. Subclasses may add a call to "compile" in the constructor after finishing their initialization.

Method Detail

isFault

public boolean isFault(java.lang.Object object)
Description copied from interface: ClassDescriptor
Returns true if an object is not fully resolved.

Specified by:
isFault in interface ClassDescriptor

isValid

public boolean isValid()
Returns true if a descriptor is initialized and ready for operation.


getObjectClass

public java.lang.Class getObjectClass()
Description copied from interface: ClassDescriptor
Returns a bean class mapped by this descriptor.

Specified by:
getObjectClass in interface ClassDescriptor

getSubclassDescriptor

public ClassDescriptor getSubclassDescriptor(java.lang.Class objectClass)
Description copied from interface: ClassDescriptor
Returns the most "specialized" descriptor for a given class. This method assumes that the following is true:
 this.getObjectClass().isAssignableFrom(objectClass)
 

Specified by:
getSubclassDescriptor in interface ClassDescriptor

getProperties

public java.util.Iterator getProperties()
Description copied from interface: ClassDescriptor
Returns an Iterator over descriptor properties.

Specified by:
getProperties in interface ClassDescriptor

getProperty

public Property getProperty(java.lang.String propertyName)
Recursively looks up property descriptor in this class descriptor and all superclass descriptors.

Specified by:
getProperty in interface ClassDescriptor

getDeclaredProperty

public Property getDeclaredProperty(java.lang.String propertyName)
Description copied from interface: ClassDescriptor
Returns a Java Bean property descriptor matching property name or null if no such property is found. Lookup DOES NOT including properties from the superclass decsriptors. Returned property maybe any one of simple, value holder or collection properties.

Specified by:
getDeclaredProperty in interface ClassDescriptor

getSuperclassDescriptor

public ClassDescriptor getSuperclassDescriptor()
Returns a descriptor of the mapped superclass or null if the descriptor's entity sits at the top of inheritance hierarchy.

Specified by:
getSuperclassDescriptor in interface ClassDescriptor

createObject

public java.lang.Object createObject()
Creates a new instance of a class described by this object.

Specified by:
createObject in interface ClassDescriptor

injectValueHolders

public void injectValueHolders(java.lang.Object object)
                        throws PropertyAccessException
Invokes 'prepareForAccess' of a super descriptor and then invokes 'prepareForAccess' of each declared property.

Specified by:
injectValueHolders in interface ClassDescriptor
Throws:
PropertyAccessException

shallowMerge

public void shallowMerge(java.lang.Object from,
                         java.lang.Object to)
                  throws PropertyAccessException
Copies object properties from one object to another. Invokes 'shallowCopy' of a super descriptor and then invokes 'shallowCopy' of each declared property.

Specified by:
shallowMerge in interface ClassDescriptor
Throws:
PropertyAccessException

visitProperties

public boolean visitProperties(PropertyVisitor visitor)
Description copied from interface: ClassDescriptor
Passes the visitor to all properties "visit" method, terminating properties walk through in case one of the properties returns false. Returns true if all visited properties returned true, false - if one property returned false.

Specified by:
visitProperties in interface ClassDescriptor


Copyright © 2001-2006 Apache.org All Rights Reserved.