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 [PalladioComponentModelOCLFactory.java]

nameclass, %method, %block, %line, %
PalladioComponentModelOCLFactory.java0%   (0/3)0%   (0/12)0%   (0/266)0%   (0/74)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelOCLFactory0%   (0/1)0%   (0/3)0%   (0/15)0%   (0/4)
PalladioComponentModelOCLFactory (): void 0%   (0/1)0%   (0/3)0%   (0/2)
getExpression (String, EClassifier): PalladioComponentModelAbstractExpression 0%   (0/1)0%   (0/5)0%   (0/1)
getExpression (String, EClassifier, Map): PalladioComponentModelAbstractExpre... 0%   (0/1)0%   (0/7)0%   (0/1)
     
class PalladioComponentModelOCLFactory$Expression0%   (0/1)0%   (0/7)0%   (0/206)0%   (0/56)
PalladioComponentModelOCLFactory$Expression (String, EClassifier, Map): void 0%   (0/1)0%   (0/13)0%   (0/4)
access$0 (PalladioComponentModelOCLFactory$Expression): OCL 0%   (0/1)0%   (0/3)0%   (0/1)
createVar (Environment, String, EClassifier): Variable 0%   (0/1)0%   (0/14)0%   (0/4)
doEvaluate (Object, Map): Object 0%   (0/1)0%   (0/62)0%   (0/17)
getQuery (): Query 0%   (0/1)0%   (0/51)0%   (0/13)
initCustomEnv (Environment, Map): void 0%   (0/1)0%   (0/27)0%   (0/6)
initExtentMap (Object): void 0%   (0/1)0%   (0/36)0%   (0/11)
     
