Skip to main content
summaryrefslogtreecommitdiffstats
blob: 768ec9c5e90785c9a7000b513f3bd29c44898da0 (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
/*******************************************************************************
 * 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.ejb.internal.util;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.jst.j2ee.ejb.ExcludeList;
import org.eclipse.jst.j2ee.ejb.MethodElement;
import org.eclipse.jst.j2ee.ejb.MethodPermission;
import org.eclipse.jst.j2ee.ejb.MethodTransaction;


/**
 * @author cbridgha
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class MethodElementHelper {
	public static final int NONE = 0;
	public static final int METHOD_PERMISSION = 1;
	public static final int METHOD_TRANSACTION = 2;
	public static final int EXCLUDE_LIST = 3;
	public static int getContainedType(MethodElement me) {
		EObject container = me.eContainer();
		if (container == null)
			return NONE;
		if (container instanceof MethodPermission)
			return METHOD_PERMISSION;
		if (container instanceof MethodTransaction)
			return METHOD_TRANSACTION;
		if (container instanceof ExcludeList)
			return EXCLUDE_LIST;
		return NONE;
	}
	public static MethodPermission getMethodPermission(MethodElement me) {
		if (METHOD_PERMISSION == getContainedType(me))
			return (MethodPermission) me.eContainer();
		return null;
	}
	public static MethodTransaction getMethodTransaction(MethodElement me) {
		if (METHOD_TRANSACTION == getContainedType(me))
			return (MethodTransaction) me.eContainer();
		return null;
	}
	public static ExcludeList getExcludeList(MethodElement me) {
		if (EXCLUDE_LIST == getContainedType(me))
			return (ExcludeList) me.eContainer();
		return null;
	}

}

Back to the top