KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > spec > ParameterSpecification


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.spec;
16
17 import java.util.Arrays JavaDoc;
18 import java.util.Collection JavaDoc;
19 import java.util.Collections JavaDoc;
20
21 import org.apache.hivemind.HiveMind;
22 import org.apache.hivemind.impl.BaseLocatable;
23 import org.apache.hivemind.util.Defense;
24 import org.apache.tapestry.TapestryUtils;
25
26 /**
27  * Defines a formal parameter to a component. A <code>IParameterSpecification</code> is contained
28  * by a {@link IComponentSpecification}.
29  * <p>
30  * TBD: Identify arrays in some way.
31  *
32  * @author Howard Lewis Ship
33  */

34
35 public class ParameterSpecification extends BaseLocatable implements IParameterSpecification
36 {
37     private boolean _required = false;
38
39     private String JavaDoc _type;
40
41     /** @since 1.0.9 */
42     private String JavaDoc _description;
43
44     /** @since 2.0.3 */
45     private String JavaDoc _propertyName;
46
47     /** @since 3.0 */
48     private String JavaDoc _defaultValue;
49
50     /** @since 4.0 */
51     private String JavaDoc _defaultBindingType;
52
53     /** @since 4.0 */
54     private boolean _cache = true;
55
56     /** @since 4.0 */
57     private Collection JavaDoc _aliasNames = Collections.EMPTY_LIST;
58
59     /** @since 4.0 */
60     private String JavaDoc _parameterName;
61
62     /** @since 4.0 */
63     private boolean _deprecated = false;
64
65     /**
66      * Returns the class name of the expected type of the parameter. The default value is
67      * <code>java.lang.Object</code> which matches anything.
68      */

69
70     public String JavaDoc getType()
71     {
72         return _type;
73     }
74
75     /**
76      * Returns true if the parameter is required by the component. The default is false, meaning the
77      * parameter is optional.
78      */

79
80     public boolean isRequired()
81     {
82         return _required;
83     }
84
85     public void setRequired(boolean value)
86     {
87         _required = value;
88     }
89
90     /**
91      * Sets the type of value expected for the parameter. This can be left blank to indicate any
92      * type.
93      */

94
95     public void setType(String JavaDoc value)
96     {
97         _type = value;
98     }
99
100     /**
101      * Returns the documentation for this parameter.
102      *
103      * @since 1.0.9
104      */

105
106     public String JavaDoc getDescription()
107     {
108         return _description;
109     }
110
111     /**
112      * Sets the documentation for this parameter.
113      *
114      * @since 1.0.9
115      */

116
117     public void setDescription(String JavaDoc description)
118     {
119         _description = description;
120     }
121
122     /**
123      * Sets the property name (of the component class) to connect the parameter to.
124      */

125
126     public void setPropertyName(String JavaDoc propertyName)
127     {
128         _propertyName = propertyName;
129     }
130
131     /**
132      * Returns the name of the JavaBeans property to connect the parameter to.
133      */

134
135     public String JavaDoc getPropertyName()
136     {
137         return _propertyName;
138     }
139
140     /**
141      * @see org.apache.tapestry.spec.IParameterSpecification#getDefaultValue()
142      */

143     public String JavaDoc getDefaultValue()
144     {
145         return _defaultValue;
146     }
147
148     /**
149      * @see org.apache.tapestry.spec.IParameterSpecification#setDefaultValue(java.lang.String)
150      */

151     public void setDefaultValue(String JavaDoc defaultValue)
152     {
153         _defaultValue = defaultValue;
154     }
155
156     /** @since 4.0 */
157     public String JavaDoc getDefaultBindingType()
158     {
159         return _defaultBindingType;
160     }
161
162     /** @since 4.0 */
163     public void setDefaultBindingType(String JavaDoc defaultBindingType)
164     {
165         _defaultBindingType = defaultBindingType;
166     }
167
168     /** @since 4.0 */
169     public boolean getCache()
170     {
171         return _cache;
172     }
173
174     /** @since 4.0 */
175     public void setCache(boolean cache)
176     {
177         _cache = cache;
178     }
179
180     /** @since 4.0 */
181     public Collection JavaDoc getAliasNames()
182     {
183         return _aliasNames;
184     }
185
186     /** @since 4.0 */
187     public String JavaDoc getParameterName()
188     {
189         return _parameterName;
190     }
191
192     /** @since 4.0 */
193     public void setAliases(String JavaDoc nameList)
194     {
195         if (HiveMind.isNonBlank(nameList))
196         {
197             String JavaDoc[] names = TapestryUtils.split(nameList);
198
199             _aliasNames = Arrays.asList(names);
200         }
201     }
202
203     /** @since 4.0 */
204     public void setParameterName(String JavaDoc name)
205     {
206         Defense.notNull(name, "name");
207
208         _parameterName = name;
209     }
210
211     /** @since 4.0 */
212     public boolean isDeprecated()
213     {
214         return _deprecated;
215     }
216
217     /** @since 4.0 */
218     public void setDeprecated(boolean deprecated)
219     {
220         _deprecated = deprecated;
221     }
222
223 }
Popular Tags