|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.parse; |
|
16 |
| |
|
17 |
| import java.io.BufferedInputStream; |
|
18 |
| import java.io.IOException; |
|
19 |
| import java.io.InputStream; |
|
20 |
| import java.net.URL; |
|
21 |
| import java.util.HashMap; |
|
22 |
| import java.util.Iterator; |
|
23 |
| import java.util.Map; |
|
24 |
| |
|
25 |
| import javax.xml.parsers.SAXParser; |
|
26 |
| import javax.xml.parsers.SAXParserFactory; |
|
27 |
| |
|
28 |
| import org.apache.commons.logging.Log; |
|
29 |
| import org.apache.commons.logging.LogFactory; |
|
30 |
| import org.apache.hivemind.ClassResolver; |
|
31 |
| import org.apache.hivemind.ErrorHandler; |
|
32 |
| import org.apache.hivemind.HiveMind; |
|
33 |
| import org.apache.hivemind.Location; |
|
34 |
| import org.apache.hivemind.Resource; |
|
35 |
| import org.apache.hivemind.impl.DefaultErrorHandler; |
|
36 |
| import org.apache.hivemind.impl.LocationImpl; |
|
37 |
| import org.apache.hivemind.parse.AbstractParser; |
|
38 |
| import org.apache.tapestry.INamespace; |
|
39 |
| import org.apache.tapestry.Tapestry; |
|
40 |
| import org.apache.tapestry.bean.BindingBeanInitializer; |
|
41 |
| import org.apache.tapestry.bean.LightweightBeanInitializer; |
|
42 |
| import org.apache.tapestry.binding.BindingConstants; |
|
43 |
| import org.apache.tapestry.binding.BindingSource; |
|
44 |
| import org.apache.tapestry.coerce.ValueConverter; |
|
45 |
| import org.apache.tapestry.spec.BeanLifecycle; |
|
46 |
| import org.apache.tapestry.spec.BindingType; |
|
47 |
| import org.apache.tapestry.spec.IApplicationSpecification; |
|
48 |
| import org.apache.tapestry.spec.IAssetSpecification; |
|
49 |
| import org.apache.tapestry.spec.IBeanSpecification; |
|
50 |
| import org.apache.tapestry.spec.IBindingSpecification; |
|
51 |
| import org.apache.tapestry.spec.IComponentSpecification; |
|
52 |
| import org.apache.tapestry.spec.IContainedComponent; |
|
53 |
| import org.apache.tapestry.spec.IExtensionSpecification; |
|
54 |
| import org.apache.tapestry.spec.ILibrarySpecification; |
|
55 |
| import org.apache.tapestry.spec.IParameterSpecification; |
|
56 |
| import org.apache.tapestry.spec.IPropertySpecification; |
|
57 |
| import org.apache.tapestry.spec.InjectSpecification; |
|
58 |
| import org.apache.tapestry.spec.SpecFactory; |
|
59 |
| import org.apache.tapestry.util.IPropertyHolder; |
|
60 |
| import org.apache.tapestry.util.RegexpMatcher; |
|
61 |
| import org.apache.tapestry.util.xml.DocumentParseException; |
|
62 |
| import org.apache.tapestry.util.xml.InvalidStringException; |
|
63 |
| import org.xml.sax.InputSource; |
|
64 |
| import org.xml.sax.SAXException; |
|
65 |
| import org.xml.sax.SAXParseException; |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| public class SpecificationParser extends AbstractParser implements ISpecificationParser |
|
75 |
| { |
|
76 |
| private static final String IDENTIFIER_PATTERN = "_?[a-zA-Z]\\w*"; |
|
77 |
| |
|
78 |
| private static final String EXTENDED_IDENTIFIER_PATTERN = "_?[a-zA-Z](\\w|-)*"; |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| public static final String ASSET_NAME_PATTERN = "(\\$template)|(" |
|
88 |
| + Tapestry.SIMPLE_PROPERTY_NAME_PATTERN + ")"; |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| public static final String BEAN_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| public static final String COMPONENT_ALIAS_PATTERN = "^(" + IDENTIFIER_PATTERN + "/)*" |
|
108 |
| + IDENTIFIER_PATTERN + "$"; |
|
109 |
| |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
| |
|
116 |
| public static final String COMPONENT_ID_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; |
|
117 |
| |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
| |
|
126 |
| |
|
127 |
| public static final String COMPONENT_TYPE_PATTERN = "^(" + IDENTIFIER_PATTERN + ":)?" + "(" |
|
128 |
| + IDENTIFIER_PATTERN + "/)*" + IDENTIFIER_PATTERN + "$"; |
|
129 |
| |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
| |
|
134 |
| |
|
135 |
| private final Map CONVERSION_MAP = new HashMap(); |
|
136 |
| |
|
137 |
| |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
| public static final String EXTENDED_PROPERTY_NAME_PATTERN = "^" + EXTENDED_IDENTIFIER_PATTERN |
|
146 |
| + "(\\." + EXTENDED_IDENTIFIER_PATTERN + ")*$"; |
|
147 |
| |
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
| |
|
154 |
| |
|
155 |
| public static final String EXTENSION_NAME_PATTERN = EXTENDED_PROPERTY_NAME_PATTERN; |
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
| public static final String LIBRARY_ID_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; |
|
164 |
| |
|
165 |
| |
|
166 |
| private final Log _log; |
|
167 |
| |
|
168 |
| |
|
169 |
| private final ErrorHandler _errorHandler; |
|
170 |
| |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
| |
|
176 |
| |
|
177 |
| private boolean _DTD_4_0; |
|
178 |
| |
|
179 |
| |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
| |
|
186 |
| |
|
187 |
| |
|
188 |
| public static final String PAGE_NAME_PATTERN = "^" + IDENTIFIER_PATTERN + "(/" |
|
189 |
| + IDENTIFIER_PATTERN + ")*$"; |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
| |
|
194 |
| |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
| public static final String PARAMETER_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; |
|
199 |
| |
|
200 |
| |
|
201 |
| |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| public static final String PROPERTY_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN; |
|
208 |
| |
|
209 |
| |
|
210 |
| |
|
211 |
| |
|
212 |
| |
|
213 |
| |
|
214 |
| |
|
215 |
| |
|
216 |
| |
|
217 |
| |
|
218 |
| public static final String SERVICE_NAME_PATTERN = EXTENDED_PROPERTY_NAME_PATTERN; |
|
219 |
| |
|
220 |
| private static final int STATE_ALLOW_DESCRIPTION = 2000; |
|
221 |
| |
|
222 |
| private static final int STATE_ALLOW_PROPERTY = 2001; |
|
223 |
| |
|
224 |
| private static final int STATE_APPLICATION_SPECIFICATION_INITIAL = 1002; |
|
225 |
| |
|
226 |
| private static final int STATE_BEAN = 4; |
|
227 |
| |
|
228 |
| |
|
229 |
| |
|
230 |
| private static final int STATE_BINDING_3_0 = 7; |
|
231 |
| |
|
232 |
| |
|
233 |
| |
|
234 |
| private static final int STATE_BINDING = 100; |
|
235 |
| |
|
236 |
| private static final int STATE_COMPONENT = 6; |
|
237 |
| |
|
238 |
| private static final int STATE_COMPONENT_SPECIFICATION = 1; |
|
239 |
| |
|
240 |
| private static final int STATE_COMPONENT_SPECIFICATION_INITIAL = 1000; |
|
241 |
| |
|
242 |
| private static final int STATE_CONFIGURE = 14; |
|
243 |
| |
|
244 |
| private static final int STATE_DESCRIPTION = 2; |
|
245 |
| |
|
246 |
| private static final int STATE_EXTENSION = 13; |
|
247 |
| |
|
248 |
| private static final int STATE_LIBRARY_SPECIFICATION = 12; |
|
249 |
| |
|
250 |
| private static final int STATE_LIBRARY_SPECIFICATION_INITIAL = 1003; |
|
251 |
| |
|
252 |
| private static final int STATE_LISTENER_BINDING = 8; |
|
253 |
| |
|
254 |
| private static final int STATE_NO_CONTENT = 3000; |
|
255 |
| |
|
256 |
| private static final int STATE_PAGE_SPECIFICATION = 11; |
|
257 |
| |
|
258 |
| private static final int STATE_PAGE_SPECIFICATION_INITIAL = 1001; |
|
259 |
| |
|
260 |
| private static final int STATE_META = 3; |
|
261 |
| |
|
262 |
| private static final int STATE_PROPERTY = 10; |
|
263 |
| |
|
264 |
| private static final int STATE_SET = 5; |
|
265 |
| |
|
266 |
| |
|
267 |
| private static final int STATE_STATIC_BINDING = 9; |
|
268 |
| |
|
269 |
| |
|
270 |
| |
|
271 |
| public static final String TAPESTRY_DTD_3_0_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 3.0//EN"; |
|
272 |
| |
|
273 |
| |
|
274 |
| |
|
275 |
| public static final String TAPESTRY_DTD_4_0_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 4.0//EN"; |
|
276 |
| |
|
277 |
| |
|
278 |
| |
|
279 |
| |
|
280 |
| |
|
281 |
| private Map _attributes; |
|
282 |
| |
|
283 |
| |
|
284 |
| |
|
285 |
| |
|
286 |
| |
|
287 |
| private String _elementName; |
|
288 |
| |
|
289 |
| |
|
290 |
| |
|
291 |
| private final SpecFactory _factory; |
|
292 |
| |
|
293 |
| private RegexpMatcher _matcher = new RegexpMatcher(); |
|
294 |
| |
|
295 |
| private SAXParser _parser; |
|
296 |
| |
|
297 |
| private SAXParserFactory _parserFactory = SAXParserFactory.newInstance(); |
|
298 |
| |
|
299 |
| |
|
300 |
| |
|
301 |
| |
|
302 |
| |
|
303 |
| private final ClassResolver _resolver; |
|
304 |
| |
|
305 |
| |
|
306 |
| |
|
307 |
| private BindingSource _bindingSource; |
|
308 |
| |
|
309 |
| |
|
310 |
| |
|
311 |
| |
|
312 |
| |
|
313 |
| private Object _rootObject; |
|
314 |
| |
|
315 |
| |
|
316 |
| |
|
317 |
| private ValueConverter _valueConverter; |
|
318 |
| |
|
319 |
| |
|
320 |
| |
|
321 |
| |
|
322 |
| |
|
323 |
| |
|
324 |
| |
|
325 |
| { |
|
326 |
| |
|
327 |
309
| CONVERSION_MAP.put("true", Boolean.TRUE);
|
|
328 |
309
| CONVERSION_MAP.put("t", Boolean.TRUE);
|
|
329 |
309
| CONVERSION_MAP.put("1", Boolean.TRUE);
|
|
330 |
309
| CONVERSION_MAP.put("y", Boolean.TRUE);
|
|
331 |
309
| CONVERSION_MAP.put("yes", Boolean.TRUE);
|
|
332 |
309
| CONVERSION_MAP.put("on", Boolean.TRUE);
|
|
333 |
309
| CONVERSION_MAP.put("aye", Boolean.TRUE);
|
|
334 |
| |
|
335 |
309
| CONVERSION_MAP.put("false", Boolean.FALSE);
|
|
336 |
309
| CONVERSION_MAP.put("f", Boolean.FALSE);
|
|
337 |
309
| CONVERSION_MAP.put("0", Boolean.FALSE);
|
|
338 |
309
| CONVERSION_MAP.put("off", Boolean.FALSE);
|
|
339 |
309
| CONVERSION_MAP.put("no", Boolean.FALSE);
|
|
340 |
309
| CONVERSION_MAP.put("n", Boolean.FALSE);
|
|
341 |
309
| CONVERSION_MAP.put("nay", Boolean.FALSE);
|
|
342 |
| |
|
343 |
309
| CONVERSION_MAP.put("none", BeanLifecycle.NONE);
|
|
344 |
309
| CONVERSION_MAP.put("request", BeanLifecycle.REQUEST);
|
|
345 |
309
| CONVERSION_MAP.put("page", BeanLifecycle.PAGE);
|
|
346 |
309
| CONVERSION_MAP.put("render", BeanLifecycle.RENDER);
|
|
347 |
| |
|
348 |
309
| _parserFactory.setNamespaceAware(false);
|
|
349 |
309
| _parserFactory.setValidating(true);
|
|
350 |
| } |
|
351 |
| |
|
352 |
| |
|
353 |
| |
|
354 |
| |
|
355 |
186
| public SpecificationParser(ClassResolver resolver)
|
|
356 |
| { |
|
357 |
186
| this(resolver, new SpecFactory());
|
|
358 |
| } |
|
359 |
| |
|
360 |
| |
|
361 |
| |
|
362 |
| |
|
363 |
| |
|
364 |
| |
|
365 |
186
| public SpecificationParser(ClassResolver resolver, SpecFactory factory)
|
|
366 |
| { |
|
367 |
186
| this(new DefaultErrorHandler(), LogFactory.getLog(SpecificationParser.class), resolver,
|
|
368 |
| factory); |
|
369 |
| } |
|
370 |
| |
|
371 |
| |
|
372 |
| |
|
373 |
| |
|
374 |
309
| public SpecificationParser(ErrorHandler errorHandler, Log log, ClassResolver resolver,
|
|
375 |
| SpecFactory factory) |
|
376 |
| { |
|
377 |
309
| _errorHandler = errorHandler;
|
|
378 |
309
| _log = log;
|
|
379 |
309
| _resolver = resolver;
|
|
380 |
309
| _factory = factory;
|
|
381 |
| } |
|
382 |
| |
|
383 |
19914
| protected void begin(String elementName, Map attributes)
|
|
384 |
| { |
|
385 |
19914
| _elementName = elementName;
|
|
386 |
19914
| _attributes = attributes;
|
|
387 |
| |
|
388 |
19914
| switch (getState())
|
|
389 |
| { |
|
390 |
948
| case STATE_COMPONENT_SPECIFICATION_INITIAL:
|
|
391 |
| |
|
392 |
948
| beginComponentSpecificationInitial();
|
|
393 |
945
| break;
|
|
394 |
| |
|
395 |
297
| case STATE_PAGE_SPECIFICATION_INITIAL:
|
|
396 |
| |
|
397 |
297
| beginPageSpecificationInitial();
|
|
398 |
297
| break;
|
|
399 |
| |
|
400 |
123
| case STATE_APPLICATION_SPECIFICATION_INITIAL:
|
|
401 |
| |
|
402 |
123
| beginApplicationSpecificationInitial();
|
|
403 |
123
| break;
|
|
404 |
| |
|
405 |
192
| case STATE_LIBRARY_SPECIFICATION_INITIAL:
|
|
406 |
| |
|
407 |
192
| beginLibrarySpecificationInitial();
|
|
408 |
192
| break;
|
|
409 |
| |
|
410 |
6663
| case STATE_COMPONENT_SPECIFICATION:
|
|
411 |
| |
|
412 |
6663
| beginComponentSpecification();
|
|
413 |
6645
| break;
|
|
414 |
| |
|
415 |
531
| case STATE_PAGE_SPECIFICATION:
|
|
416 |
| |
|
417 |
531
| beginPageSpecification();
|
|
418 |
531
| break;
|
|
419 |
| |
|
420 |
2556
| case STATE_ALLOW_DESCRIPTION:
|
|
421 |
| |
|
422 |
2556
| beginAllowDescription();
|
|
423 |
2556
| break;
|
|
424 |
| |
|
425 |
9
| case STATE_ALLOW_PROPERTY:
|
|
426 |
| |
|
427 |
9
| allowMetaData();
|
|
428 |
9
| break;
|
|
429 |
| |
|
430 |
39
| case STATE_BEAN:
|
|
431 |
| |
|
432 |
39
| beginBean();
|
|
433 |
39
| break;
|
|
434 |
| |
|
435 |
984
| case STATE_COMPONENT:
|
|
436 |
| |
|
437 |
984
| beginComponent();
|
|
438 |
984
| break;
|
|
439 |
| |
|
440 |
7473
| case STATE_LIBRARY_SPECIFICATION:
|
|
441 |
| |
|
442 |
7473
| beginLibrarySpecification();
|
|
443 |
7458
| break;
|
|
444 |
| |
|
445 |
99
| case STATE_EXTENSION:
|
|
446 |
| |
|
447 |
99
| beginExtension();
|
|
448 |
99
| break;
|
|
449 |
| |
|
450 |
0
| default:
|
|
451 |
| |
|
452 |
0
| unexpectedElement(_elementName);
|
|
453 |
| } |
|
454 |
| } |
|
455 |
| |
|
456 |
| |
|
457 |
| |
|
458 |
| |
|
459 |
| |
|
460 |
| |
|
461 |
2556
| private void beginAllowDescription()
|
|
462 |
| { |
|
463 |
2556
| if (_elementName.equals("description"))
|
|
464 |
| { |
|
465 |
2556
| enterDescription();
|
|
466 |
2556
| return;
|
|
467 |
| } |
|
468 |
| |
|
469 |
0
| unexpectedElement(_elementName);
|
|
470 |
| } |
|
471 |
| |
|
472 |
| |
|
473 |
| |
|
474 |
| |
|
475 |
| |
|
476 |
| |
|
477 |
174
| private void allowMetaData()
|
|
478 |
| { |
|
479 |
174
| if (_DTD_4_0)
|
|
480 |
| { |
|
481 |
33
| if (_elementName.equals("meta"))
|
|
482 |
| { |
|
483 |
33
| enterMeta();
|
|
484 |
33
| return;
|
|
485 |
| } |
|
486 |
| } |
|
487 |
141
| else if (_elementName.equals("property"))
|
|
488 |
| { |
|
489 |
141
| enterProperty_3_0();
|
|
490 |
141
| return;
|
|
491 |
| } |
|
492 |
| |
|
493 |
0
| unexpectedElement(_elementName);
|
|
494 |
| } |
|
495 |
| |
|
496 |
123
| private void beginApplicationSpecificationInitial()
|
|
497 |
| { |
|
498 |
123
| expectElement("application");
|
|
499 |
| |
|
500 |
123
| String name = getAttribute("name");
|
|
501 |
123
| String engineClassName = getAttribute("engine-class");
|
|
502 |
| |
|
503 |
123
| IApplicationSpecification as = _factory.createApplicationSpecification();
|
|
504 |
| |
|
505 |
123
| as.setName(name);
|
|
506 |
| |
|
507 |
123
| if (HiveMind.isNonBlank(engineClassName))
|
|
508 |
15
| as.setEngineClassName(engineClassName);
|
|
509 |
| |
|
510 |
123
| _rootObject = as;
|
|
511 |
| |
|
512 |
123
| push(_elementName, as, STATE_LIBRARY_SPECIFICATION);
|
|
513 |
| } |
|
514 |
| |
|
515 |
39
| private void beginBean()
|
|
516 |
| { |
|
517 |
39
| if (_elementName.equals("set"))
|
|
518 |
| { |
|
519 |
9
| enterSet();
|
|
520 |
9
| return;
|
|
521 |
| } |
|
522 |
| |
|
523 |
30
| if (_elementName.equals("set-property"))
|
|
524 |
| { |
|
525 |
6
| enterSetProperty_3_0();
|
|
526 |
6
| return;
|
|
527 |
| } |
|
528 |
| |
|
529 |
24
| if (_elementName.equals("set-message-property"))
|
|
530 |
| { |
|
531 |
3
| enterSetMessage_3_0();
|
|
532 |
3
| return;
|
|
533 |
| } |
|
534 |
| |
|
535 |
21
| if (_elementName.equals("description"))
|
|
536 |
| { |
|
537 |
6
| enterDescription();
|
|
538 |
6
| return;
|
|
539 |
| } |
|
540 |
| |
|
541 |
15
| allowMetaData();
|
|
542 |
| } |
|
543 |
| |
|
544 |
984
| private void beginComponent()
|
|
545 |
| { |
|
546 |
| |
|
547 |
| |
|
548 |
984
| if (_elementName.equals("binding"))
|
|
549 |
| { |
|
550 |
855
| enterBinding();
|
|
551 |
855
| return;
|
|
552 |
| } |
|
553 |
| |
|
554 |
129
| if (_elementName.equals("static-binding"))
|
|
555 |
| { |
|
556 |
96
| enterStaticBinding_3_0();
|
|
557 |
96
| return;
|
|
558 |
| } |
|
559 |
| |
|
560 |
33
| if (_elementName.equals("message-binding"))
|
|
561 |
| { |
|
562 |
12
| enterMessageBinding_3_0();
|
|
563 |
12
| return;
|
|
564 |
| } |
|
565 |
| |
|
566 |
21
| if (_elementName.equals("inherited-binding"))
|
|
567 |
| { |
|
568 |
6
| enterInheritedBinding_3_0();
|
|
569 |
6
| return;
|
|
570 |
| } |
|
571 |
| |
|
572 |
15
| if (_elementName.equals("listener-binding"))
|
|
573 |
| { |
|
574 |
3
| enterListenerBinding();
|
|
575 |
3
| return;
|
|
576 |
| } |
|
577 |
| |
|
578 |
12
| allowMetaData();
|
|
579 |
| } |
|
580 |
| |
|
581 |
6663
| private void beginComponentSpecification()
|
|
582 |
| { |
|
583 |
6663
| if (_elementName.equals("reserved-parameter"))
|
|
584 |
| { |
|
585 |
324
| enterReservedParameter();
|
|
586 |
324
| return;
|
|
587 |
| } |
|
588 |
| |
|
589 |
6339
| if (_elementName.equals("parameter"))
|
|
590 |
| { |
|
591 |
3492
| enterParameter();
|
|
592 |
3489
| return;
|
|
593 |
| } |
|
594 |
| |
|
595 |
| |
|
596 |
| |
|
597 |
| |
|
598 |
2847
| beginPageSpecification();
|
|
599 |
| } |
|
600 |
| |
|
601 |
948
| private void beginComponentSpecificationInitial()
|
|
602 |
| { |
|
603 |
948
| expectElement("component-specification");
|
|
604 |
| |
|
605 |
945
| IComponentSpecification cs = _factory.createComponentSpecification();
|
|
606 |
| |
|
607 |
945
| cs.setAllowBody(getBooleanAttribute("allow-body", true));
|
|
608 |
945
| cs.setAllowInformalParameters(getBooleanAttribute("allow-informal-parameters", true));
|
|
609 |
945
| cs.setDeprecated(getBooleanAttribute("deprecated", false));
|
|
610 |
| |
|
611 |
945
| String className = getAttribute("class");
|
|
612 |
| |
|
613 |
945
| if (className != null)
|
|
614 |
843
| cs.setComponentClassName(className);
|
|
615 |
| |
|
616 |
945
| cs.setSpecificationLocation(getResource());
|
|
617 |
| |
|
618 |
945
| _rootObject = cs;
|
|
619 |
| |
|
620 |
945
| push(_elementName, cs, STATE_COMPONENT_SPECIFICATION);
|
|
621 |
| } |
|
622 |
| |
|
623 |
99
| private void beginExtension()
|
|
624 |
| { |
|
625 |
99
| if (_elementName.equals("configure"))
|
|
626 |
| { |
|
627 |
90
| enterConfigure();
|
|
628 |
90
| return;
|
|
629 |
| } |
|
630 |
| |
|
631 |
9
| allowMetaData();
|
|
632 |
| } |
|
633 |
| |
|
634 |
7473
| private void beginLibrarySpecification()
|
|
635 |
| { |
|
636 |
7473
| if (_elementName.equals("description"))
|
|
637 |
| { |
|
638 |
3
| enterDescription();
|
|
639 |
3
| return;
|
|
640 |
| } |
|
641 |
| |
|
642 |
7470
| if (_elementName.equals("page"))
|
|
643 |
| { |
|
644 |
1467
| enterPage();
|
|
645 |
1464
| return;
|
|
646 |
| } |
|
647 |
| |
|
648 |
6003
| if (_elementName.equals("component-type"))
|
|
649 |
| { |
|
650 |
5841
| enterComponentType();
|
|
651 |
5838
| return;
|
|
652 |
| } |
|
653 |
| |
|
654 |
| |
|
655 |
| |
|
656 |
162
| if (_elementName.equals("service"))
|
|
657 |
| { |
|
658 |
3
| enterService_3_0();
|
|
659 |
3
| return;
|
|
660 |
| } |
|
661 |
| |
|
662 |
159
| if (_elementName.equals("library"))
|
|
663 |
| { |
|
664 |
69
| enterLibrary();
|
|
665 |
63
| return;
|
|
666 |
| } |
|
667 |
| |
|
668 |
90
| if (_elementName.equals("extension"))
|
|
669 |
| { |
|
670 |
33
| enterExtension();
|
|
671 |
30
| return;
|
|
672 |
| } |
|
673 |
| |
|
674 |
57
| allowMetaData();
|
|
675 |
| } |
|
676 |
| |
|
677 |
192
| private void beginLibrarySpecificationInitial()
|
|
678 |
| { |
|
679 |
192
| expectElement("library-specification");
|
|
680 |
| |
|
681 |
192
| ILibrarySpecification ls = _factory.createLibrarySpecification();
|
|
682 |
| |
|
683 |
192
| _rootObject = ls;
|
|
684 |
| |
|
685 |
192
| push(_elementName, ls, STATE_LIBRARY_SPECIFICATION);
|
|
686 |
| } |
|
687 |
| |
|
688 |
3378
| private void beginPageSpecification()
|
|
689 |
| { |
|
690 |
3378
| if (_elementName.equals("component"))
|
|
691 |
| { |
|
692 |
756
| enterComponent();
|
|
693 |
744
| return;
|
|
694 |
| } |
|
695 |
| |
|
696 |
2622
| if (_elementName.equals("bean"))
|
|
697 |
| { |
|
698 |
90
| enterBean();
|
|
699 |
90
| return;
|
|
700 |
| } |
|
701 |
| |
|
702 |
| |
|
703 |
| |
|
704 |
| |
|
705 |
2532
| if (_elementName.equals("property-specification")
|
|
706 |
| || (_DTD_4_0 && _elementName.equals("property"))) |
|
707 |
| { |
|
708 |
351
| enterProperty();
|
|
709 |
351
| return;
|
|
710 |
| } |
|
711 |
| |
|
712 |
2181
| if (_elementName.equals("inject"))
|
|
713 |
| { |
|
714 |
1167
| enterInject();
|
|
715 |
1167
| return;
|
|
716 |
| } |
|
717 |
| |
|
718 |
| |
|
719 |
| |
|
720 |
1014
| if (_elementName.equals("asset"))
|
|
721 |
| { |
|
722 |
75
| enterAsset();
|
|
723 |
75
| return;
|
|
724 |
| } |
|
725 |
| |
|
726 |
| |
|
727 |
| |
|
728 |
| |
|
729 |
| |
|
730 |
939
| if (_elementName.equals("context-asset"))
|
|
731 |
| { |
|
732 |
21
| enterContextAsset_3_0();
|
|
733 |
21
| return;
|
|
734 |
| } |
|
735 |
| |
|
736 |
918
| if (_elementName.equals("private-asset"))
|
|
737 |
| { |
|
738 |
24
| enterPrivateAsset_3_0();
|
|
739 |
21
| return;
|
|
740 |
| } |
|
741 |
| |
|
742 |
894
| if (_elementName.equals("external-asset"))
|
|
743 |
| { |
|
744 |
9
| enterExternalAsset_3_0();
|
|
745 |
9
| return;
|
|
746 |
| |
|
747 |
| } |
|
748 |
| |
|
749 |
885
| if (_elementName.equals("description"))
|
|
750 |
| { |
|
751 |
813
| enterDescription();
|
|
752 |
813
| return;
|
|
753 |
| } |
|
754 |
| |
|
755 |
72
| allowMetaData();
|
|
756 |
| } |
|
757 |
| |
|
758 |
297
| private void beginPageSpecificationInitial()
|
|
759 |
| { |
|
760 |
297
| expectElement("page-specification");
|
|
761 |
| |
|
762 |
297
| IComponentSpecification cs = _factory.createComponentSpecification();
|
|
763 |
| |
|
764 |
297
| String className = getAttribute("class");
|
|
765 |
| |
|
766 |
297
| if (className != null)
|
|
767 |
204
| cs.setComponentClassName(className);
|
|
768 |
| |
|
769 |
297
| cs.setSpecificationLocation(getResource());
|
|
770 |
297
| cs.setPageSpecification(true);
|
|
771 |
| |
|
772 |
297
| _rootObject = cs;
|
|
773 |
| |
|
774 |
297
| push(_elementName, cs, STATE_PAGE_SPECIFICATION);
|
|
775 |
| } |
|
776 |
| |
|
777 |
| |
|
778 |
| |
|
779 |
| |
|
780 |
1566
| private void close(InputStream stream)
|
|
781 |
| { |
|
782 |
1566
| try
|
|
783 |
| { |
|
784 |
1566
| if (stream != null)
|
|
785 |
48
| stream.close();
|
|
786 |
| } |
|
787 |
| catch (IOException ex) |
|
788 |
| { |
|
789 |
| |
|
790 |
| } |
|
791 |
| } |
|
792 |
| |
|
793 |
9
| private void copyBindings(String sourceComponentId, IComponentSpecification cs,
|
|
794 |
| IContainedComponent target) |
|
795 |
| { |
|
796 |
9
| IContainedComponent source = cs.getComponent(sourceComponentId);
|
|
797 |
9
| if (source == null)
|
|
798 |
3
| throw new DocumentParseException(ParseMessages.unableToCopy(sourceComponentId),
|
|
799 |
| getLocation()); |
|
800 |
| |
|
801 |
6
| Iterator i = source.getBindingNames().iterator();
|
|
802 |
6
| while (i.hasNext())
|
|
803 |
| { |
|
804 |
12
| String bindingName = (String) i.next();
|
|
805 |
12
| IBindingSpecification binding = source.getBinding(bindingName);
|
|
806 |
12
| target.setBinding(bindingName, binding);
|
|
807 |
| } |
|
808 |
| |
|
809 |
6
| target.setType(source.getType());
|
|
810 |
| } |
|
811 |
| |
|
812 |
19833
| protected void end(String elementName)
|
|
813 |
| { |
|
814 |
19833
| _elementName = elementName;
|
|
815 |
| |
|
816 |
19833
| switch (getState())
|
|
817 |
| { |
|
818 |
3378
| case STATE_DESCRIPTION:
|
|
819 |
| |
|
820 |
3378
| endDescription();
|
|
821 |
3378
| break;
|
|
822 |
| |
|
823 |
174
| case STATE_META:
|
|
824 |
| |
|
825 |
174
| endProperty();
|
|
826 |
174
| break;
|
|
827 |
| |
|
828 |
15
| case STATE_SET:
|
|
829 |
| |
|
830 |
15
| endSetProperty();
|
|
831 |
15
| break;
|
|
832 |
| |
|
833 |
87
| case STATE_BINDING_3_0:
|
|
834 |
| |
|
835 |
87
| endBinding_3_0();
|
|
836 |
84
| break;
|
|
837 |
| |
|
838 |
768
| case STATE_BINDING:
|
|
839 |
| |
|
840 |
768
| endBinding();
|
|
841 |
768
| break;
|
|
842 |
| |
|
843 |
96
| case STATE_STATIC_BINDING:
|
|
844 |
| |
|
845 |
96
| endStaticBinding();
|
|
846 |
93
| break;
|
|
847 |
| |
|
848 |
351
| case STATE_PROPERTY:
|
|
849 |
| |
|
850 |
351
| endPropertySpecification();
|
|
851 |
351
| break;
|
|
852 |
| |
|
853 |
300
| case STATE_LIBRARY_SPECIFICATION:
|
|
854 |
| |
|
855 |
300
| endLibrarySpecification();
|
|
856 |
300
| break;
|
|
857 |
| |
|
858 |
90
| case STATE_CONFIGURE:
|
|
859 |
| |
|
860 |
90
| endConfigure();
|
|
861 |
90
| break;
|
|
862 |
| |
|
863 |
14574
| default:
|
|
864 |
14574
| break;
|
|
865 |
| } |
|
866 |
| |
|
867 |
| |
|
868 |
| |
|
869 |
19827
| pop();
|
|
870 |
| } |
|
871 |
| |
|
872 |
87
| private void endBinding_3_0()
|
|
873 |
| { |
|
874 |
87
| BindingSetter bs = (BindingSetter) peekObject();
|
|
875 |
| |
|
876 |
87
| String expression = getExtendedValue(bs.getValue(), "expression", true);
|
|
877 |
| |
|
878 |
84
| IBindingSpecification spec = _factory.createBindingSpecification();
|
|
879 |
| |
|
880 |
84
| spec.setType(BindingType.PREFIXED);
|
|
881 |
84
| spec.setValue(BindingConstants.OGNL_PREFIX + ":" + expression);
|
|
882 |
| |
|
883 |
84
| bs.apply(spec);
|
|
884 |
| } |
|
885 |
| |
|
886 |
90
| private void endConfigure()
|
|
887 |
| { |
|
888 |
90
| ExtensionConfigurationSetter setter = (ExtensionConfigurationSetter) peekObject();
|
|
889 |
| |
|
890 |
90
| String finalValue = getExtendedValue(setter.getValue(), "value", true);
|
|
891 |
| |
|
892 |
90
| setter.apply(finalValue);
|
|
893 |
| } |
|
894 |
| |
|
895 |
3378
| private void endDescription()
|
|
896 |
| { |
|
897 |
3378
| DescriptionSetter setter = (DescriptionSetter) peekObject();
|
|
898 |
| |
|
899 |
3378
| String description = peekContent();
|
|
900 |
| |
|
901 |
3378
| setter.apply(description);
|
|
902 |
| } |
|
903 |
| |
|
904 |
300
| private void endLibrarySpecification()
|
|
905 |
| { |
|
906 |
300
| ILibrarySpecification spec = (ILibrarySpecification) peekObject();
|
|
907 |
| |
|
908 |
300
| spec.setSpecificationLocation(getResource());
|
|
909 |
| |
|
910 |
300
| spec.instantiateImmediateExtensions();
|
|
911 |
| } |
|
912 |
| |
|
913 |
174
| private void endProperty()
|
|
914 |
| { |
|
915 |
174
| PropertyValueSetter pvs = (PropertyValueSetter) peekObject();
|
|
916 |
| |
|
917 |
174
| String finalValue = getExtendedValue(pvs.getPropertyValue(), "value", true);
|
|
918 |
| |
|
919 |
174
| pvs.applyValue(finalValue);
|
|
920 |
| } |
|
921 |
| |
|
922 |
351
| private void endPropertySpecification()
|
|
923 |
| { |
|
924 |
351
| IPropertySpecification ps = (IPropertySpecification) peekObject();
|
|
925 |
| |
|
926 |
351
| String initialValue = getExtendedValue(ps.getInitialValue(), "initial-value", false);
|
|
927 |
| |
|
928 |
| |
|
929 |
| |
|
930 |
| |
|
931 |
351
| if (initialValue != null && !_DTD_4_0)
|
|
932 |
15
| initialValue = BindingConstants.OGNL_PREFIX + ":" + initialValue;
|
|
933 |
| |
|
934 |
351
| ps.setInitialValue(initialValue);
|
|
935 |
| } |
|
936 |
| |
|
937 |
15
| private void endSetProperty()
|
|
938 |
| { |
|
939 |
15
| BeanSetPropertySetter bs = (BeanSetPropertySetter) peekObject();
|
|
940 |
| |
|
941 |
15
| String finalValue = getExtendedValue(bs.getBindingReference(), "expression", true);
|
|
942 |
| |
|
943 |
15
| bs.applyBindingReference(finalValue);
|
|
944 |
| } |
|
945 |
| |
|
946 |
96
| private void endStaticBinding()
|
|
947 |
| { |
|
948 |
96
| BindingSetter bs = (BindingSetter) peekObject();
|
|
949 |
| |
|
950 |
96
| String literalValue = getExtendedValue(bs.getValue(), "value", true);
|
|
951 |
| |
|
952 |
93
| IBindingSpecification spec = _factory.createBindingSpecification();
|
|
953 |
| |
|
954 |
93
| spec.setType(BindingType.PREFIXED);
|
|
955 |
93
| spec.setValue(BindingConstants.LITERAL_PREFIX + ":" + literalValue);
|
|
956 |
| |
|
957 |
93
| bs.apply(spec);
|
|
958 |
| } |
|
959 |
| |
|
960 |
129
| private void enterAsset(String pathAttributeName, String prefix)
|
|
961 |
| { |
|
962 |
129
| String name = getValidatedAttribute("name", ASSET_NAME_PATTERN, "invalid-asset-name");
|
|
963 |
126
| String path = getAttribute(pathAttributeName);
|
|
964 |
126
| String propertyName = getValidatedAttribute(
|
|
965 |
| "property", |
|
966 |
| PROPERTY_NAME_PATTERN, |
|
967 |
| "invalid-property-name"); |
|
968 |
| |
|
969 |
126
| IAssetSpecification ia = _factory.createAssetSpecification();
|
|
970 |
| |
|
971 |
126
| ia.setPath(prefix == null ? path : prefix + path);
|
|
972 |
126
| ia.setPropertyName(propertyName);
|
|
973 |
| |
|
974 |
126
| IComponentSpecification cs = (IComponentSpecification) peekObject();
|
|
975 |
| |
|
976 |
126
| cs.addAsset(name, ia);
|
|
977 |
| |
|
978 |
126
| push(_elementName, ia, STATE_ALLOW_PROPERTY);
|
|
979 |
| } |
|
980 |
| |
|
981 |
90
| private void enterBean()
|
|
982 |
| { |
|
983 |
90
| String name = getValidatedAttribute("name", BEAN_NAME_PATTERN, "invalid-bean-name");
|
|
984 |
| |
|
985 |
90
| String classAttribute = getAttribute("class");
|
|
986 |
| |
|
987 |
| |
|
988 |
| |
|
989 |
90
| int commax = classAttribute.indexOf(',');
|
|
990 |
| |
|
991 |
90
| String className = commax < 0 ? classAttribute : classAttribute.substring(0, commax);
|
|
992 |
| |
|
993 |
90
| BeanLifecycle lifecycle = (BeanLifecycle) getConvertedAttribute(
|
|
994 |
| "lifecycle", |
|
995 |
| BeanLifecycle.REQUEST); |
|
996 |
90
| String propertyName = getValidatedAttribute(
|
|
997 |
| "property", |
|
998 |
| PROPERTY_NAME_PATTERN, |
|
999 |
| "invalid-property-name"); |
|
1000 |
| |
|
1001 |
90
| IBeanSpecification bs = _factory.createBeanSpecification();
|
|
1002 |
| |
|
1003 |
90
| bs.setClassName(className);
|
|
1004 |
90
| bs.setLifecycle(lifecycle);
|
|
1005 |
90
| bs.setPropertyName(propertyName);
|
|
1006 |
| |
|
1007 |
90
| if (commax > 0)
|
|
1008 |
| { |
|
1009 |
3
| String initializer = classAttribute.substring(commax + 1);
|
|
1010 |
3
| bs.addInitializer(new LightweightBeanInitializer(initializer));
|
|
1011 |
| } |
|
1012 |
| |
|
1013 |
90
| IComponentSpecification cs = (IComponentSpecification) peekObject();
|
|
1014 |
| |
|
1015 |
90
| cs.addBeanSpecification(name, bs);
|
|
1016 |
| |
|
1017 |
90
| push(_elementName, bs, STATE_BEAN);
|
|
1018 |
| } |
|
1019 |
| |
|
1020 |
855
| private void enterBinding()
|
|
1021 |
| { |
|
1022 |
855
| if (!_DTD_4_0)
|
|
1023 |
| { |
|
1024 |
87
| enterBinding_3_0();
|
|
1025 |
87
| return;
|
|
1026 |
| } |
|
1027 |
| |
|
1028 |
| |
|
1029 |
| |
|
1030 |
768
| String name = getValidatedAttribute(
|
|
1031 |
| "name", |
|
1032 |
| PARAMETER_NAME_PATTERN, |
|
1033 |
| "invalid-parameter-name"); |
|
1034 |
768
| String value = getAttribute("value");
|
|
1035 |
| |
|
1036 |
768
| IContainedComponent cc = (IContainedComponent) peekObject();
|
|
1037 |
| |
|
1038 |
768
| BindingSetter bs = new BindingSetter(cc, name, value);
|
|
1039 |
| |
|
1040 |
768
| push(_elementName, bs, STATE_BINDING, false);
|
|
1041 |
| } |
|
1042 |
| |
|
1043 |
768
| private void endBinding()
|
|
1044 |
| { |
|
1045 |
768
| BindingSetter bs = (BindingSetter) peekObject();
|
|
1046 |
| |
|
1047 |
768
| String value = getExtendedValue(bs.getValue(), "value", true);
|
|
1048 |
| |
|
1049 |
768
| IBindingSpecification spec = _factory.createBindingSpecification();
|
|
1050 |
| |
|
1051 |
768
| spec.setType(BindingType.PREFIXED);
|
|
1052 |
768
| spec.setValue(value);
|
|
1053 |
| |
|
1054 |
768
| bs.apply(spec);
|
|
1055 |
| } |
|
1056 |
| |
|
1057 |
| |
|
1058 |
| |
|
1059 |
| |
|
1060 |
| |
|
1061 |
87
| private void enterBinding_3_0()
|
|
1062 |
| { |
|
1063 |
87
| String name = getAttribute("name");
|
|
1064 |
87
| String expression = getAttribute("expression");
|
|
1065 |
| |
|
1066 |
87
| IContainedComponent cc = (IContainedComponent) peekObject();
|
|
1067 |
| |
|
1068 |
87
| BindingSetter bs = new BindingSetter(cc, name, expression);
|
|
1069 |
| |
|
1070 |
87
| push(_elementName, bs, STATE_BINDING_3_0, false);
|
|
1071 |
| } |
|
1072 |
| |
|
1073 |
756
| private void enterComponent()
|
|
1074 |
| { |
|
1075 |
756
| String id = getValidatedAttribute("id", COMPONENT_ID_PATTERN, "invalid-component-id");
|
|
1076 |
| |
|
1077 |
753
| String type = getValidatedAttribute(
|
|
1078 |
| "type", |
|
1079 |
| COMPONENT_TYPE_PATTERN, |
|
1080 |
| "invalid-component-type"); |
|
1081 |
753
| String copyOf = getAttribute("copy-of");
|
|
1082 |
753
| boolean inherit = getBooleanAttribute("inherit-informal-parameters", false);
|
|
1083 |
753
| String propertyName = getValidatedAttribute(
|
|
1084 |
| "property", |
|
1085 |
| PROPERTY_NAME_PATTERN, |
|
1086 |
| "invalid-property-name"); |
|
1087 |
| |
|
1088 |
| |
|
1089 |
| |
|
1090 |
753
| boolean hasCopyOf = HiveMind.isNonBlank(copyOf);
|
|
1091 |
| |
|
1092 |
753
| if (hasCopyOf)
|
|
1093 |
| { |
|
1094 |
12
| if (HiveMind.isNonBlank(type))
|
|
1095 |
3
| throw new DocumentParseException(ParseMessages.bothTypeAndCopyOf(id), getLocation());
|
|
1096 |
| } |
|
1097 |
| else |
|
1098 |
| { |
|
1099 |
741
| if (HiveMind.isBlank(type))
|
|
1100 |
3
| throw new DocumentParseException(ParseMessages.missingTypeOrCopyOf(id),
|
|
1101 |
| getLocation()); |
|
1102 |
| } |
|
1103 |
| |
|
1104 |
747
| IContainedComponent cc = _factory.createContainedComponent();
|
|
1105 |
747
| cc.setType(type);
|
|
1106 |
747
| cc.setCopyOf(copyOf);
|
|
1107 |
747
| cc.setInheritInformalParameters(inherit);
|
|
1108 |
747
| cc.setPropertyName(propertyName);
|
|
1109 |
| |
|
1110 |
747
| IComponentSpecification cs = (IComponentSpecification) peekObject();
|
|
1111 |
| |
|
1112 |
747
| cs.addComponent(id, cc);
|
|
1113 |
| |
|
1114 |
747
| if (hasCopyOf)
|
|
1115 |
9
| copyBindings(copyOf, cs, cc);
|
|
1116 |
| |
|
1117 |
744
| push(_elementName, cc, STATE_COMPONENT);
|
|
1118 |
| } |
|
1119 |
| |
|
1120 |
5841
| private void enterComponentType()
|
|
1121 |
| { |
|
1122 |
5841
| String type = getValidatedAttribute(
|
|
1123 |
| "type", |
|
1124 |
| COMPONENT_ALIAS_PATTERN, |
|
1125 |
| "invalid-component-type"); |
|
1126 |
5838
| String path = getAttribute("specification-path");
|
|
1127 |
| |
|
1128 |
5838
| ILibrarySpecification ls = (ILibrarySpecification) peekObject();
|
|
1129 |
| |
|
1130 |
5838
| ls.setComponentSpecificationPath(type, path);
|
|
1131 |
| |
|
1132 |
5838
| push(_elementName, null, STATE_NO_CONTENT);
|
|
1133 |
| } |
|
1134 |
| |
|
1135 |
90
| private void enterConfigure()
|
|
1136 |
| { |
|
1137 |
90
| String attributeName = _DTD_4_0 ? "property" : "property-name";
|
|
1138 |
| |
|
1139 |
90
| String propertyName = getValidatedAttribute(
|
|
1140 |
| attributeName, |
|
1141 |
| PROPERTY_NAME_PATTERN, |
|
1142 |
| "invalid-property-name"); |
|
1143 |
| |
|
1144 |
90
| String value = getAttribute("value");
|
|
1145 |
| |
|
1146 |
90
| IExtensionSpecification es = (IExtensionSpecification) peekObject();
|
|
1147 |
| |
|
1148 |
90
| ExtensionConfigurationSetter setter = new ExtensionConfigurationSetter(es, propertyName,
|
|
1149 |
| value); |
|
1150 |
| |
|
1151 |
90
| push(_elementName, setter, STATE_CONFIGURE, false);
|
|
1152 |
| } |
|
1153 |
| |
|
1154 |
21
| private void enterContextAsset_3_0()
|
|
1155 |
| { |
|
1156 |
21
| enterAsset("path", "context:");
|
|
1157 |
| } |
|
1158 |
| |
|
1159 |
| |
|
1160 |
| |
|
1161 |
| |
|
1162 |
| |
|
1163 |
| |
|
1164 |
| |
|
1165 |
| |
|
1166 |
75
| private void enterAsset()
|
|
1167 |
| { |
|
1168 |
75
| enterAsset("path", null);
|
|
1169 |
| } |
|
1170 |
| |
|
1171 |
3378
| private void enterDescription()
|
|
1172 |
| { |
|
1173 |
3378
| push(_elementName, new DescriptionSetter(peekObject()), STATE_DESCRIPTION, false);
|
|
1174 |
| } |
|
1175 |
| |
|
1176 |
33
| private void enterExtension()
|
|
1177 |
| { |
|
1178 |
33
| String name = getValidatedAttribute(
|
|
1179 |
| "name", |
|
1180 |
| EXTENSION_NAME_PATTERN, |
|
1181 |
| "invalid-extension-name"); |
|
1182 |
| |
|
1183 |
30
| boolean immediate = getBooleanAttribute("immediate", false);
|
|
1184 |
30
| String className = getAttribute("class");
|
|
1185 |
| |
|
1186 |
30
| IExtensionSpecification es = _factory.createExtensionSpecification(
|
|
1187 |
| _resolver, |
|
1188 |
| _valueConverter); |
|
1189 |
| |
|
1190 |
30
| es.setClassName(className);
|
|
1191 |
30
| es.setImmediate(immediate);
|
|
1192 |
| |
|
1193 |
30
| ILibrarySpecification ls = (ILibrarySpecification) peekObject();
|
|
1194 |
| |
|
1195 |
30
| ls.addExtensionSpecification(name, es);
|
|
1196 |
| |
|
1197 |
30
| push(_elementName, es, STATE_EXTENSION);
|
|
1198 |
| } |
|
1199 |
| |
|
1200 |
9
| private void enterExternalAsset_3_0()
|
|
1201 |
| { |
|
1202 |
| |
|
1203 |
| |
|
1204 |
| |
|
1205 |
9
| enterAsset("URL", null);
|
|
1206 |
| } |
|
1207 |
| |
|
1208 |
| |
|
1209 |
| |
|
1210 |
6
| private void enterInheritedBinding_3_0()
|
|
1211 |
| { |
|
1212 |
6
| String name = getAttribute("name");
|
|
1213 |
6
| String parameterName = getAttribute("parameter-name");
|
|
1214 |
| |
|
1215 |
6
| IBindingSpecification bs = _factory.createBindingSpecification();
|
|
1216 |
6
| bs.setType(BindingType.INHERITED);
|
|
1217 |
6
| bs.setValue(parameterName);
|
|
1218 |
| |
|
1219 |
6
| IContainedComponent cc = (IContainedComponent) peekObject();
|
|
1220 |
| |
|
1221 |
6
| cc.setBinding(name, bs);
|
|
1222 |
| |
|
1223 |
6
| push(_elementName, null, STATE_NO_CONTENT);
|
|
1224 |
| } |
|
1225 |
| |
|
1226 |
69
| private void enterLibrary()
|
|
1227 |
| { |
|
1228 |
69
| String libraryId = getValidatedAttribute("id", LIBRARY_ID_PATTERN, "invalid-library-id");
|
|
1229 |
66
| String path = getAttribute("specification-path");
|
|
1230 |
| |
|
1231 |
66
| if (libraryId.equals(INamespace.FRAMEWORK_NAMESPACE)
|
|
1232 |
| || libraryId.equals(INamespace.APPLICATION_NAMESPACE)) |
|
1233 |
3
| throw new DocumentParseException(ParseMessages
|
|
1234 |
| .frameworkLibraryIdIsReserved(INamespace.FRAMEWORK_NAMESPACE), getLocation()); |
|
1235 |
| |
|
1236 |
63
| ILibrarySpecification ls = (ILibrarySpecification) peekObject();
|
|
1237 |
| |
|
1238 |
63
| ls.setLibrarySpecificationPath(libraryId, path);
|
|
1239 |
| |
|
1240 |
63
| push(_elementName, null, STATE_NO_CONTENT);
|
|
1241 |
| } |
|
1242 |
| |
|
1243 |
3
| private void enterListenerBinding()
|
|
1244 |
| { |
|
1245 |
3
| _log.warn(ParseMessages.listenerBindingUnsupported(getLocation()));
|
|
1246 |
| |
|
1247 |
3
| push(_elementName, null, STATE_LISTENER_BINDING, false);
|
|
1248 |
| } |
|
1249 |
| |
|
1250 |
12
| private void enterMessageBinding_3_0()
|
|
1251 |
| { |
|
1252 |
12
| String name = getAttribute("name");
|
|
1253 |
12
| String key = getAttribute("key");
|
|
1254 |
| |
|
1255 |
12
| IBindingSpecification bs = _factory.createBindingSpecification();
|
|
1256 |
12
| bs.setType(BindingType.PREFIXED);
|
|
1257 |
12
| bs.setValue(BindingConstants.MESSAGE_PREFIX + ":" + key);
|
|
1258 |
12
| bs.setLocation(getLocation());
|
|
1259 |
| |
|
1260 |
12
| IContainedComponent cc = (IContainedComponent) peekObject();
|
|
1261 |
| |
|
1262 |
12
| cc.setBinding(name, bs);
|
|
1263 |
| |
|
1264 |
12
| push(_elementName, null, STATE_NO_CONTENT);
|
|
1265 |
| } |
|
1266 |
| |
|
1267 |
1467
| private void enterPage()
|
|
1268 |
| { |
|
1269 |
1467
| String name = getValidatedAttribute("name", PAGE_NAME_PATTERN, "invalid-page-name");
|
|
1270 |
1464
| String path = getAttribute("specification-path");
|
|
1271 |
| |
|
1272 |
1464
| ILibrarySpecification ls = (ILibrarySpecification) peekObject();
|
|
1273 |
| |
|
1274 |
1464
| ls.setPageSpecificationPath(name, path);
|
|
1275 |
| |
|
1276 |
1464
| push(_elementName, null, STATE_NO_CONTENT);
|
|
1277 |
| } |
|
1278 |
| |
|
1279 |
3492
| private void enterParameter()
|
|
1280 |
| { |
|
1281 |
3492
| IParameterSpecification ps = _factory.createParameterSpecification();
|
|
1282 |
| |
|
1283 |
3492
| String name = getValidatedAttribute(
|
|
1284 |
| "name", |
|
1285 |
| PARAMETER_NAME_PATTERN, |
|
1286 |
| "invalid-parameter-name"); |
|
1287 |
| |
|
1288 |
3489
| String attributeName = _DTD_4_0 ? "property" : "property-name";
|
|
1289 |
| |
|
1290 |
3489
| String propertyName = getValidatedAttribute(
|
|
1291 |
| attributeName, |
|
1292 |
| PROPERTY_NAME_PATTERN, |
|
1293 |
| "invalid-property-name"); |
|
1294 |
| |
|
1295 |
3489
| if (propertyName == null)
|
|
1296 |
3219
| propertyName = name;
|
|
1297 |
| |
|
1298 |
3489
| ps.setParameterName(name);
|
|
1299 |
3489
| ps.setPropertyName(propertyName);
|
|
1300 |
| |
|
1301 |
3489
| ps.setRequired(getBooleanAttribute("required", false));
|
|
1302 |
| |
|
1303 |
| |
|
1304 |
| |
|
1305 |
| |
|
1306 |
| |
|
1307 |
3489
| String defaultValue = getAttribute("default-value");
|
|
1308 |
| |
|
1309 |
3489
| if (defaultValue != null && !_DTD_4_0)
|
|
1310 |
21
| defaultValue = BindingConstants.OGNL_PREFIX + ":" + defaultValue;
|
|
1311 |
| |
|
1312 |
3489
| ps.setDefaultValue(defaultValue);
|
|
1313 |
| |
|
1314 |
3489
| if (!_DTD_4_0)
|
|
1315 |
| { |
|
1316 |
| |
|
1317 |
| |
|
1318 |
132
| String direction = getAttribute("direction");
|
|
1319 |
132
| ps.setCache(!"auto".equals(direction));
|
|
1320 |
| } |
|
1321 |
| else |
|
1322 |
| { |
|
1323 |
3357
| boolean cache = getBooleanAttribute("cache", true);
|
|
1324 |
3357
| ps.setCache(cache);
|
|
1325 |
| } |
|
1326 |
| |
|
1327 |
| |
|
1328 |
| |
|
1329 |
3489
| String type = getAttribute("type");
|
|
1330 |
| |
|
1331 |
3489
| if (type != null)
|
|
1332 |
114
| ps.setType(type);
|
|
1333 |
| |
|
1334 |
| |
|
1335 |
| |
|
1336 |
3489
| String aliases = getAttribute("aliases");
|
|
1337 |
| |
|
1338 |
3489
| ps.setAliases(aliases);
|
|
1339 |
3489
| ps.setDeprecated(getBooleanAttribute("deprecated", false));
|
|
1340 |
| |
|
1341 |
3489
| IComponentSpecification cs = (IComponentSpecification) peekObject();
|
|
1342 |
| |
|
1343 |
3489
| cs.addParameter(ps);
|
|
1344 |
| |
|
1345 |
3489
| push(_elementName, ps, STATE_ALLOW_DESCRIPTION);
|
|
1346 |
| } |
|
1347 |
| |
|
1348 |
24
| private void enterPrivateAsset_3_0()
|
|
1349 |
| { |
|
1350 |
24
| enterAsset("resource-path", "classpath:");
|
|
1351 |
| } |
|
1352 |
| |
|
1353 |
| |
|
1354 |
33
| private void enterMeta()
|
|
1355 |
| { |
|
1356 |
33
| String key = getAttribute("key");
|
|
1357 |
33
| String value = getAttribute("value");
|
|
1358 |
| |
|
1359 |
| |
|
1360 |
| |
|
1361 |
33
| IPropertyHolder ph = (IPropertyHolder) peekObject();
|
|
1362 |
| |
|
1363 |
33
| push(_elementName, new PropertyValueSetter(ph, key, value), STATE_META, false);
|
|
1364 |
| } |
|
1365 |
| |
|
1366 |
141
| private void enterProperty_3_0()
|
|
1367 |
| { |
|
1368 |
141
| String name = getAttribute("name");
|
|
1369 |
141
| String value = getAttribute("value");
|
|
1370 |
| |
|
1371 |
| |
|
1372 |
| |
|
1373 |
141
| IPropertyHolder ph = (IPropertyHolder) peekObject();
|
|
1374 |
| |
|
1375 |
141
| push(_elementName, new PropertyValueSetter(ph, name, value), STATE_META, false);
|
|
1376 |
| } |
|
1377 |
| |
|
1378 |
| |
|
1379 |
| |
|
1380 |
| |
|
1381 |
| |
|
1382 |
351
| private void enterProperty()
|
|
1383 |
| { |
|
1384 |
351
| String name = getValidatedAttribute("name", PROPERTY_NAME_PATTERN, "invalid-property-name");
|
|
1385 |
351
| String type = getAttribute("type");
|
|
1386 |
| |
|
1387 |
351
| String persistence = null;
|
|
1388 |
| |
|
1389 |
351
| if (_DTD_4_0)
|
|
1390 |
192
| persistence = getAttribute("persist");
|
|
1391 |
| else |
|
1392 |
159
| persistence = getBooleanAttribute("persistent", false) ? "session" : null;
|
|
1393 |
| |
|
1394 |
351
| String initialValue = getAttribute("initial-value");
|
|
1395 |
| |
|
1396 |
351
| IPropertySpecification ps = _factory.createPropertySpecification();
|
|
1397 |
351
| ps.setName(name);
|
|
1398 |
| |
|
1399 |
351
| if (HiveMind.isNonBlank(type))
|
|
1400 |
150
| ps.setType(type);
|
|
1401 |
| |
|
1402 |
351
| ps.setPersistence(persistence);
|
|
1403 |
351
| ps.setInitialValue(initialValue);
|
|
1404 |
| |
|
1405 |
351
| IComponentSpecification cs = (IComponentSpecification) peekObject();
|
|
1406 |
351
| cs.addPropertySpecification(ps);
|
|
1407 |
| |
|
1408 |
351
| push(_elementName, ps, STATE_PROPERTY, false);
|
|
1409 |
| } |
|
1410 |
| |
|
1411 |
| |
|
1412 |
| |
|
1413 |
| |
|
1414 |
| |
|
1415 |
1167
| private void enterInject()
|
|
1416 |
| { |
|
1417 |
1167
| String property = getValidatedAttribute(
|
|
1418 |
| "property", |
|
1419 |
| PROPERTY_NAME_PATTERN, |
|
1420 |
| "invalid-property-name"); |
|
1421 |
1167
| String type = getAttribute("type");
|
|
1422 |
1167
| String objectReference = getAttribute("object");
|
|
1423 |
| |
|
1424 |
1167
| InjectSpecification spec = _factory.createInjectSpecification();
|
|
1425 |
| |
|
1426 |
1167
| spec.setProperty(property);
|
|
1427 |
1167
| spec.setType(type);
|
|
1428 |
1167
| spec.setObject(objectReference);
|
|
1429 |
1167
| IComponentSpecification cs = (IComponentSpecification) peekObject();
|
|
1430 |
| |
|
1431 |
1167
| cs.addInjectSpecification(spec);
|
|
1432 |
| |
|
1433 |
1167
| push(_elementName, spec, STATE_NO_CONTENT);
|
|
1434 |
| } |
|
1435 |
| |
|
1436 |
324
| private void enterReservedParameter()
|
|
1437 |
| { |
|
1438 |
324
| String name = getAttribute("name");
|
|
1439 |
324
| IComponentSpecification cs = (IComponentSpecification) peekObject();
|
|
1440 |
| |
|
1441 |
324
| cs.addReservedParameterName(name);
|
|
1442 |
| |
|
1443 |
324
| push(_elementName, null, STATE_NO_CONTENT);
|
|
1444 |
| } |
|
1445 |
| |
|
1446 |
3
| private void enterService_3_0()
|
|
1447 |
| { |
|
1448 |
3
| _errorHandler.error(_log, ParseMessages.serviceElementNotSupported(), getLocation(), null);
|
|
1449 |
| |
|
1450 |
3
| push(_elementName, null, STATE_NO_CONTENT);
|
|
1451 |
| } |
|
1452 |
| |
|
1453 |
3
| private void enterSetMessage_3_0()
|
|
1454 |
| { |
|
1455 |
3
| String name = getAttribute("name");
|
|
1456 |
3
| String key = getAttribute("key");
|
|
1457 |
| |
|
1458 |
3
| BindingBeanInitializer bi = _factory.createBindingBeanInitializer(_bindingSource);
|
|
1459 |
| |
|
1460 |
3
| bi.setPropertyName(name);
|
|
1461 |
3
| bi.setBindingReference(BindingConstants.MESSAGE_PREFIX + ":" + key);
|
|
1462 |
3
| bi.setLocation(getLocation());
|
|
1463 |
| |
|
1464 |
3
| IBeanSpecification bs = (IBeanSpecification) peekObject();
|
|
1465 |
| |
|
1466 |
3
| bs.addInitializer(bi);
|
|
1467 |
| |
|
1468 |
3
| push(_elementName, null, STATE_NO_CONTENT);
|
|
1469 |
| } |
|
1470 |
| |
|
1471 |
9
| private void enterSet()
|
|
1472 |
| { |
|
1473 |
9
| String name = getAttribute("name");
|
|
1474 |
9
| String reference = getAttribute("value");
|
|
1475 |
| |
|
1476 |
9
| BindingBeanInitializer bi = _factory.createBindingBeanInitializer(_bindingSource);
|
|
1477 |
| |
|
1478 |
9
| bi.setPropertyName(name);
|
|
1479 |
| |
|
1480 |
9
| IBeanSpecification bs = (IBeanSpecification) peekObject();
|
|
1481 |
| |
|
1482 |
9
| push(_elementName, new BeanSetPropertySetter(bs, bi, null, reference), STATE_SET, false);
|
|
1483 |
| } |
|
1484 |
| |
|
1485 |
6
| private void enterSetProperty_3_0()
|
|
1486 |
| { |
|
1487 |
6
| String name = getAttribute("name");
|
|
1488 |
6
| String expression = getAttribute("expression");
|
|
1489 |
| |
|
1490 |
6
| BindingBeanInitializer bi = _factory.createBindingBeanInitializer(_bindingSource);
|
|
1491 |
| |
|
1492 |
6
| bi.setPropertyName(name);
|
|
1493 |
| |
|
1494 |
6
| IBeanSpecification bs = (IBeanSpecification) peekObject();
|
|
1495 |
| |
|
1496 |
6
| push(_elementName, new BeanSetPropertySetter(bs, bi, BindingConstants.OGNL_PREFIX + ":",
|
|
1497 |
| expression), STATE_SET, false); |
|
1498 |
| } |
|
1499 |
| |
|
1500 |
96
| private void enterStaticBinding_3_0()
|
|
1501 |
| { |
|
1502 |
96
| String name = getAttribute("name");
|
|
1503 |
96
| String expression = getAttribute("value");
|
|
1504 |
| |
|
1505 |
96
| IContainedComponent cc = (IContainedComponent) peekObject();
|
|
1506 |
| |
|
1507 |
96
| BindingSetter bs = new BindingSetter(cc, name, expression);
|
|
1508 |
| |
|
1509 |
96
| push(_elementName, bs, STATE_STATIC_BINDING, false);
|
|
1510 |
| } |
|
1511 |
| |
|
1512 |
1560
| private void expectElement(String elementName)
|
|
1513 |
| { |
|
1514 |
1560
| if (_elementName.equals(elementName))
|
|
1515 |
1557
| return;
|
|
1516 |
| |
|
1517 |
3
| throw new DocumentParseException(ParseMessages.incorrectDocumentType(
|
|
1518 |
| _elementName, |
|
1519 |
| elementName), getLocation(), null); |
|
1520 |
| |
|
1521 |
| } |
|
1522 |
| |
|
1523 |
59316
| private String getAttribute(String name)
|
|
1524 |
| { |
|
1525 |
59316
| return (String) _attributes.get(name);
|
|
1526 |
| } |
|
1527 |
| |
|
1528 |
14112
| private boolean getBooleanAttribute(String name, boolean defaultValue)
|
|
1529 |
| { |
|
1530 |
14112
| String value = getAttribute(name);
|
|
1531 |
| |
|
1532 |
14112
| if (value == null)
|
|
1533 |
255
| return defaultValue;
|
|
1534 |
| |
|
1535 |
13857
| Boolean b = (Boolean) CONVERSION_MAP.get(value);
|
|
1536 |
| |
|
1537 |
13857
| return b.booleanValue();
|
|
1538 |
| } |
|
1539 |
| |
|
1540 |
90
| private Object getConvertedAttribute(String name, Object defaultValue)
|
|
1541 |
| { |
|
1542 |
90
| String key = getAttribute(name);
|
|
1543 |
| |
|
1544 |
90
| if (key == null)
|
|
1545 |
0
| return defaultValue;
|
|
1546 |
| |
|
1547 |
90
| return CONVERSION_MAP.get(key);
|
|
1548 |
| } |
|
1549 |
| |
|
1550 |
1560
| private InputSource getDTDInputSource(String name)
|
|
1551 |
| { |
|
1552 |
1560
| InputStream stream = getClass().getResourceAsStream(name);
|
|
1553 |
| |
|
1554 |
1560
| return new InputSource(stream);
|
|
1555 |
| } |
|
1556 |
| |
|
1557 |
1581
| private String getExtendedValue(String attributeValue, String attributeName, boolean required)
|
|
1558 |
| { |
|
1559 |
1581
| String contentValue = peekContent();
|
|
1560 |
| |
|
1561 |
1581
| boolean asAttribute = HiveMind.isNonBlank(attributeValue);
|
|
1562 |
1581
| boolean asContent = HiveMind.isNonBlank(contentValue);
|
|
1563 |
| |
|
1564 |
1581
| if (asAttribute && asContent)
|
|
1565 |
| { |
|
1566 |
3
| throw new DocumentParseException(ParseMessages.noAttributeAndBody(
|
|
1567 |
| attributeName, |
|
1568 |
| _elementName), getLocation(), null); |
|
1569 |
| } |
|
1570 |
| |
|
1571 |
1578
| if (required && !(asAttribute || asContent))
|
|
1572 |
| { |
|
1573 |
3
| throw new DocumentParseException(ParseMessages.requiredExtendedAttribute(
|
|
1574 |
| _elementName, |
|
1575 |
| attributeName), getLocation(), null); |
|
1576 |
| } |
|
1577 |
| |
|
1578 |
1575
| if (asAttribute)
|
|
1579 |
1071
| return attributeValue;
|
|
1580 |
| |
|
1581 |
504
| return contentValue;
|
|
1582 |
| } |
|
1583 |
| |
|
1584 |
19464
| private String getValidatedAttribute(String name, String pattern, String errorKey)
|
|
1585 |
| { |
|
1586 |
19464
| String value = getAttribute(name);
|
|
1587 |
| |
|
1588 |
19464
| if (value == null)
|
|
1589 |
4179
| return null;
|
|
1590 |
| |
|
1591 |
15285
| if (_matcher.matches(pattern, value))
|
|
1592 |
15264
| return value;
|
|
1593 |
| |
|
1594 |
21
| throw new InvalidStringException(ParseMessages.invalidAttribute(errorKey, value), value,
|
|
1595 |
| getLocation()); |
|
1596 |
| } |
|
1597 |
| |
|
1598 |
1566
| protected void initializeParser(Resource resource, int startState)
|
|
1599 |
| { |
|
1600 |
1566
| super.initializeParser(resource, startState);
|
|
1601 |
| |
|
1602 |
1566
| _rootObject = null;
|
|
1603 |
1566
| _attributes = new HashMap();
|
|
1604 |
| } |
|
1605 |
| |
|
1606 |
129
| public IApplicationSpecification parseApplicationSpecification(Resource resource)
|
|
1607 |
| { |
|
1608 |
129
| initializeParser(resource, STATE_APPLICATION_SPECIFICATION_INITIAL);
|
|
1609 |
| |
|
1610 |
129
| try
|
|
1611 |
| { |
|
1612 |
129
| parseDocument();
|
|
1613 |
| |
|
1614 |
114
| return (IApplicationSpecification) _rootObject;
|
|
1615 |
| } |
|
1616 |
| finally |
|
1617 |
| { |
|
1618 |
129
| resetParser();
|
|
1619 |
| } |
|
1620 |
| } |
|
1621 |
| |
|
1622 |
948
| public IComponentSpecification parseComponentSpecification(Resource resource)
|
|
1623 |
| { |
|
1624 |
948
| initializeParser(resource, STATE_COMPONENT_SPECIFICATION_INITIAL);
|
|
1625 |
| |
|
1626 |
948
| try
|
|
1627 |
| { |
|
1628 |
948
| parseDocument();
|
|
1629 |
| |
|
1630 |
927
| return (IComponentSpecification) _rootObject;
|
|
1631 |
| } |
|
1632 |
| finally |
|
1633 |
| { |
|
1634 |
948
| resetParser();
|
|
1635 |
| } |
|
1636 |
| } |
|
1637 |
| |
|
1638 |
1566
| private void parseDocument()
|
|
1639 |
| { |
|
1640 |
1566
| InputStream stream = null;
|
|
1641 |
| |
|
1642 |
1566
| Resource resource = getResource();
|
|
1643 |
| |
|
1644 |
1566
| boolean success = false;
|
|
1645 |
| |
|
1646 |
1566
| try
|
|
1647 |
| { |
|
1648 |
1566
| if (_parser == null)
|
|
1649 |
309
| _parser = _parserFactory.newSAXParser();
|
|
1650 |
| |
|
1651 |
1566
| URL resourceURL = resource.getResourceURL();
|
|
1652 |
| |
|
1653 |
1566
| if (resourceURL == null)
|
|
1654 |
0
| throw new DocumentParseException(ParseMessages.missingResource(resource), resource);
|
|
1655 |
| |
|
1656 |
1566
| InputStream rawStream = resourceURL.openStream();
|
|
1657 |
1566
| stream = new BufferedInputStream(rawStream);
|
|
1658 |
| |
|
1659 |
1566
| _parser.parse(stream, this, resourceURL.toExternalForm());
|
|
1660 |
| |
|
1661 |
1518
| stream.close();
|
|
1662 |
1518
| stream = null;
|
|
1663 |
| |
|
1664 |
1518
| success = true;
|
|
1665 |
| } |
|
1666 |
| catch (SAXParseException ex) |
|
1667 |
| { |
|
1668 |
3
| _parser = null;
|
|
1669 |
| |
|
1670 |
3
| Location location = new LocationImpl(resource, ex.getLineNumber(), ex.getColumnNumber());
|
|
1671 |
| |
|
1672 |
3
| throw new DocumentParseException(ParseMessages.errorReadingResource(resource, ex),
|
|
1673 |
| location, ex); |
|
1674 |
| } |
|
1675 |
| catch (Exception ex) |
|
1676 |
| { |
|
1677 |
45
| _parser = null;
|
|
1678 |
| |
|
1679 |
45
| throw new DocumentParseException(ParseMessages.errorReadingResource(resource, ex),
|
|
1680 |
| resource, ex); |
|
1681 |
| } |
|
1682 |
| finally |
|
1683 |
| { |
|
1684 |
1566
| if (!success)
|
|
1685 |
48
| _parser = null;
|
|
1686 |
| |
|
1687 |
1566
| close(stream);
|
|
1688 |
| } |
|
1689 |
| } |
|
1690 |
| |
|
1691 |
192
| public ILibrarySpecification parseLibrarySpecification(Resource resource)
|
|
1692 |
| { |
|
1693 |
192
| initializeParser(resource, STATE_LIBRARY_SPECIFICATION_INITIAL);
|
|
1694 |
| |
|
1695 |
192
| try
|
|
1696 |
| { |
|
1697 |
192
| parseDocument();
|
|
1698 |
| |
|
1699 |
186
| return (ILibrarySpecification) _rootObject;
|
|
1700 |
| } |
|
1701 |
| finally |
|
1702 |
| { |
|
1703 |
192
| resetParser();
|
|
1704 |
| } |
|
1705 |
| } |
|
1706 |
| |
|
1707 |
297
| public IComponentSpecification parsePageSpecification(Resource resource)
|
|
1708 |
| { |
|
1709 |
297
| initializeParser(resource, STATE_PAGE_SPECIFICATION_INITIAL);
|
|
1710 |
| |
|
1711 |
297
| try
|
|
1712 |
| { |
|
1713 |
297
| parseDocument();
|
|
1714 |
| |
|
1715 |
291
| return (IComponentSpecification) _rootObject;
|
|
1716 |
| } |
|
1717 |
| finally |
|
1718 |
| { |
|
1719 |
297
| resetParser();
|
|
1720 |
| } |
|
1721 |
| } |
|
1722 |
| |
|
1723 |
4959
| protected String peekContent()
|
|
1724 |
| { |
|
1725 |
4959
| String content = super.peekContent();
|
|
1726 |
| |
|
1727 |
4959
| if (content == null)
|
|
1728 |
1398
| return null;
|
|
1729 |
| |
|
1730 |
3561
| return content.trim();
|
|
1731 |
| } |
|
1732 |
| |
|
1733 |
1566
| protected void resetParser()
|
|
1734 |
| { |
|
1735 |
1566
| _rootObject = null;
|
|
1736 |
1566
| _DTD_4_0 = false;
|
|
1737 |
| |
|
1738 |
1566
| _attributes.clear();
|
|
1739 |
| } |
|
1740 |
| |
|
1741 |
| |
|
1742 |
| |
|
1743 |
| |
|
1744 |
| |
|
1745 |
1563
| public InputSource resolveEntity(String publicId, String systemId) throws SAXException
|
|
1746 |
| { |
|
1747 |
1563
| if (TAPESTRY_DTD_4_0_PUBLIC_ID.equals(publicId))
|
|
1748 |
| { |
|
1749 |
921
| _DTD_4_0 = true;
|
|
1750 |
921
| return getDTDInputSource("Tapestry_4_0.dtd");
|
|
1751 |
| } |
|
1752 |
| |
|
1753 |
642
| if (TAPESTRY_DTD_3_0_PUBLIC_ID.equals(publicId))
|
|
1754 |
639
| return getDTDInputSource("Tapestry_3_0.dtd");
|
|
1755 |
| |
|
1756 |
3
| throw new DocumentParseException(ParseMessages.unknownPublicId(getResource(), publicId),
|
|
1757 |
| new LocationImpl(getResource()), null); |
|
1758 |
| } |
|
1759 |
| |
|
1760 |
| |
|
1761 |
162
| public void setBindingSource(BindingSource bindingSource)
|
|
1762 |
| { |
|
1763 |
162
| _bindingSource = bindingSource;
|
|
1764 |
| } |
|
1765 |
| |
|
1766 |
| |
|
1767 |
189
| public void setValueConverter(ValueConverter valueConverter)
|
|
1768 |
| { |
|
1769 |
189
| _valueConverter = valueConverter;
|
|
1770 |
| } |
|
1771 |
| } |