EMMA Coverage Report (generated Thu Jan 20 11:39:44 EST 2011)
[all classes][com.hammurapi.eventbus.snapshot.io]

COVERAGE SUMMARY FOR SOURCE FILE [PredicateOutput.java]

nameclass, %method, %block, %line, %
PredicateOutput.java0%   (0/1)0%   (0/2)0%   (0/54)0%   (0/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PredicateOutput0%   (0/1)0%   (0/2)0%   (0/54)0%   (0/12)
PredicateOutput (): void 0%   (0/1)0%   (0/3)0%   (0/1)
output (Predicate, File): void 0%   (0/1)0%   (0/51)0%   (0/11)

1package com.hammurapi.eventbus.snapshot.io;
2 
3import java.io.File;
4import java.io.IOException;
5 
6import org.eclipse.emf.common.util.EList;
7import org.eclipse.emf.common.util.URI;
8import org.eclipse.emf.ecore.EObject;
9import org.eclipse.emf.ecore.resource.Resource;
10import org.eclipse.emf.ecore.resource.ResourceSet;
11import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
12import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
13 
14import com.hammurapi.convert.ConvertingService;
15import com.hammurapi.eventbus.EventBusException;
16import com.hammurapi.extract.Predicate;
17 
18/**
19 * Class to dump predicates into snapshot model for troubleshooting.
20 * @author Pavel Vlasov
21 */
22public class PredicateOutput {
23        
24                
25        public static void output(Predicate<?, ?> predicate, File out) {
26                
27                com.hammurapi.eventbus.snapshot.Predicate sp = ConvertingService.convert(predicate, com.hammurapi.eventbus.snapshot.Predicate.class);
28                
29                ResourceSet resourceSet = new ResourceSetImpl();
30                        // Register the appropriate resource factory to handle all file extensions.
31                        //
32                resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
33         
34                URI uri = URI.createFileURI(out.getAbsolutePath());
35                Resource predicateResource = resourceSet.createResource(uri);
36                EList<EObject> contents = predicateResource.getContents();
37                contents.add(sp);
38                try {
39                        predicateResource.save(null);
40                } catch (IOException e) {
41                        throw new EventBusException("Could not save snapshot: "+e, e);
42                }                        
43        }
44 
45}

[all classes][com.hammurapi.eventbus.snapshot.io]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov