View Javadoc

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  import org.apache.portals.graffito.jcr.persistence.objectconverter.BeanConverter;
20  import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl;
21  import org.apache.portals.graffito.jcr.reflection.ReflectionUtils;
22  
23  /***
24   * BeanDescriptor is used by the mapper to read general information on a bean field
25   *
26   * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
27   * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
28   */
29  public class BeanDescriptor {
30      private ClassDescriptor classDescriptor;
31      
32      private String fieldName;
33      private String jcrName;
34      private boolean proxy;
35      private boolean autoRetrieve = true;
36      private boolean autoUpdate = true;
37      private boolean autoInsert = true;
38      private boolean inline;
39      private String converter;
40      private BeanConverter beanConverter;
41      private String jcrNodeType;
42      private boolean jcrAutoCreated;
43      private boolean jcrMandatory;
44      private String jcrOnParentVersion;
45      private boolean jcrProtected;
46      private boolean jcrSameNameSiblings;
47  
48      /***
49       * @return Returns the fieldName.
50       */
51      public String getFieldName() {
52          return fieldName;
53      }
54  
55      /***
56       * @param fieldName The fieldName to set.
57       */
58      public void setFieldName(String fieldName) {
59          this.fieldName = fieldName;
60      }
61  
62      /***
63       * @return Returns the jcrName.
64       */
65      public String getJcrName() {
66          return jcrName;
67      }
68  
69      /***
70       * @param jcrName The jcrName to set.
71       */
72      public void setJcrName(String jcrName) {
73          this.jcrName = jcrName;
74      }
75  
76      /***
77       * @return Returns the proxy.
78       */
79      public boolean isProxy() {
80          return proxy;
81      }
82  
83      /***
84       * @param proxy The proxy to set.
85       */
86      public void setProxy(boolean proxy) {
87          this.proxy = proxy;
88      }
89         
90      
91      public boolean isAutoInsert() {
92  		return autoInsert;
93  	}
94  
95  	public void setAutoInsert(boolean autoInsert) {
96  		this.autoInsert = autoInsert;
97  	}
98  
99  	public boolean isAutoRetrieve() {
100 		return autoRetrieve;
101 	}
102 
103 	public void setAutoRetrieve(boolean autoRetrieve) {
104 		this.autoRetrieve = autoRetrieve;
105 	}
106 
107 	public boolean isAutoUpdate() {
108 		return autoUpdate;
109 	}
110 
111 	public void setAutoUpdate(boolean autoUpdate) {
112 		this.autoUpdate = autoUpdate;
113 	}
114 
115 	/***
116      * Are the current bean properties inlined in the parent
117      * 
118      * @return <tt>true</tt> if bean's properties are inlined in the parent node
119      */
120     public boolean isInline() {
121         return this.inline;
122     }
123 
124     /***
125      * Sets if the bean's properties should be inlined in the parent
126      * instead of being persisted on a subnode
127      * 
128      * @param flag <tt>true</tt> if the bean properties should be inlined
129      */
130     public void setInline(boolean flag) {
131         this.inline = flag;
132     }
133 
134     /***
135      * Get the <code>BeanConverter</code> fully qualified name or <tt>null</tt>
136      * if none specified by the bean descriptor.
137      * 
138      * @return fully qualified class name or <tt>null</tt>
139      */
140     public String getConverter() {
141         return this.converter;
142     }
143 
144     /***
145      * Sets the fully qualified name of a <code>BeanConverter</code> to be used.
146      * 
147      * @param converterClass a fully qualified class name
148      */
149     public void setConverter(String converterClass) {
150         this.converter = converterClass;
151     }
152 
153     
154     /*** Getter for property jcrNodeType.
155      *
156      * @return jcrNodeType
157      */
158     public String getJcrNodeType() {
159         return jcrNodeType;
160     }
161 
162     /*** Setter for property jcrNodeType.
163      *
164      * @param value jcrNodeType
165      */
166     public void setJcrNodeType(String value) {
167         this.jcrNodeType = value;
168     }
169 
170     /*** Getter for property jcrAutoCreated.
171      *
172      * @return jcrAutoCreated
173      */
174     public boolean isJcrAutoCreated() {
175         return jcrAutoCreated;
176     }
177 
178     /*** Setter for property jcrAutoCreated.
179      *
180      * @param value jcrAutoCreated
181      */
182     public void setJcrAutoCreated(boolean value) {
183         this.jcrAutoCreated = value;
184     }
185 
186     /*** Getter for property jcrMandatory.
187      *
188      * @return jcrMandatory
189      */
190     public boolean isJcrMandatory() {
191         return jcrMandatory;
192     }
193 
194     /*** Setter for property jcrMandatory.
195      *
196      * @param value jcrMandatory
197      */
198     public void setJcrMandatory(boolean value) {
199         this.jcrMandatory = value;
200     }
201 
202     /*** Getter for property jcrOnParentVersion.
203      *
204      * @return jcrOnParentVersion
205      */
206     public String getJcrOnParentVersion() {
207         return jcrOnParentVersion;
208     }
209 
210     /*** Setter for property jcrOnParentVersion.
211      *
212      * @param value jcrOnParentVersion
213      */
214     public void setJcrOnParentVersion(String value) {
215         this.jcrOnParentVersion = value;
216     }
217 
218     /*** Getter for property jcrProtected.
219      *
220      * @return jcrProtected
221      */
222     public boolean isJcrProtected() {
223         return jcrProtected;
224     }
225 
226     /*** Setter for property jcrProtected.
227      *
228      * @param value jcrProtected
229      */
230     public void setJcrProtected(boolean value) {
231         this.jcrProtected = value;
232     }
233 
234     /*** Getter for property jcrSameNameSiblings.
235      *
236      * @return jcrSameNameSiblings
237      */
238     public boolean isJcrSameNameSiblings() {
239         return jcrSameNameSiblings;
240     }
241 
242     /*** Setter for property jcrSameNameSiblings.
243      *
244      * @param value jcrSameNameSiblings
245      */
246     public void setJcrSameNameSiblings(boolean value) {
247         this.jcrSameNameSiblings = value;
248     }
249 
250     /***
251      * @param descriptor
252      */
253     public void setClassDescriptor(ClassDescriptor descriptor) {
254         this.classDescriptor = descriptor;
255     }
256 
257     /***
258      * @return Returns the classDescriptor.
259      */
260     public ClassDescriptor getClassDescriptor() {
261         return classDescriptor;
262     }
263     
264 	public String toString() {
265 		
266 		return "Bean Descriptor : " +  this.fieldName;
267 	}    
268 }