|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
IComponentSpecification.java | - | - | - | - |
|
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.Collection;
|
|
18 |
import java.util.List;
|
|
19 |
|
|
20 |
import org.apache.hivemind.Locatable;
|
|
21 |
import org.apache.hivemind.LocationHolder;
|
|
22 |
import org.apache.hivemind.Resource;
|
|
23 |
import org.apache.tapestry.util.IPropertyHolder;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* A specification for a component, as read from an XML specification file.
|
|
27 |
* <p>
|
|
28 |
* A specification consists of
|
|
29 |
* <ul>
|
|
30 |
* <li>An implementing class
|
|
31 |
* <li>An optional template
|
|
32 |
* <li>An optional description
|
|
33 |
* <li>A set of contained components
|
|
34 |
* <li>Bindings for the properties of each contained component
|
|
35 |
* <li>A set of named assets
|
|
36 |
* <li>Definitions for helper beans
|
|
37 |
* <li>Any reserved names (used for HTML attributes)
|
|
38 |
* </ul>
|
|
39 |
* <p>
|
|
40 |
* From this information, an actual component may be instantiated and initialized. Instantiating a
|
|
41 |
* component is usually a recursive process, since to initialize a container component, it is
|
|
42 |
* necessary to instantiate and initialize its contained components as well.
|
|
43 |
*
|
|
44 |
* @see org.apache.tapestry.IComponent
|
|
45 |
* @see IContainedComponent
|
|
46 |
* @see IComponentSpecification
|
|
47 |
* @see org.apache.tapestry.engine.IPageLoader
|
|
48 |
* @author glongman@intelligentworks.com
|
|
49 |
*/
|
|
50 |
public interface IComponentSpecification extends IPropertyHolder, LocationHolder, Locatable |
|
51 |
{ |
|
52 |
/**
|
|
53 |
* @throws IllegalArgumentException
|
|
54 |
* if the name already exists.
|
|
55 |
*/
|
|
56 |
public void addAsset(String name, IAssetSpecification asset); |
|
57 |
|
|
58 |
/**
|
|
59 |
* @throws IllegalArgumentException
|
|
60 |
* if the id is already defined.
|
|
61 |
*/
|
|
62 |
public void addComponent(String id, IContainedComponent component); |
|
63 |
|
|
64 |
/**
|
|
65 |
* Adds the parameter. The name is added as a reserved name.
|
|
66 |
*
|
|
67 |
* @throws IllegalArgumentException
|
|
68 |
* if the name already exists.
|
|
69 |
*/
|
|
70 |
public void addParameter(String name, IParameterSpecification spec); |
|
71 |
|
|
72 |
/**
|
|
73 |
* Returns true if the component is allowed to wrap other elements (static HTML or other
|
|
74 |
* components). The default is true.
|
|
75 |
*
|
|
76 |
* @see #setAllowBody(boolean)
|
|
77 |
*/
|
|
78 |
public boolean getAllowBody(); |
|
79 |
|
|
80 |
/**
|
|
81 |
* Returns true if the component allows informal parameters (parameters not formally defined).
|
|
82 |
* Informal parameters are generally used to create additional HTML attributes for an HTML tag
|
|
83 |
* rendered by the component. This is often used to specify JavaScript event handlers or the
|
|
84 |
* class of the component (for Cascarding Style Sheets).
|
|
85 |
* <p>
|
|
86 |
* The default value is true.
|
|
87 |
*
|
|
88 |
* @see #setAllowInformalParameters(boolean)
|
|
89 |
*/
|
|
90 |
public boolean getAllowInformalParameters(); |
|
91 |
|
|
92 |
/**
|
|
93 |
* Returns the {@link IAssetSpecification}with the given name, or null if no such specification
|
|
94 |
* exists.
|
|
95 |
*
|
|
96 |
* @see #addAsset(String,IAssetSpecification)
|
|
97 |
*/
|
|
98 |
public IAssetSpecification getAsset(String name);
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Returns a <code>List</code> of the String names of all assets, in alphabetical order
|
|
102 |
*/
|
|
103 |
public List getAssetNames();
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Returns the specification of a contained component with the given id, or null if no such
|
|
107 |
* contained component exists.
|
|
108 |
*
|
|
109 |
* @see #addComponent(String, IContainedComponent)
|
|
110 |
*/
|
|
111 |
public IContainedComponent getComponent(String id);
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Returns the class name to be used when instantiating the component, or null if no class name
|
|
115 |
* was provided in the specification (in which case, a system of defaults will be used to
|
|
116 |
* determine the class name).
|
|
117 |
*/
|
|
118 |
|
|
119 |
public String getComponentClassName();
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Returns an <code>List</code> of the String names of the {@link IContainedComponent}s for
|
|
123 |
* this component.
|
|
124 |
*
|
|
125 |
* @see #addComponent(String, IContainedComponent)
|
|
126 |
*/
|
|
127 |
public List getComponentIds();
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Returns the specification of a parameter with the given name, or null if no such parameter
|
|
131 |
* exists.
|
|
132 |
*
|
|
133 |
* @see #addParameter(String, IParameterSpecification)
|
|
134 |
*/
|
|
135 |
public IParameterSpecification getParameter(String name);
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Returns a List of of String names of all parameters. This list is in alphabetical order.
|
|
139 |
*
|
|
140 |
* @see #addParameter(String, IParameterSpecification)
|
|
141 |
*/
|
|
142 |
public List getParameterNames();
|
|
143 |
|
|
144 |
public void setAllowBody(boolean value); |
|
145 |
|
|
146 |
public void setAllowInformalParameters(boolean value); |
|
147 |
|
|
148 |
public void setComponentClassName(String value); |
|
149 |
|
|
150 |
/**
|
|
151 |
* @since 1.0.4
|
|
152 |
* @throws IllegalArgumentException
|
|
153 |
* if the bean already has a specification.
|
|
154 |
*/
|
|
155 |
public void addBeanSpecification(String name, IBeanSpecification specification); |
|
156 |
|
|
157 |
/**
|
|
158 |
* Returns the {@link IBeanSpecification}for the given name, or null if not such specification
|
|
159 |
* exists.
|
|
160 |
*
|
|
161 |
* @since 1.0.4
|
|
162 |
*/
|
|
163 |
public IBeanSpecification getBeanSpecification(String name);
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Returns an unmodifiable collection of the names of all beans.
|
|
167 |
*/
|
|
168 |
public Collection getBeanNames();
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Adds the value as a reserved name. Reserved names are not allowed as the names of informal
|
|
172 |
* parameters. Since the comparison is caseless, the value is converted to lowercase before
|
|
173 |
* being stored.
|
|
174 |
*
|
|
175 |
* @since 1.0.5
|
|
176 |
*/
|
|
177 |
public void addReservedParameterName(String value); |
|
178 |
|
|
179 |
/**
|
|
180 |
* Returns true if the value specified is in the reserved name list. The comparison is caseless.
|
|
181 |
* All formal parameters are automatically in the reserved name list, as well as any additional
|
|
182 |
* reserved names specified in the component specification. The latter refer to HTML attributes
|
|
183 |
* generated directly by the component.
|
|
184 |
*
|
|
185 |
* @since 1.0.5
|
|
186 |
*/
|
|
187 |
public boolean isReservedParameterName(String value); |
|
188 |
|
|
189 |
/**
|
|
190 |
* Returns the documentation for this component.
|
|
191 |
*
|
|
192 |
* @since 1.0.9
|
|
193 |
*/
|
|
194 |
public String getDescription();
|
|
195 |
|
|
196 |
/**
|
|
197 |
* Sets the documentation for this component.
|
|
198 |
*
|
|
199 |
* @since 1.0.9
|
|
200 |
*/
|
|
201 |
public void setDescription(String description); |
|
202 |
|
|
203 |
/**
|
|
204 |
* Returns the XML Public Id for the specification file, or null if not applicable.
|
|
205 |
* <p>
|
|
206 |
* This method exists as a convienience for the Spindle plugin. A previous method used an
|
|
207 |
* arbitrary version string, the public id is more useful and less ambiguous.
|
|
208 |
*
|
|
209 |
* @since 2.2
|
|
210 |
*/
|
|
211 |
public String getPublicId();
|
|
212 |
|
|
213 |
/** @since 2.2 * */
|
|
214 |
public void setPublicId(String publicId); |
|
215 |
|
|
216 |
/**
|
|
217 |
* Returns true if the specification is known to be a page specification and not a component
|
|
218 |
* specification. Earlier versions of the framework did not distinguish between the two, but
|
|
219 |
* starting in 2.2, there are seperate XML entities for pages and components. Pages omit several
|
|
220 |
* attributes and entities related to parameters, as parameters only make sense for components.
|
|
221 |
*
|
|
222 |
* @since 2.2
|
|
223 |
*/
|
|
224 |
public boolean isPageSpecification(); |
|
225 |
|
|
226 |
/** @since 2.2 * */
|
|
227 |
public void setPageSpecification(boolean pageSpecification); |
|
228 |
|
|
229 |
/** @since 3.0 * */
|
|
230 |
public Resource getSpecificationLocation();
|
|
231 |
|
|
232 |
/** @since 3.0 * */
|
|
233 |
public void setSpecificationLocation(Resource specificationLocation); |
|
234 |
|
|
235 |
/**
|
|
236 |
* Adds a new property specification. The name of the property must not already be defined (and
|
|
237 |
* must not change after being added).
|
|
238 |
*
|
|
239 |
* @since 3.0
|
|
240 |
*/
|
|
241 |
public void addPropertySpecification(IPropertySpecification spec); |
|
242 |
|
|
243 |
/**
|
|
244 |
* Returns a sorted, immutable list of the names of all
|
|
245 |
* {@link org.apache.tapestry.spec.IPropertySpecification}s.
|
|
246 |
*
|
|
247 |
* @since 3.0
|
|
248 |
*/
|
|
249 |
public List getPropertySpecificationNames();
|
|
250 |
|
|
251 |
/**
|
|
252 |
* Returns the named {@link org.apache.tapestry.spec.IPropertySpecification}, or null if no
|
|
253 |
* such specification exist.
|
|
254 |
*
|
|
255 |
* @since 3.0
|
|
256 |
* @see #addPropertySpecification(IPropertySpecification)
|
|
257 |
*/
|
|
258 |
public IPropertySpecification getPropertySpecification(String name);
|
|
259 |
|
|
260 |
/**
|
|
261 |
* Adds a {@link InjectSpecification}.
|
|
262 |
*
|
|
263 |
* @since 4.0
|
|
264 |
*/
|
|
265 |
|
|
266 |
public void addInjectSpecification(InjectSpecification spec); |
|
267 |
|
|
268 |
/**
|
|
269 |
* Returns the list of {@link InjectSpecification}. Will return an empty list if no
|
|
270 |
* specifications have been added.
|
|
271 |
*
|
|
272 |
* @since 4.0
|
|
273 |
*/
|
|
274 |
|
|
275 |
public List getInjectSpecifications();
|
|
276 |
} |
|