%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor |
|
|
1 | /* |
|
2 | * Copyright 2000-2005 The Apache Software Foundation. |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | */ |
|
16 | package org.apache.portals.graffito.jcr.mapper.model; |
|
17 | ||
18 | ||
19 | /** |
|
20 | * |
|
21 | * |
|
22 | * FieldDescriptor is used by the mapper to read general information on a atomic field |
|
23 | * |
|
24 | * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a> |
|
25 | * |
|
26 | */ |
|
27 | 0 | public class FieldDescriptor { |
28 | private String fieldName; |
|
29 | private String fieldType; |
|
30 | private Class fieldTypeClass; |
|
31 | private String jcrName; |
|
32 | private String jcrType; |
|
33 | private boolean jcrAutoCreated; |
|
34 | private boolean jcrMandatory; |
|
35 | private String jcrOnParentVersion; |
|
36 | private boolean jcrProtected; |
|
37 | private boolean jcrMultiple; |
|
38 | private ClassDescriptor classDescriptor; |
|
39 | private boolean id; |
|
40 | private boolean path; |
|
41 | private boolean discriminator; |
|
42 | ||
43 | /** |
|
44 | * @return Returns the fieldName. |
|
45 | */ |
|
46 | public String getFieldName() { |
|
47 | 0 | return fieldName; |
48 | } |
|
49 | ||
50 | /** |
|
51 | * @param fieldName The fieldName to set. |
|
52 | */ |
|
53 | public void setFieldName(String fieldName) { |
|
54 | 0 | this.fieldName = fieldName; |
55 | 0 | } |
56 | ||
57 | /** |
|
58 | * @return the primitive or fully qualified class of the field |
|
59 | * or <tt>null</tt> if not specified in the mapping |
|
60 | */ |
|
61 | public String getFieldType() { |
|
62 | 0 | return this.fieldType; |
63 | } |
|
64 | ||
65 | /** |
|
66 | * Sets the type of the field. It supports primitive types, specified as |
|
67 | * int, long, etc or fully qualified class names. |
|
68 | * |
|
69 | * @param fieldType the type of the field |
|
70 | */ |
|
71 | public void setFieldType(String fieldType) { |
|
72 | 0 | this.fieldType = fieldType; |
73 | 0 | } |
74 | ||
75 | /** |
|
76 | * @return the field class of the field |
|
77 | * or <tt>null</tt> if not specified in the mapping |
|
78 | * or if the class was not found |
|
79 | */ |
|
80 | public Class getFieldTypeClass() { |
|
81 | 0 | if (this.fieldType == null) { |
82 | 0 | return null; |
83 | } |
|
84 | 0 | if (this.fieldTypeClass == null) { |
85 | 0 | this.fieldTypeClass = loadFieldTypeClass(); |
86 | } |
|
87 | ||
88 | 0 | return this.fieldTypeClass; |
89 | } |
|
90 | ||
91 | /** |
|
92 | * @return Returns the jcrName. |
|
93 | */ |
|
94 | public String getJcrName() { |
|
95 | 0 | return jcrName; |
96 | } |
|
97 | ||
98 | /** |
|
99 | * @param jcrName The jcrName to set. |
|
100 | */ |
|
101 | public void setJcrName(String jcrName) { |
|
102 | 0 | this.jcrName = jcrName; |
103 | 0 | } |
104 | ||
105 | /** |
|
106 | * |
|
107 | * @return the associated class descriptor |
|
108 | */ |
|
109 | public ClassDescriptor getClassDescriptor() { |
|
110 | 0 | return classDescriptor; |
111 | } |
|
112 | ||
113 | /** |
|
114 | * Set the associated class descriptor |
|
115 | * @param classDescriptor the class descriptor to set |
|
116 | */ |
|
117 | public void setClassDescriptor(ClassDescriptor classDescriptor) { |
|
118 | 0 | this.classDescriptor = classDescriptor; |
119 | 0 | } |
120 | ||
121 | /** |
|
122 | * @return true if the field is the class ID |
|
123 | */ |
|
124 | public boolean isId() { |
|
125 | 0 | return id; |
126 | } |
|
127 | ||
128 | /** |
|
129 | * |
|
130 | * @param id |
|
131 | */ |
|
132 | public void setId(boolean id) { |
|
133 | 0 | this.id = id; |
134 | 0 | } |
135 | ||
136 | /** |
|
137 | * @return Returns true if the field is the object JCR path. |
|
138 | */ |
|
139 | public boolean isPath() { |
|
140 | 0 | return path; |
141 | } |
|
142 | ||
143 | /** |
|
144 | * @param path The path to set. |
|
145 | */ |
|
146 | public void setPath(boolean path) { |
|
147 | 0 | this.path = path; |
148 | 0 | } |
149 | ||
150 | /** Getter for property jcrType. |
|
151 | * |
|
152 | * @return jcrType |
|
153 | */ |
|
154 | public String getJcrType() { |
|
155 | 0 | return jcrType; |
156 | } |
|
157 | ||
158 | /** Setter for property jcrType. |
|
159 | * |
|
160 | * @param value jcrType |
|
161 | */ |
|
162 | public void setJcrType(String value) { |
|
163 | 0 | this.jcrType = value; |
164 | 0 | } |
165 | ||
166 | /** Getter for propery jcrAutoCreated. |
|
167 | * |
|
168 | * @return jcrAutoCreated |
|
169 | */ |
|
170 | public boolean isJcrAutoCreated() { |
|
171 | 0 | return jcrAutoCreated; |
172 | } |
|
173 | ||
174 | /** Setter for property jcrAutoCreated. |
|
175 | * |
|
176 | * @param value jcrAutoCreated |
|
177 | */ |
|
178 | public void setJcrAutoCreated(boolean value) { |
|
179 | 0 | this.jcrAutoCreated = value; |
180 | 0 | } |
181 | ||
182 | /** Getter for property jcrMandatory. |
|
183 | * |
|
184 | * @return jcrMandatory |
|
185 | */ |
|
186 | public boolean isJcrMandatory() { |
|
187 | 0 | return jcrMandatory; |
188 | } |
|
189 | ||
190 | /** Setter for property jcrMandatory. |
|
191 | * |
|
192 | * @param value jcrMandatory |
|
193 | */ |
|
194 | public void setJcrMandatory(boolean value) { |
|
195 | 0 | this.jcrMandatory = value; |
196 | 0 | } |
197 | ||
198 | /** Getter for property jcrOnParentVersion. |
|
199 | * |
|
200 | * @return jcrOnParentVersion |
|
201 | */ |
|
202 | public String getJcrOnParentVersion() { |
|
203 | 0 | return jcrOnParentVersion; |
204 | } |
|
205 | ||
206 | /** Setter for property jcrOnParentVersion. |
|
207 | * |
|
208 | * @param value jcrOnParentVersion |
|
209 | */ |
|
210 | public void setJcrOnParentVersion(String value) { |
|
211 | 0 | this.jcrOnParentVersion = value; |
212 | 0 | } |
213 | ||
214 | /** Getter for property jcrProtected. |
|
215 | * |
|
216 | * @return jcrProtected |
|
217 | */ |
|
218 | public boolean isJcrProtected() { |
|
219 | 0 | return jcrProtected; |
220 | } |
|
221 | ||
222 | /** Setter for property jcrProtected. |
|
223 | * |
|
224 | * @param value jcrProtected |
|
225 | */ |
|
226 | public void setJcrProtected(boolean value) { |
|
227 | 0 | this.jcrProtected = value; |
228 | 0 | } |
229 | ||
230 | /** Getter for property jcrMultiple. |
|
231 | * |
|
232 | * @return jcrMultiple |
|
233 | */ |
|
234 | public boolean isJcrMultiple() { |
|
235 | 0 | return jcrMultiple; |
236 | } |
|
237 | ||
238 | /** Setter for property jcrMultiple. |
|
239 | * |
|
240 | * @param value jcrMultiple |
|
241 | */ |
|
242 | public void setJcrMultiple(boolean value) { |
|
243 | 0 | this.jcrMultiple = value; |
244 | 0 | } |
245 | ||
246 | public void setDiscriminator(boolean value) { |
|
247 | 0 | this.discriminator = value; |
248 | 0 | } |
249 | ||
250 | public boolean isDiscriminator() { |
|
251 | 0 | return this.discriminator; |
252 | } |
|
253 | ||
254 | /** |
|
255 | * Initialize the fieldTypeClass. |
|
256 | * |
|
257 | * @return the primitive class or the class accordign to fieldType |
|
258 | */ |
|
259 | private Class loadFieldTypeClass() { |
|
260 | 0 | if (this.fieldType == null) { |
261 | 0 | return null; |
262 | } |
|
263 | 0 | if ("byte".equals(this.fieldType)) { |
264 | 0 | return byte.class; |
265 | } |
|
266 | 0 | else if ("short".equals(this.fieldType)) { |
267 | 0 | return short.class; |
268 | } |
|
269 | 0 | else if ("int".equals(this.fieldType)) { |
270 | 0 | return int.class; |
271 | } |
|
272 | 0 | else if ("long".equals(this.fieldType)) { |
273 | 0 | return long.class; |
274 | } |
|
275 | 0 | else if ("float".equals(this.fieldType)) { |
276 | 0 | return float.class; |
277 | } |
|
278 | 0 | else if ("double".equals(this.fieldType)) { |
279 | 0 | return double.class; |
280 | } |
|
281 | 0 | else if ("char".equals(this.fieldType)) { |
282 | 0 | return char.class; |
283 | } |
|
284 | 0 | else if ("boolean".equals(this.fieldType)) { |
285 | 0 | return boolean.class; |
286 | } |
|
287 | else { |
|
288 | try { |
|
289 | 0 | return Class.forName(this.fieldType); |
290 | } |
|
291 | 0 | catch (ClassNotFoundException cnfe) { |
292 | ; // nothing to do; it will be dynamically determined |
|
293 | } |
|
294 | } |
|
295 | ||
296 | 0 | return null; |
297 | } |
|
298 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |