KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > Descriptor


1 /*
2  * Copyright 2001-2004 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.commons.betwixt;
17
18 import org.apache.commons.betwixt.expression.Expression;
19 import org.apache.commons.betwixt.expression.Updater;
20
21 /** <p>Describes a content node mapping.</p>
22   * Common superclass for types of <code>Descriptor</code></p>
23   *
24   * @author Robert Burrell Donkin
25   * @since 0.5
26   */

27 public abstract class Descriptor {
28
29     /** the expression used to evaluate the text value of this node */
30     private Expression textExpression;
31     /** the updater used to update the current bean from the text value of this node */
32     private Updater updater;
33     /** The property expression to which this node refers to, or null if it is just a constant */
34     private String JavaDoc propertyName;
35     /** the property type associated with this node, if any */
36     private Class JavaDoc propertyType;
37     /** the singular property type (i.e. the type ignoring the Collection or Array */
38     private Class JavaDoc singularPropertyType;
39     /** Options set for this Descriptor */
40     private Options options = new Options();
41     
42     
43     /** Base constructor */
44     public Descriptor() {
45     }
46         
47     /**
48      * Gets the expression used to evaluate the text value of this node
49      * for a particular <code>Context</code>.
50      * @return the expression used to evaluate the text value of this node
51      */

52     public Expression getTextExpression() {
53         return textExpression;
54     }
55     
56     /**
57      * Sets the expression used to evaluate the text value of this node
58      * for a particular <code>Context</code>
59      * @param textExpression the Expression to be used to evaluate the value of this node
60      */

61     public void setTextExpression(Expression textExpression) {
62         this.textExpression = textExpression;
63     }
64     
65     /**
66      * Gets the <code>Updater</code> used to update a <code>Context</code> from the text value
67      * corresponding to this node in an xml document
68      * @return the Update that should be used to update the value of this node
69      */

70     public Updater getUpdater() {
71         return updater;
72     }
73     
74     /**
75      * Sets the <code>Updater</code> used to update a <code>Context</code> from the text value
76      * corresponding to this node in an xml document
77      * @param updater the Updater to be used to update the values of this node
78      */

79     public void setUpdater(Updater updater) {
80         this.updater = updater;
81     }
82     
83     /**
84      * Gets the type of the bean property associated with this node, if any
85      * @return the property type associated with this node, if any
86      */

87     public Class JavaDoc getPropertyType() {
88         return propertyType;
89     }
90     
91     /**
92      * Sets the type of the bean property associated with this node, if any
93      * @param propertyType the Class of the bean property
94      */

95     public void setPropertyType(Class JavaDoc propertyType) {
96         this.propertyType = propertyType;
97     }
98
99     
100     /**
101      * Gets the name of the bean property to which this node refers
102      * @return the name of the bean property to which this node refers to,
103      * or null if it is just a constant
104      */

105     public String JavaDoc getPropertyName() {
106         return propertyName;
107     }
108     
109     /**
110      * Sets the name of the bean property to which this node refers
111      * @param propertyName the name of the bean property.
112      * Or null, if this node is not mapped to to a bean property
113      */

114     public void setPropertyName(String JavaDoc propertyName) {
115         this.propertyName = propertyName;
116     }
117     
118     /**
119      * Gets the underlying type ignoring any wrapping a Collection or Array.
120      *
121      * @return if this property is a 1-N relationship then this returns the type
122      * of a single property value.
123      */

124     public Class JavaDoc getSingularPropertyType() {
125         if ( singularPropertyType == null ) {
126             return getPropertyType();
127         }
128         return singularPropertyType;
129     }
130     
131     /**
132      * Sets the underlying type ignoring any wrapping Collection or Array.
133      *
134      * @param singularPropertyType the Class of the items in the Collection or Array.
135      * If node is associated with a collective bean property, then this should not be null.
136      */

137     public void setSingularPropertyType(Class JavaDoc singularPropertyType) {
138         this.singularPropertyType = singularPropertyType;
139     }
140     
141     
142     /**
143      * Gets the options for this descriptor.
144      * Options are used to communicate non-declarative
145      * (optinal) behaviour hints.
146      * @return <code>Options</code>, not null
147      */

148     public Options getOptions() {
149         return options;
150     }
151     
152     /**
153      * Sets the options for this descriptor.
154      * Options are used to communicate non-declarative
155      * (optinal) behaviour hints.
156      * @param options
157      */

158     public void setOptions(Options options) {
159         this.options = options;
160     }
161
162 }
163
Popular Tags