blob: ee81c1dea1c98e658157da22f43f40a689db436d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
package org.eclipse.jst.jsf.facelet.core.internal.cm;
import org.eclipse.jst.jsf.common.dom.TagIdentifier;
import org.eclipse.jst.jsf.core.internal.tld.TagIdentifierFactory;
import org.eclipse.jst.jsf.facelet.core.internal.FaceletCorePlugin;
import org.eclipse.jst.jsf.facelet.core.internal.cm.strategy.TagInfoStrategyComposite;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
/**
* A tag info that composes a number of other tag infos selected from a
* TagInfoStrategyComposite.
*
* @author cbateman
*
*/
public abstract class CompositeTagInfo extends TagInfo
{
private final TagInfoStrategyComposite _compositeStrategy;
private final String _uri;
/**
* @param uri
* @param compositeStrategy
*/
protected CompositeTagInfo(final String uri, final TagInfoStrategyComposite compositeStrategy)
{
_uri = uri;
_compositeStrategy = compositeStrategy;
}
@Override
public Object getTagProperty(String tagName, String key)
{
final TagIdentifier tagId = TagIdentifierFactory.createJSPTagWrapper(
_uri, tagName);
_compositeStrategy.resetIterator();
for (TagInfo tagInfo = getNextExternalInfo(tagId); tagInfo != _compositeStrategy
.getNoResult(); tagInfo = getNextExternalInfo(tagId))
{
try
{
if (tagInfo != _compositeStrategy.getNoResult())
{
final Object value = tagInfo.getTagProperty(tagName, key);
if (value != null)
{
return value;
}
}
// fall-through
}
catch (final Exception e)
{
FaceletCorePlugin.log("During meta-data strategy", e); //$NON-NLS-1$
}
}
return null;
}
/**
* @param tagName
* @return a named node map of known attributes for the tag, or null if not
* found
*/
@Override
public CMNamedNodeMap getAttributes(String tagName)
{
final TagIdentifier tagId = TagIdentifierFactory.createJSPTagWrapper(
_uri, tagName);
_compositeStrategy.resetIterator();
for (TagInfo tagInfo = getNextExternalInfo(tagId); tagInfo != _compositeStrategy
.getNoResult(); tagInfo = getNextExternalInfo(tagId))
{
try
{
if (tagInfo != _compositeStrategy.getNoResult())
{
final CMNamedNodeMap nodeMap = tagInfo
.getAttributes(tagName);
if (nodeMap != null)
{
return nodeMap;
}
}
// fall-through
}
catch (final Exception e)
{
FaceletCorePlugin.log("During meta-data strategy", e); //$NON-NLS-1$
}
}
return null;
}
private TagInfo getNextExternalInfo(final TagIdentifier input)
{
return _compositeStrategy.perform(input);
}
}
|