Skip to main content
summaryrefslogtreecommitdiffstats
blob: c7b37664cbab121a0e34a4d7b753a7ad5fded454 (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
package org.eclipse.jst.jsf.facelet.core.internal.cm;

import java.util.Enumeration;

import org.eclipse.jst.jsf.common.runtime.internal.view.model.common.ITagAttribute;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDataTypeImpl;
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;

/**
 * Adapts Facelet attribute date to the CM model.
 * 
 * @author cbateman
 *
 */
public class AttributeCMAdapter implements CMAttributeDeclaration
{
    private static final String DESCRIPTION = "description"; //$NON-NLS-1$
    private final int     _usage;
    private final String _name;
    private String _description;

    /**
     * @param name
     * @param usage
     */
    public AttributeCMAdapter(final String name, final int usage)
    {
        _name = name;
        _usage = usage;
    }
    
    /**
     * @param tagAttr 
     */
    public AttributeCMAdapter(final ITagAttribute tagAttr)
    {
        this(tagAttr.getName(), tagAttr.isRequired() ? REQUIRED : OPTIONAL);
        _description = tagAttr.getDescription();
    }
    
    public String getAttrName()
    {
        return _name;
    }

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

    public String getDefaultValue()
    {
        return null;
    }

    public Enumeration<?> getEnumAttr()
    {
        return null;
    }

    public int getUsage()
    {
        return _usage;
    }

    public String getNodeName()
    {
        return _name;
    }

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

    public Object getProperty(String propertyName)
    {
        if (DESCRIPTION.equals(propertyName))
        {
            return _description;
        }
        return null;
    }

    /**
     * @param description
     */
    public void setDescription(final String description)
    {
        _description = description;
    }
    
    public boolean supports(String propertyName)
    {
        return false;
    }
}

Back to the top