KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > weaving > AttributeDetails


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) 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.weaving;
23
24 // J2SE imports
25

26 // ASM imports
27
import oracle.toplink.libraries.asm.Type;
28
29 import oracle.toplink.essentials.internal.descriptors.InstanceVariableAttributeAccessor;
30
31 import oracle.toplink.essentials.mappings.OneToOneMapping;
32
33 /**
34  * INTERNAL:
35  * Internal helper class that holds details of a persistent attribute.
36  * Used by {@link ClassDetails}
37  *
38  */

39
40 public class AttributeDetails {
41     
42     // the name of this attribute (obviously!)
43
protected String JavaDoc attributeName;
44
45     protected String JavaDoc referenceClass;
46
47     protected boolean weaveValueHolders = false;
48     
49     protected OneToOneMapping mapping = null;
50     
51     protected String JavaDoc getterMethodName = null;
52     protected String JavaDoc setterMethodName = null;
53     
54     // is this attribute mapped using a CollectionMapping?
55
protected boolean collectionMapping = false;
56     
57     protected boolean isMappedWithAttributeAccess = false;
58     
59     protected boolean attributeOnSuperClass = false;
60
61     public AttributeDetails(String JavaDoc attributeName) {
62         this.attributeName = attributeName;
63     }
64
65     public String JavaDoc getAttributeName() {
66         return this.attributeName;
67     }
68     
69     public OneToOneMapping getMapping(){
70         return mapping;
71     }
72
73     public String JavaDoc getGetterMethodName(){
74         return getterMethodName;
75     }
76     
77     public String JavaDoc getSetterMethodName(){
78         return setterMethodName;
79     }
80
81     public String JavaDoc getReferenceClass() {
82         return referenceClass;
83     }
84
85     public void setAttributeOnSuperClass(boolean onSuperClass){
86         attributeOnSuperClass = onSuperClass;
87     }
88
89     public boolean isAttributeOnSuperClass(){
90         return attributeOnSuperClass;
91     }
92
93     public boolean weaveValueHolders() {
94         return weaveValueHolders;
95     }
96     public void weaveVH(boolean weaveValueHolders, OneToOneMapping mapping) {
97         this.weaveValueHolders = weaveValueHolders;
98         this.mapping = mapping;
99         this.getterMethodName = mapping.getGetMethodName();
100         this.setterMethodName = mapping.getSetMethodName();
101     }
102
103     public boolean isCollectionMapping() {
104         return collectionMapping;
105     }
106     public void setCollectionMapping(boolean collectionMapping) {
107         this.collectionMapping = collectionMapping;
108     }
109     
110     public void setIsMappedWithAttributeAccess(boolean isMappedWithAttributeAccess){
111         this.isMappedWithAttributeAccess = isMappedWithAttributeAccess;
112     }
113     
114     public boolean isMappedWithAttributeAccess(){
115         return isMappedWithAttributeAccess;
116     }
117     
118     public String JavaDoc toString() {
119         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(attributeName);
120         if (referenceClass != null) {
121             sb.append("[");
122             sb.append(referenceClass);
123             sb.append("]");
124         }
125         sb.append(" weaveVH: ");
126         if (weaveValueHolders()) {
127             sb.append("true");
128         }
129         else {
130             sb.append("false");
131         }
132         sb.append(" CM: ");
133         if (isCollectionMapping()) {
134             sb.append("true");
135         }
136         else {
137             sb.append("false");
138         }
139         return sb.toString();
140     }
141
142 }
143
Popular Tags