|
|||||||||||||||||||
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 | |||||||||||||||
DefaultParserDelegate.java | 50% | 92.9% | 100% | 90.5% |
|
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.services.impl;
|
|
16 |
|
|
17 |
import org.apache.hivemind.Location;
|
|
18 |
import org.apache.tapestry.IComponent;
|
|
19 |
import org.apache.tapestry.INamespace;
|
|
20 |
import org.apache.tapestry.IRequestCycle;
|
|
21 |
import org.apache.tapestry.Tapestry;
|
|
22 |
import org.apache.tapestry.parse.ITemplateParserDelegate;
|
|
23 |
import org.apache.tapestry.resolver.ComponentSpecificationResolver;
|
|
24 |
import org.apache.tapestry.spec.IComponentSpecification;
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Default implementation of {@link org.apache.tapestry.parse.ITemplateParserDelegate}.
|
|
28 |
*
|
|
29 |
* @author Howard Lewis Ship
|
|
30 |
* @since 4.0
|
|
31 |
*/
|
|
32 |
public class DefaultParserDelegate implements ITemplateParserDelegate |
|
33 |
{ |
|
34 |
private IComponent _component;
|
|
35 |
|
|
36 |
private ComponentSpecificationResolver _resolver;
|
|
37 |
|
|
38 |
private IRequestCycle _cycle;
|
|
39 |
|
|
40 |
private String _componentAttributeName;
|
|
41 |
|
|
42 | 171 |
public DefaultParserDelegate(IComponent component, String componentAttributeName,
|
43 |
IRequestCycle cycle, ComponentSpecificationResolver resolver) |
|
44 |
{ |
|
45 | 171 |
_component = component; |
46 | 171 |
_componentAttributeName = componentAttributeName; |
47 | 171 |
_resolver = resolver; |
48 | 171 |
_cycle = cycle; |
49 |
} |
|
50 |
|
|
51 | 292 |
public boolean getKnownComponent(String componentId) |
52 |
{ |
|
53 | 292 |
return _component.getSpecification().getComponent(componentId) != null; |
54 |
} |
|
55 |
|
|
56 | 292 |
public boolean getAllowBody(String componentId, Location location) |
57 |
{ |
|
58 | 292 |
IComponent embedded = _component.getComponent(componentId); |
59 |
|
|
60 | 292 |
if (embedded == null) |
61 | 0 |
throw Tapestry.createNoSuchComponentException(_component, componentId, location);
|
62 |
|
|
63 | 292 |
return embedded.getSpecification().getAllowBody();
|
64 |
} |
|
65 |
|
|
66 | 508 |
public boolean getAllowBody(String libraryId, String type, Location location) |
67 |
{ |
|
68 | 508 |
INamespace namespace = _component.getNamespace(); |
69 |
|
|
70 | 508 |
_resolver.resolve(_cycle, namespace, libraryId, type, location); |
71 |
|
|
72 | 508 |
IComponentSpecification spec = _resolver.getSpecification(); |
73 |
|
|
74 | 508 |
return spec.getAllowBody();
|
75 |
} |
|
76 |
|
|
77 | 171 |
public String getComponentAttributeName()
|
78 |
{ |
|
79 | 171 |
return _componentAttributeName;
|
80 |
} |
|
81 |
} |
|