EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.gmf.seff.expressions]

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelAbstractExpression.java]

nameclass, %method, %block, %line, %
PalladioComponentModelAbstractExpression.java0%   (0/1)0%   (0/8)0%   (0/220)0%   (0/57)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelAbstractExpression0%   (0/1)0%   (0/8)0%   (0/220)0%   (0/57)
PalladioComponentModelAbstractExpression (String, EClassifier): void 0%   (0/1)0%   (0/12)0%   (0/5)
body (): String 0%   (0/1)0%   (0/3)0%   (0/1)
context (): EClassifier 0%   (0/1)0%   (0/3)0%   (0/1)
evaluate (Object): Object 0%   (0/1)0%   (0/5)0%   (0/1)
evaluate (Object, Map): Object 0%   (0/1)0%   (0/24)0%   (0/6)
getStatus (): IStatus 0%   (0/1)0%   (0/3)0%   (0/1)
performCast (Object, EDataType): Object 0%   (0/1)0%   (0/134)0%   (0/34)
setStatus (int, String, Throwable): void 0%   (0/1)0%   (0/36)0%   (0/8)

1/*
2 * Copyright 2006 SDQ Research Group, University of Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.seff.expressions;
5 
6import java.math.BigDecimal;
7import java.math.BigInteger;
8import java.util.Collections;
9import java.util.Map;
10 
11import org.eclipse.core.runtime.IStatus;
12import org.eclipse.core.runtime.Status;
13import org.eclipse.emf.ecore.EClassifier;
14import org.eclipse.emf.ecore.EDataType;
15import org.eclipse.emf.ecore.EEnum;
16import org.eclipse.emf.ecore.EEnumLiteral;
17import org.eclipse.emf.ecore.util.EcoreUtil;
18 
19import de.uka.ipd.sdq.pcm.gmf.seff.part.PalladioComponentModelSeffDiagramEditorPlugin;
20 
21/**
22 * @generated
23 */
24public abstract class PalladioComponentModelAbstractExpression {
25        /**
26         * @generated
27         */
28        private IStatus status = Status.OK_STATUS;
29 
30        /**
31         * @generated
32         */
33        protected PalladioComponentModelAbstractExpression(String body,
34                        EClassifier context) {
35                myBody = body;
36                myContext = context;
37        }
38 
39        /**
40         * @generated
41         */
42        protected void setStatus(int severity, String message, Throwable throwable) {
43                String pluginID = PalladioComponentModelSeffDiagramEditorPlugin.ID;
44                this.status = new Status(severity, pluginID, -1,
45                                (message != null) ? message : "", throwable); //$NON-NLS-1$
46                if (!this.status.isOK()) {
47                        PalladioComponentModelSeffDiagramEditorPlugin
48                                        .getInstance()
49                                        .logError(
50                                                        "Expression problem:" + message + "body:" + body(), throwable); //$NON-NLS-1$ //$NON-NLS-2$
51                }
52        }
53 
54        /**
55         * @generated
56         */
57        protected abstract Object doEvaluate(Object context, Map env);
58 
59        /**
60         * @generated
61         */
62        public Object evaluate(Object context) {
63                return evaluate(context, Collections.EMPTY_MAP);
64        }
65 
66        /**
67         * @generated
68         */
69        public Object evaluate(Object context, Map env) {
70                if (context().isInstance(context)) {
71                        try {
72                                return doEvaluate(context, env);
73                        } catch (Exception e) {
74                                PalladioComponentModelSeffDiagramEditorPlugin
75                                                .getInstance()
76                                                .logError("Expression evaluation failure: " + body(), e); //$NON-NLS-1$
77                        }
78                }
79                return null;
80        }
81 
82        /**
83         * Expression may return number value which is not directly compatible with feature type (e.g. Double when Integer is expected), or EEnumLiteral meta-object when literal instance is expected
84         * @generated
85         */
86        public static Object performCast(Object value, EDataType targetType) {
87                if (targetType instanceof EEnum) {
88                        if (value instanceof EEnumLiteral) {
89                                EEnumLiteral literal = (EEnumLiteral) value;
90                                return (literal.getInstance() != null) ? literal.getInstance()
91                                                : literal;
92                        }
93                }
94                if (false == value instanceof Number || targetType == null
95                                || targetType.getInstanceClass() == null) {
96                        return value;
97                }
98                Class targetClass = targetType.getInstanceClass();
99                Number num = (Number) value;
100                Class valClass = value.getClass();
101                Class targetWrapperClass = targetClass;
102                if (targetClass.isPrimitive()) {
103                        targetWrapperClass = EcoreUtil.wrapperClassFor(targetClass);
104                }
105                if (valClass.equals(targetWrapperClass)) {
106                        return value;
107                }
108                if (Number.class.isAssignableFrom(targetWrapperClass)) {
109                        if (targetWrapperClass.equals(Byte.class))
110                                return new Byte(num.byteValue());
111                        if (targetWrapperClass.equals(Integer.class))
112                                return new Integer(num.intValue());
113                        if (targetWrapperClass.equals(Short.class))
114                                return new Short(num.shortValue());
115                        if (targetWrapperClass.equals(Long.class))
116                                return new Long(num.longValue());
117                        if (targetWrapperClass.equals(BigInteger.class))
118                                return BigInteger.valueOf(num.longValue());
119                        if (targetWrapperClass.equals(Float.class))
120                                return new Float(num.floatValue());
121                        if (targetWrapperClass.equals(Double.class))
122                                return new Double(num.doubleValue());
123                        if (targetWrapperClass.equals(BigDecimal.class))
124                                return new BigDecimal(num.doubleValue());
125                }
126                return value;
127        }
128 
129        /**
130         * @generated
131         */
132        public IStatus getStatus() {
133                return status;
134        }
135 
136        /**
137         * @generated
138         */
139        private final String myBody;
140 
141        /**
142         * @generated
143         */
144        public String body() {
145                return myBody;
146        }
147 
148        /**
149         * @generated
150         */
151        private final EClassifier myContext;
152 
153        /**
154         * @generated
155         */
156        public EClassifier context() {
157                return myContext;
158        }
159}

[all classes][de.uka.ipd.sdq.pcm.gmf.seff.expressions]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov