1 /** 2 * Redistribution and use of this software and associated documentation 3 * ("Software"), with or without modification, are permitted provided 4 * that the following conditions are met: 5 * 6 * 1. Redistributions of source code must retain copyright 7 * statements and notices. Redistributions must also contain a 8 * copy of this document. 9 * 10 * 2. Redistributions in binary form must reproduce the 11 * above copyright notice, this list of conditions and the 12 * following disclaimer in the documentation and/or other 13 * materials provided with the distribution. 14 * 15 * 3. The name "Exolab" must not be used to endorse or promote 16 * products derived from this Software without prior written 17 * permission of Intalio, Inc. For written permission, 18 * please contact info@exolab.org. 19 * 20 * 4. Products derived from this Software may not be called "Exolab" 21 * nor may "Exolab" appear in their names without prior written 22 * permission of Intalio, Inc. Exolab is a registered 23 * trademark of Intalio, Inc. 24 * 25 * 5. Due credit should be given to the Exolab Project 26 * (http://www.exolab.org/). 27 * 28 * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS 29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 32 * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 39 * OF THE POSSIBILITY OF SUCH DAMAGE. 40 * 41 * Copyright 2003 (C) Intalio, Inc. All Rights Reserved. 42 * 43 * $Id$ 44 */ 45 46 package org.exolab.castor.mapping.loader; 47 48 import org.exolab.castor.mapping.FieldDescriptor; 49 import org.exolab.castor.mapping.FieldHandler; 50 import org.exolab.castor.mapping.ValidityException; 51 52 /** 53 * An extended version of the FieldHandler interface which is used for adding 54 * additional functionality while preserving backward compatability. 55 * 56 * @author <a href="kvisco@intalio.com">Keith Visco</a> 57 * @version $Revision$ $Date: 2005-08-03 15:11:51 -0600 (Wed, 03 Aug 58 * 2005) $ 59 * @see FieldDescriptor 60 * @see FieldHandler 61 */ 62 public abstract class FieldHandlerFriend<T> implements FieldHandler<T> { 63 64 /** 65 * Returns the FieldDescriptor for the field that this handler is responsible 66 * for, or null if no FieldDescriptor has been set. This method is useful for 67 * implementations of the {@link FieldHandler} interface that wish to obtain 68 * information about the field in order to make the FieldHandler more generic 69 * and reusable, or simply for validation purposes. 70 * 71 * @return the {@link FieldDescriptor}, or null if none exists. 72 */ 73 protected abstract FieldDescriptor getFieldDescriptor(); 74 75 /** 76 * Sets the FieldDescriptor that this FieldHander is responsibile for. By 77 * setting the FieldDescriptor, it allows the implementation of the 78 * FieldHandler methods to obtain information about the field itself. This 79 * allows a particular implementation to become more generic and reusable. 80 * 81 * @param fieldDesc 82 * the FieldDescriptor to set 83 */ 84 public abstract void setFieldDescriptor(FieldDescriptor fieldDesc); 85 86 // ---------------------------------------/ 87 // - Methods inherited from FieldHandler -/ 88 // ---------------------------------------/ 89 90 /** 91 * @deprecated No longer supported 92 */ 93 public abstract void checkValidity(Object object) throws ValidityException, IllegalStateException; 94 95 // /** 96 // * Returns the value of the field from the object. 97 // * 98 // * @param object 99 // * The object 100 // * @return The value of the field 101 // * @throws IllegalStateException 102 // * The Java object has changed and is no longer supported by this 103 // * handler, or the handler is not compatible with the Java object 104 // */ 105 // public abstract T getValue(Object object) throws IllegalStateException; 106 107 // /** 108 // * Creates a new instance of the object described by this field. 109 // * 110 // * @param parent 111 // * The object for which the field is created 112 // * @return A new instance of the field's value 113 // * @throws IllegalStateException 114 // * This field is a simple type and cannot be instantiated 115 // */ 116 // public abstract Object newInstance(Object parent) throws IllegalStateException; 117 118 // /** 119 // * Sets the value of the field to a default value. 120 // * <p> 121 // * Reference fields are set to null, primitive fields are set to their 122 // * default value, collection fields are emptied of all elements. 123 // * 124 // * @param object 125 // * The object 126 // * @throws IllegalStateException 127 // * The Java object has changed and is no longer supported by this 128 // * handler, or the handler is not compatiable with the Java object 129 // */ 130 // public abstract void resetValue(Object object) throws IllegalStateException, IllegalArgumentException; 131 // 132 // /** 133 // * Sets the value of the field on the object. 134 // * 135 // * @param object 136 // * The object 137 // * @param value 138 // * The new value 139 // * @throws IllegalStateException 140 // * The Java object has changed and is no longer supported by this 141 // * handler, or the handler is not compatiable with the Java object 142 // * @throws IllegalArgumentException 143 // * The value passed is not of a supported type 144 // */ 145 // public abstract void setValue(Object object, T value) throws IllegalStateException, 146 // IllegalArgumentException; 147 148 } 149