KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > mappings > AttributeAccessor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.mappings;
23
24 import java.io.*;
25 import oracle.toplink.essentials.exceptions.*;
26 import oracle.toplink.essentials.internal.helper.ClassConstants;
27
28 /**
29  * <p><b>Purpose</b>: This provides an abstract class for setting and retrieving
30  * the attribute value for the mapping from an object.
31  * It can be used in advanced situations if the attribute
32  * requires advanced conversion of the mapping value, or a real attribute does not exist.
33  *
34  * @author James
35  * @since OracleAS TopLink 10<i>g</i> (10.0.3)
36  */

37 public abstract class AttributeAccessor implements Cloneable JavaDoc, Serializable {
38
39     /** Stores the name of the attribute */
40     protected String JavaDoc attributeName;
41
42     /**
43      * INTERNAL:
44      * Clones itself.
45      */

46     public Object JavaDoc clone() {
47         try {
48             return super.clone();
49         } catch (CloneNotSupportedException JavaDoc e) {
50             throw new InternalError JavaDoc();
51         }
52     }
53
54     /**
55      * INTERNAL:
56      * Return the attribute name.
57      */

58     public String JavaDoc getAttributeName() {
59         return attributeName;
60     }
61
62     /**
63      * INTERNAL:
64      * Set the attribute name.
65      */

66     public void setAttributeName(String JavaDoc attributeName) {
67         this.attributeName = attributeName;
68     }
69
70     /**
71      * Return the class type of the attribute.
72      */

73     public Class JavaDoc getAttributeClass() {
74         return ClassConstants.OBJECT;
75     }
76
77     /**
78      * Allow any initialization to be performed with the descriptor class.
79      */

80     public void initializeAttributes(Class JavaDoc descriptorClass) throws DescriptorException {
81         if (getAttributeName() == null) {
82             throw DescriptorException.attributeNameNotSpecified();
83         }
84     }
85
86     /**
87      * Return the attribute value from the object.
88      */

89     public abstract Object JavaDoc getAttributeValueFromObject(Object JavaDoc object) throws DescriptorException;
90
91     /**
92      * Set the attribute value into the object.
93      */

94     public abstract void setAttributeValueInObject(Object JavaDoc object, Object JavaDoc value) throws DescriptorException;
95 }
96
Popular Tags