Skip to main content
summaryrefslogtreecommitdiffstats
blob: b38e4315018e8f1995478514303bb9636d9d24a2 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/**
 * 
 */
package org.eclipse.jst.jsf.facelet.core.internal.cm;

import java.util.Iterator;

import org.eclipse.jst.jsf.common.runtime.internal.view.model.common.ITagElement;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDataTypeImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;

class ElementCMAdapter implements CMElementDeclaration, CMNamedNodeMap
{
    private final ITagElement  _tagElement;
    private final TagInfo _tLDTagInfo;

    ElementCMAdapter(final ITagElement tagElement, final TagInfo tldTagInfo)
    {
        _tagElement = tagElement;
        _tLDTagInfo = tldTagInfo;
    }

    public CMNamedNodeMap getAttributes()
    {
        return this;
    }

    public CMContent getContent()
    {
        return null;
    }

    public int getContentType()
    {
        return ELEMENT;
    }

    public CMDataType getDataType()
    {
        return new CMDataTypeImpl(CMDataType.CDATA);
    }

    public String getElementName()
    {
        return _tagElement.getName();
    }

    public CMNamedNodeMap getLocalElements()
    {
        // TODO Auto-generated method stub
        return null;
    }

    public int getMaxOccur()
    {
        // unbounded
        return -1;
    }

    public int getMinOccur()
    {
        // optional
        return 0;
    }

    public String getNodeName()
    {
        return _tagElement.getName();
    }

    public int getNodeType()
    {
        return CMNode.ELEMENT_DECLARATION;
    }

    public Object getProperty(final String propertyName)
    {
        return _tLDTagInfo.getTagProperty(_tagElement.getName(), propertyName);
    }

    public boolean supports(final String propertyName)
    {
        return false;
    }

    @Override
    public boolean equals(final Object obj)
    {
        if (obj instanceof ElementCMAdapter)
        {
            return ((ElementCMAdapter) obj)._tagElement.equals(_tagElement);
        }

        return false;
    }

    @Override
    public int hashCode()
    {
        return _tagElement.hashCode();
    }

    public int getLength()
    {
        final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());

        if (map != null)
        {
            return map.getLength();
        }

        return 0;
    }

    public CMNode getNamedItem(final String name)
    {
        final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());

        if (map != null)
        {
            return map.getNamedItem(name);
        }
        return null;
    }

    public CMNode item(final int index)
    {
        final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());

        if (map != null)
        {
            return map.item(index);
        }
        return null;
    }

    public Iterator<?> iterator()
    {
        final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
        return map.iterator();
    }

}

Back to the top