class PalladioComponentModelOCLFactory$Expression$10%   (0/1)0%   (0/2)0%   (0/45)0%   (0/15)
PalladioComponentModelOCLFactory$Expression$1 (PalladioComponentModelOCLFacto... 0%   (0/1)0%   (0/15)0%   (0/3)
visitOperationCallExp (OperationCallExp): Object 0%   (0/1)0%   (0/30)0%   (0/12)

1/*
2 * Copyright 2006 SDQ Research Group, University of Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.seff.expressions;
5 
6import java.lang.ref.WeakReference;
7import java.util.Collections;
8import java.util.Iterator;
9import java.util.Map;
10 
11import org.eclipse.core.runtime.IStatus;
12import org.eclipse.emf.ecore.EClassifier;
13import org.eclipse.ocl.Environment;
14import org.eclipse.ocl.EvaluationEnvironment;
15import org.eclipse.ocl.ParserException;
16import org.eclipse.ocl.Query;
17import org.eclipse.ocl.ecore.EcoreFactory;
18import org.eclipse.ocl.expressions.OCLExpression;
19import org.eclipse.ocl.expressions.OperationCallExp;
20import org.eclipse.ocl.expressions.Variable;
21import org.eclipse.ocl.helper.OCLHelper;
22import org.eclipse.ocl.utilities.AbstractVisitor;
23import org.eclipse.ocl.utilities.PredefinedType;
24 
25/**
26 * @generated 
27 */
28public class PalladioComponentModelOCLFactory {
29 
30        /**
31         * @generated 
32         */
33        private PalladioComponentModelOCLFactory() {
34        }
35 
36        /**
37         * @generated 
38         */
39        public static PalladioComponentModelAbstractExpression getExpression(
40                        String body, EClassifier context, Map environment) {
41                return new Expression(body, context, environment);
42        }
43 
44        /**
45         * @generated 
46         */
47        public static PalladioComponentModelAbstractExpression getExpression(
48                        String body, EClassifier context) {
49                return getExpression(body, context, Collections.EMPTY_MAP);
50        }
51 
52        /**
53         * @generated 
54         */
55        private static class Expression extends
56                        PalladioComponentModelAbstractExpression {
57                /**
58                 * @generated 
59                 */
60                private WeakReference queryRef;
61 
62                /**
63                 * @generated 
64                 */
65                private final org.eclipse.ocl.ecore.OCL oclInstance;
66 
67                /**
68                 * @generated 
69                 */
70                public Expression(String body, EClassifier context, Map environment) {
71                        super(body, context);
72                        oclInstance = org.eclipse.ocl.ecore.OCL.newInstance();
73                        initCustomEnv(oclInstance.getEnvironment(), environment);
74                }
75 
76                /**
77                 * @generated 
78                 */
79                protected Query getQuery() {
80                        Query oclQuery = null;
81                        if (this.queryRef != null) {
82                                oclQuery = (Query) this.queryRef.get();
83                        }
84                        if (oclQuery == null) {
85                                OCLHelper oclHelper = oclInstance.createOCLHelper();
86                                oclHelper.setContext(context());
87                                try {
88                                        OCLExpression oclExpression = oclHelper.createQuery(body());
89                                        oclQuery = oclInstance.createQuery(oclExpression);
90                                        this.queryRef = new WeakReference(oclQuery);
91                                        setStatus(IStatus.OK, null, null);
92                                } catch (ParserException e) {
93                                        setStatus(IStatus.ERROR, e.getMessage(), e);
94                                }
95                        }
96                        return oclQuery;
97                }
98 
99                /**
100                 * @generated 
101                 */
102                protected Object doEvaluate(Object context, Map env) {
103                        Query oclQuery = getQuery();
104                        if (oclQuery == null) {
105                                return null;
106                        }
107                        EvaluationEnvironment evalEnv = oclQuery.getEvaluationEnvironment();
108                        // init environment
109                        for (Iterator it = env.entrySet().iterator(); it.hasNext();) {
110                                Map.Entry nextEntry = (Map.Entry) it.next();
111                                evalEnv.replace((String) nextEntry.getKey(), nextEntry
112                                                .getValue());
113                        }
114                        try {
115                                initExtentMap(context);
116                                Object result = oclQuery.evaluate(context);
117                                return (result != oclInstance.getEnvironment()
118                                                .getOCLStandardLibrary().getOclInvalid()) ? result
119                                                : null;
120                        } finally {
121                                evalEnv.clear();
122                                oclQuery.getExtentMap().clear();
123                        }
124                }
125 
126                /**
127                 * @generated
128                 */
129                private void initExtentMap(Object context) {
130                        if (!getStatus().isOK() || context == null) {
131                                return;
132                        }
133                        final Query queryToInit = getQuery();
134                        final Object extentContext = context;
135                        queryToInit.getExtentMap().clear();
136                        if (queryToInit.queryText() != null
137                                        && queryToInit.queryText().indexOf(
138                                                        PredefinedType.ALL_INSTANCES_NAME) >= 0) {
139                                AbstractVisitor visitior = new AbstractVisitor() {
140 
141                                        private boolean usesAllInstances = false;
142 
143                                        public Object visitOperationCallExp(OperationCallExp oc) {
144                                                if (!usesAllInstances) {
145                                                        usesAllInstances = PredefinedType.ALL_INSTANCES == oc
146                                                                        .getOperationCode();
147                                                        if (usesAllInstances) {
148                                                                queryToInit
149                                                                                .getExtentMap()
150                                                                                .putAll(
151                                                                                                oclInstance
152                                                                                                                .getEvaluationEnvironment()
153                                                                                                                .createExtentMap(
154                                                                                                                                extentContext));
155                                                        }
156                                                }
157                                                return super.visitOperationCallExp(oc);
158                                        }
159                                };
160                                queryToInit.getExpression().accept(visitior);
161                        }
162                }
163 
164                /**
165                 * @generated 
166                 */
167                private static void initCustomEnv(Environment ecoreEnv, Map environment) {
168                        for (Iterator it = environment.keySet().iterator(); it.hasNext();) {
169                                String varName = (String) it.next();
170                                EClassifier varType = (EClassifier) environment.get(varName);
171                                ecoreEnv.addElement(varName, createVar(ecoreEnv, varName,
172                                                varType), false);
173                        }
174                }
175 
176                /**
177                 * @generated 
178                 */
179                private static Variable createVar(Environment ecoreEnv, String name,
180                                EClassifier type) {
181                        Variable var = EcoreFactory.eINSTANCE.createVariable();
182                        var.setName(name);
183                        var.setType(ecoreEnv.getUMLReflection().getOCLType(type));
184                        return var;
185                }
186        }
187}

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