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

COVERAGE SUMMARY FOR SOURCE FILE [CollectionIteratorActionHandler.java]

nameclass, %method, %block, %line, %
CollectionIteratorActionHandler.java0%   (0/1)0%   (0/4)0%   (0/145)0%   (0/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CollectionIteratorActionHandler0%   (0/1)0%   (0/4)0%   (0/145)0%   (0/34)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/2)
CollectionIteratorActionHandler (SeffVisitor): void 0%   (0/1)0%   (0/4)0%   (0/2)
getIterationExpression (String): String 0%   (0/1)0%   (0/111)0%   (0/21)
handle (CollectionIteratorAction): void 0%   (0/1)0%   (0/25)0%   (0/9)

1package de.uka.ipd.sdq.pcmsolver.handler;
2 
3import org.apache.log4j.Logger;
4import org.eclipse.emf.common.util.EList;
5 
6import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisation;
7import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisationType;
8import de.uka.ipd.sdq.pcm.parameter.VariableUsage;
9import de.uka.ipd.sdq.pcm.repository.Parameter;
10import de.uka.ipd.sdq.pcm.seff.CollectionIteratorAction;
11import de.uka.ipd.sdq.pcmsolver.visitors.SeffVisitor;
12import de.uka.ipd.sdq.stoex.AbstractNamedReference;
13import de.uka.ipd.sdq.stoex.NamespaceReference;
14 
15/**
16 * @author Koziolek
17 *
18 */
19public class CollectionIteratorActionHandler extends AbstractLoopActionHandler{
20 
21        private static Logger logger = Logger.getLogger(CollectionIteratorActionHandler.class.getName());
22 
23        public CollectionIteratorActionHandler(SeffVisitor seffVisitor) {
24                super(seffVisitor);
25        }
26        
27        /**
28         * @param loop
29         */
30        public void handle(CollectionIteratorAction collIterAction) {
31                Parameter parameter = collIterAction.getParameter_CollectionIteratorAction();
32                String parameterName = parameter.getParameterName();
33                
34                String iterCount = getIterationExpression(parameterName);
35                if (iterCount == null){
36                        logger.error("Skipping execution of loop body!");
37                        return;
38                }
39                
40                storeToUsageContext(collIterAction, iterCount);
41                
42                visitLoopBody(collIterAction, iterCount);
43        }
44 
45 
46        
47        /**
48         * Fetches the expression describing the number of loop iteration
49         * from the usage context. It is the NUMBER_OF_ELEMENTS of the parameter
50         * in the SEFF, whose name is passed here as input parameter.
51         * 
52         * @param soughtParameterName
53         * @return
54         */
55        private String getIterationExpression(String soughtParameterName){
56                EList<VariableUsage> vuList = visitor.getContextWrapper().getCompUsgCtx().getInput_ComputedUsageContext().getParameterChacterisations_Input();
57 
58                for (VariableUsage vu : vuList){ // iterate over parameters
59                        String currentParameterName = "";
60                        AbstractNamedReference ref = vu.getNamedReference__VariableUsage();
61                        while (ref instanceof NamespaceReference){
62                                NamespaceReference nsRef = (NamespaceReference)ref;
63                                currentParameterName += nsRef.getReferenceName() + ".";
64                                ref = nsRef.getInnerReference_NamespaceReference();
65                        }
66                        currentParameterName += ref.getReferenceName();
67                        
68                        if (currentParameterName.equals(soughtParameterName)){
69                                EList<VariableCharacterisation> varChars = vu.getVariableCharacterisation_VariableUsage();
70                                for (VariableCharacterisation vc : varChars){ // iterate over a parameter's characterisations
71                                        if (vc.getType() == VariableCharacterisationType.NUMBER_OF_ELEMENTS){
72                                                return vc.getSpecification_VariableCharacterisation().getSpecification();
73                                        }
74                                }
75                                logger.error("Variable Characterisation NUMBER_OF_ELEMENTS missing " +
76                                                "in Usage Context for parameter "+soughtParameterName+")! " +
77                                                                "It is needed for a CollectionIteratorAction.");
78                                return null;
79                        }
80                }
81                logger.error("Variable "+soughtParameterName+" missing " +
82                                "in Usage Context!");
83                return null;
84        }
85        
86}

[all classes][de.uka.ipd.sdq.pcmsolver.handler]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov