Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1989995113daa31f2c1a1c86e97f707d38593403 (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
/**
 * <copyright>
 * </copyright>
 *
 * $Id: IBoundedMapTypeDescriptorImpl.java,v 1.7 2007/10/01 04:29:44 cbateman Exp $
 */
package org.eclipse.jst.jsf.context.symbol.internal.impl;

import java.util.Iterator;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
import org.eclipse.jst.jsf.common.internal.types.ValueType;
import org.eclipse.jst.jsf.context.symbol.IBoundedJavaTypeDescriptor;
import org.eclipse.jst.jsf.context.symbol.IBoundedMapTypeDescriptor;
import org.eclipse.jst.jsf.context.symbol.IPropertySymbol;
import org.eclipse.jst.jsf.context.symbol.ISymbol;
import org.eclipse.jst.jsf.context.symbol.SymbolFactory;
import org.eclipse.jst.jsf.context.symbol.SymbolPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>IBounded Map Type Descriptor</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * </p>
 *
 * @generated
 */
public class IBoundedMapTypeDescriptorImpl extends IMapTypeDescriptorImpl implements IBoundedMapTypeDescriptor {
    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @SuppressWarnings("hiding")
	public static final String copyright = "Copyright 2006 Oracle";  //$NON-NLS-1$

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected IBoundedMapTypeDescriptorImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected EClass eStaticClass() {
        return SymbolPackage.Literals.IBOUNDED_MAP_TYPE_DESCRIPTOR;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated NOT
     */
    public boolean isUnboundedForType(String typeSignature) {
        // TODO: for now, return true if the type is a resolved object
        // need to add support for template checking (Java5) and
        // decide what to do with unresolved (Q) type signatures
        return typeSignature != null
                && typeSignature.startsWith(Character.toString(Signature.C_RESOLVED));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated NOT
     */
    public ISymbol getUnboundedProperty(Object name, String typeSignature) {
        ISymbol  retValue = null;
        
        if (isUnboundedForType(typeSignature))
        {
            // first see if we have it in our map source
            retValue = getFromMap(name.toString());
            
            if (retValue == null)
            {
                IPropertySymbol  propSymbol = SymbolFactory.eINSTANCE.createIPropertySymbol();
                // TODO: there is a possible problem here for non-string keyed maps
                propSymbol.setName(name.toString());
                propSymbol.setReadable(true);
                IBoundedJavaTypeDescriptor typeDesc = 
                    SymbolFactory.eINSTANCE.createIBoundedJavaTypeDescriptor();
                
                typeDesc.setTypeSignatureDelegate(TypeConstants.TYPE_JAVAOBJECT);
                propSymbol.setTypeDescriptor(typeDesc);
                retValue = propSymbol;
            }
        }

        return retValue;

    }

    /**
     * @see org.eclipse.jst.jsf.context.symbol.internal.impl.ITypeDescriptorImpl#calculateSyntheticCall(java.lang.String, org.eclipse.emf.common.util.EList, java.lang.String)
     * @generated NOT
     */
    public ISymbol calculateSyntheticCall(String methodName, EList methodArgs,
            String symbolName) {
        if ("get".equals(methodName)  //$NON-NLS-1$
                && methodArgs.size() == 1)
        {
            return getUnboundedProperty(symbolName, ((ValueType) methodArgs.get(0)).getSignature());
        }
            
        // default is return null
        return null;
    }


    /**
     * @generated NOT
     */
    private ISymbol getFromMap(final String name)
    {
        for (final Iterator it = getProperties().iterator(); it.hasNext();)
        {
            ISymbol  symbol = (ISymbol) it.next();
            
            if (symbol.getName().equals(name))
            {
                return symbol;
            }
        }
        
        return null;
    }

} //IBoundedMapTypeDescriptorImpl

Back to the top