Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0cb6b106a42e04e8cba6418b11790272e36d15dd (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
/*******************************************************************************
 * Copyright (c) 2001, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.internal.model.translator.ejb;

import java.util.Collections;
import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.jst.j2ee.ejb.EjbPackage;
import org.eclipse.jst.j2ee.ejb.MethodElement;
import org.eclipse.jst.j2ee.ejb.MethodElementKind;
import org.eclipse.jst.j2ee.internal.xml.EjbDeploymentDescriptorXmlMapperI;
import org.eclipse.wst.common.internal.emf.resource.Translator;

public class MethodElementKindTranslator extends Translator implements EjbDeploymentDescriptorXmlMapperI {
	private static final EjbPackage EJB_PKG = EjbPackage.eINSTANCE;
    /**
     * @param domNameAndPath
     * @param eClass
     */
    public MethodElementKindTranslator(){
		super(METHOD_INTF, EJB_PKG.getMethodElement_Type());
    }
	/* (non-Javadoc)
	 * @see com.ibm.etools.emf2xml.impl.Translator#convertStringToValue(java.lang.String, org.eclipse.emf.ecore.EObject)
	 */
	@Override
	public Object convertStringToValue(String strValue, EObject owner) {
		Object obj = super.convertStringToValue(strValue, owner);
		if(obj != null)
			return obj;
		if (strValue == null)
			return null;
		String correct = strValue;
		if (strValue.equalsIgnoreCase("HOME")) //$NON-NLS-1$
			correct = "Home"; //$NON-NLS-1$
		else if (strValue.equalsIgnoreCase("REMOTE")) //$NON-NLS-1$
			correct = "Remote"; //$NON-NLS-1$
		else if (strValue.equalsIgnoreCase("LOCALHOME")) //$NON-NLS-1$
			correct = "LocalHome"; //$NON-NLS-1$
		else if (strValue.equalsIgnoreCase("LOCAL")) //$NON-NLS-1$
			correct = "Local"; //$NON-NLS-1$
		return super.convertStringToValue(correct, owner);
	}
	
	/* (non-Javadoc)
     * @see com.ibm.etools.emf2xml.impl.Translator#isSetMOFValue(org.eclipse.emf.ecore.EObject)
     */
    @Override
	public boolean isSetMOFValue(EObject emfObject) {
        if (((MethodElement)emfObject).getType() == MethodElementKind.UNSPECIFIED_LITERAL)
        	return false;
        return super.isSetMOFValue(emfObject);
    }
    
    /* (non-Javadoc)
	 * @see com.ibm.etools.emf2xml.impl.Translator#getMOFChildren(org.eclipse.emf.ecore.EObject)
	 */
	@Override
	public List getMOFChildren(EObject mofObject) {
		List result = super.getMOFChildren(mofObject);
		if(result != null && result.size() > 0) {
			MethodElementKind methodIntf = (MethodElementKind) result.get(0);
			if(methodIntf.getValue() == MethodElementKind.UNSPECIFIED) 
				result = Collections.EMPTY_LIST;
		}
		return result;
	}


}

Back to the top