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

COVERAGE SUMMARY FOR SOURCE FILE [probespecExample.java]

nameclass, %method, %block, %line, %
probespecExample.java0%   (0/1)0%   (0/3)0%   (0/157)0%   (0/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class probespecExample0%   (0/1)0%   (0/3)0%   (0/157)0%   (0/34)
main (String []): void 0%   (0/1)0%   (0/124)0%   (0/28)
printDiagnostic (Diagnostic, String): void 0%   (0/1)0%   (0/30)0%   (0/5)
probespecExample (): void 0%   (0/1)0%   (0/3)0%   (0/1)

1/**
2 * <copyright>
3 * </copyright>
4 *
5 * $Id$
6 */
7package de.uka.ipd.sdq.probespec.tests;
8 
9import de.uka.ipd.sdq.probespec.PassiveResourceCalculator;
10import de.uka.ipd.sdq.probespec.probespecFactory;
11import de.uka.ipd.sdq.probespec.probespecPackage;
12 
13import de.uka.ipd.sdq.probespec.util.probespecResourceFactoryImpl;
14 
15import java.io.File;
16import java.io.IOException;
17 
18import org.eclipse.emf.common.util.Diagnostic;
19import org.eclipse.emf.common.util.URI;
20 
21import org.eclipse.emf.ecore.EObject;
22 
23import org.eclipse.emf.ecore.resource.Resource;
24import org.eclipse.emf.ecore.resource.ResourceSet;
25 
26import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
27 
28import org.eclipse.emf.ecore.util.Diagnostician;
29 
30/**
31 * <!-- begin-user-doc -->
32 * A sample utility for the '<em><b>probespec</b></em>' package.
33 * <!-- end-user-doc -->
34 * @generated
35 */
36public class probespecExample {
37        /**
38         * <!-- begin-user-doc -->
39         * Load all the argument file paths or URIs as instances of the model.
40         * <!-- end-user-doc -->
41         * @param args the file paths or URIs.
42         * @generated
43         */
44        public static void main(String[] args) {
45                // Create a resource set to hold the resources.
46                //
47                ResourceSet resourceSet = new ResourceSetImpl();
48                
49                // Register the appropriate resource factory to handle all file extensions.
50                //
51                resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
52                        (Resource.Factory.Registry.DEFAULT_EXTENSION, 
53                         new probespecResourceFactoryImpl());
54 
55                // Register the package to ensure it is available during loading.
56                //
57                resourceSet.getPackageRegistry().put
58                        (probespecPackage.eNS_URI, 
59                         probespecPackage.eINSTANCE);
60        
61                // If there are no arguments, emit an appropriate usage message.
62                //
63                if (args.length == 0) {
64                        System.out.println("Enter a list of file paths or URIs that have content like this:");
65                        try {
66                                Resource resource = resourceSet.createResource(URI.createURI("http:///My.probespec"));
67                                PassiveResourceCalculator root = probespecFactory.eINSTANCE.createPassiveResourceCalculator();
68                                resource.getContents().add(root);
69                                resource.save(System.out, null);
70                        }
71                        catch (IOException exception) {
72                                exception.printStackTrace();
73                        }
74                }
75                else {
76                        // Iterate over all the arguments.
77                        //
78                        for (int i = 0; i < args.length; ++i) {
79                                // Construct the URI for the instance file.
80                                // The argument is treated as a file path only if it denotes an existing file.
81                                // Otherwise, it's directly treated as a URL.
82                                //
83                                File file = new File(args[i]);
84                                URI uri = file.isFile() ? URI.createFileURI(file.getAbsolutePath()): URI.createURI(args[0]);
85 
86                                try {
87                                        // Demand load resource for this file.
88                                        //
89                                        Resource resource = resourceSet.getResource(uri, true);
90                                        System.out.println("Loaded " + uri);
91 
92                                        // Validate the contents of the loaded resource.
93                                        //
94                                        for (EObject eObject : resource.getContents()) {
95                                                Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eObject);
96                                                if (diagnostic.getSeverity() != Diagnostic.OK) {
97                                                        printDiagnostic(diagnostic, "");
98                                                }
99                                        }
100                                }
101                                catch (RuntimeException exception) {
102                                        System.out.println("Problem loading " + uri);
103                                        exception.printStackTrace();
104                                }
105                        }
106                }
107        }
108        
109        /**
110         * <!-- begin-user-doc -->
111         * Prints diagnostics with indentation.
112         * <!-- end-user-doc -->
113         * @param diagnostic the diagnostic to print.
114         * @param indent the indentation for printing.
115         * @generated
116         */
117        protected static void printDiagnostic(Diagnostic diagnostic, String indent) {
118                System.out.print(indent);
119                System.out.println(diagnostic.getMessage());
120                for (Diagnostic child : diagnostic.getChildren()) {
121                        printDiagnostic(child, indent + "  ");
122                }
123        }
124 
125} //probespecExample

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