001 package org.apache.ojb.broker.metadata.fieldaccess;
002
003 /* Copyright 2002-2005 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 import java.io.Serializable;
019
020 import org.apache.ojb.broker.metadata.MetadataException;
021
022 /**
023 * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
024 * @version $Id: PersistentField.java,v 1.1 2007-08-24 22:17:35 ewestfal Exp $
025 */
026 public interface PersistentField extends Serializable
027 {
028 public Class getDeclaringClass();
029 public String getName();
030 public Class getType();
031
032 /**
033 * Sets the field represented by this PersistentField object on the specified object argument to the specified new value.
034 * The new value is automatically unwrapped if the underlying field has a primitive type.
035 * This implementation invokes set() on its underlying Field object if the argument <b>is not null</b>.
036 * OBS IllegalArgumentExceptions are wrapped as PersistenceBrokerExceptions.
037 *
038 * @param obj The target object (no proxy objects allowed).
039 * @param value The value to set.
040 * @throws MetadataException if there is an error setting this field value on obj
041 * @see java.lang.reflect.Field
042 */
043 public void set(Object obj, Object value) throws MetadataException;
044
045 /**
046 * Returns the value of the field represented by this PersistentField, on the specified object.
047 * This implementation invokes get() on its underlying Field object.
048 *
049 * @param anObject - The object instance (proxy objects are not allowed here) which we are
050 * trying to get the field value from.
051 * @throws MetadataException if there is an error getting this field value from obj
052 * @see java.lang.reflect.Field
053 */
054 public Object get(Object anObject) throws MetadataException;
055
056 public boolean usesAccessorsAndMutators();
057 }