org.apache.ojb.broker.metadata.fieldaccess
Class PersistentFieldAutoProxyImpl

java.lang.Object
  extended byorg.apache.ojb.broker.metadata.fieldaccess.PersistentFieldAutoProxyImpl
All Implemented Interfaces:
PersistentField, java.io.Serializable

public class PersistentFieldAutoProxyImpl
extends java.lang.Object
implements PersistentField

PeristentField implementation that attempts to detect the nature of the field it is persisting.

First checks to see if it is a Field, then Property, then DynaBean

It will match in that order.

Version:
Author:
Brian McCallister
See Also:
Serialized Form

Constructor Summary
PersistentFieldAutoProxyImpl()
          Being nice to Class.newInstance() seems popular.
PersistentFieldAutoProxyImpl(java.lang.Class type, java.lang.String name)
          Constructor will examine the Class type to attempt to determine what type of attribute this is (field, property, or DynaProperty and wrap an instance of the correct PersistentField implementation for that field.
 
Method Summary
 java.lang.Object get(java.lang.Object anObject)
          Returns the value of the field represented by this PersistentField, on the specified object.
 java.lang.Class getDeclaringClass()
           
protected  java.lang.reflect.Field getFieldRecursive(java.lang.Class c, java.lang.String name)
          REFACTOR: This is cut and paste code from PersistentFieldDefaultImpl,
 java.lang.String getName()
           
 java.lang.Class getType()
           
 void set(java.lang.Object obj, java.lang.Object value)
          Sets the field represented by this PersistentField object on the specified object argument to the specified new value.
 boolean usesAccessorsAndMutators()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistentFieldAutoProxyImpl

public PersistentFieldAutoProxyImpl()
Being nice to Class.newInstance() seems popular.


PersistentFieldAutoProxyImpl

public PersistentFieldAutoProxyImpl(java.lang.Class type,
                                    java.lang.String name)
Constructor will examine the Class type to attempt to determine what type of attribute this is (field, property, or DynaProperty and wrap an instance of the correct PersistentField implementation for that field.

TODO: Improve error reporting. Really need to keep why each one failed and give it lump some to the user so that the user can figure out why the one which was supposed to work didn't

Method Detail

getFieldRecursive

protected java.lang.reflect.Field getFieldRecursive(java.lang.Class c,
                                                    java.lang.String name)
                                             throws java.lang.NoSuchFieldException
REFACTOR: This is cut and paste code from PersistentFieldDefaultImpl,

Throws:
java.lang.NoSuchFieldException - if no Field was found into the class hierarchy

getDeclaringClass

public java.lang.Class getDeclaringClass()
Specified by:
getDeclaringClass in interface PersistentField

set

public void set(java.lang.Object obj,
                java.lang.Object value)
         throws MetadataException
Description copied from interface: PersistentField
Sets the field represented by this PersistentField object on the specified object argument to the specified new value. The new value is automatically unwrapped if the underlying field has a primitive type. This implementation invokes set() on its underlying Field object if the argument is not null. OBS IllegalArgumentExceptions are wrapped as PersistenceBrokerExceptions.

Specified by:
set in interface PersistentField
Throws:
MetadataException - if there is an error setting this field value on obj
See Also:
Field

get

public java.lang.Object get(java.lang.Object anObject)
                     throws MetadataException
Description copied from interface: PersistentField
Returns the value of the field represented by this PersistentField, on the specified object. This implementation invokes get() on its underlying Field object.

Specified by:
get in interface PersistentField
Parameters:
anObject - - the object instance which we are trying to get the field value from
Throws:
MetadataException - if there is an error getting this field value from obj
See Also:
Field

usesAccessorsAndMutators

public boolean usesAccessorsAndMutators()
Specified by:
usesAccessorsAndMutators in interface PersistentField

getName

public java.lang.String getName()
Specified by:
getName in interface PersistentField

getType

public java.lang.Class getType()
Specified by:
getType in interface PersistentField


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14