FileDocCategorySizeDatePackage
RTCoverageDataPersister.javaAPI DocAndroid 1.5 API2992Wed May 06 22:41:16 BST 2009com.vladium.emma.rt

RTCoverageDataPersister

public abstract class RTCoverageDataPersister extends Object
author
Vlad Roubtsov, (C) 2004

Fields Summary
Constructors Summary
Methods Summary
static voiddumpCoverageData(com.vladium.emma.data.ICoverageData cdata, boolean useSnapshot, java.io.File outFile, boolean merge)

        try
        {
            if (cdata != null)
            {
                // use method-scoped loggers everywhere in RT:
                final Logger log = Logger.getLogger ();
                final boolean info = log.atINFO ();
                
                final long start = info ? System.currentTimeMillis () : 0;
                {
                    final ICoverageData cdataView = useSnapshot ? cdata.shallowCopy () : cdata;
                    
                    synchronized (Object.class) // fake a JVM-global critical section when multilply loaded RT's write to the same file
                    {
                        DataFactory.persist (cdataView, outFile, merge);
                    }
                }
                if (info)
                {
                    final long end = System.currentTimeMillis ();
                    
                    log.info ("runtime coverage data " + (merge ? "merged into" : "written to") + " [" + outFile.getAbsolutePath () + "] {in " + (end - start) + " ms}");
                }
            }
        }
        catch (Throwable t)
        {
            // log
            t.printStackTrace ();
            
            // TODO: do better chaining in JRE 1.4+
            throw new RuntimeException (IAppConstants.APP_NAME + " failed to dump coverage data: " + t.toString ());
        }