emma

AN, span);
      
      return this;
    }
    
    Cell(Tag tag)
    {
      super(AttributeSet.create());
    }
  }
  
  private static class Row
    extends IElement.Factory.ElementImpl
    implements HTMLTable.IRow
  {
    private final boolean m_th;
    
    public HTMLTable.ICell newCell()
    {
      HTMLTable.ICell cell = new HTMLTable.Cell(m_th ? Tag.TH : Tag.TD);
      add(cell);
      
      return cell;
    }
    
    Row(boolean th)
    {
      super(AttributeSet.create());
      
      m_th = th;
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.HTMLTable
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

import com.vladium.emma.EMMARuntimeException;
import com.vladium.util.IConstants;
import java.io.IOException;
import java.io.Writer;

public final class HTMLWriter
{
  private Writer m_out;
  
  public HTMLWriter(Writer out)
  {
    if (out == null) {
      throw new IllegalArgumentException("null input: out");
    }
    m_out = out;
  }
  
  public void write(String s)
  {
    if (m_out != null) {
      try
      {
        m_out.write(s);
      }
      catch (IOException ioe)
      {
        throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
      }
    }
  }
  
  public void write(char c)
  {
    if (m_out != null) {
      try
      {
        m_out.write(c);
      }
      catch (IOException ioe)
      {
        throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
      }
    }
  }
  
  public void eol()
  {
    if (m_out != null) {
      try
      {
        m_out.write(IConstants.EOL);
      }
      catch (IOException ioe)
      {
        throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
      }
    }
  }
  
  public void flush()
  {
    if (m_out != null) {
      try
      {
        m_out.flush();
      }
      catch (IOException ioe)
      {
        throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
      }
    }
  }
  
  public void close()
  {
    if (m_out != null)
    {
      try
      {
        m_out.close();
      }
      catch (IOException ignore) {}
      m_out = null;
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.HTMLWriter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

public class HyperRef
  extends IElement.Factory.ElementImpl
{
  public HyperRef(String href, String text, boolean nbsp)
  {
    super(Tag.A, AttributeSet.create());
    if ((href == null) || (href.length() == 0)) {
      throw new IllegalArgumentException("null or empty input: href");
    }
    if ((text == null) || (text.length() == 0)) {
      throw new IllegalArgumentException("null or empty input: text");
    }
    getAttributes().set(Attribute.HREF, href);
    
    setText(text, nbsp);
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.HyperRef
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

public abstract interface IContent
{
  public abstract void emit(HTMLWriter paramHTMLWriter);
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.IContent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

class IElement$Factory$ElementImpl
  extends ISimpleElement.Factory.SimpleElementImpl
  implements IElement
{
  protected final List m_contents;
  private static final boolean DEBUG_HTML = false;
  
  public String toString()
  {
    return "<" + m_tag.getName() + ">";
  }
  
  public void emit(HTMLWriter out)
  {
    String tagName = m_tag.getName();
    
    out.write('<');
    out.write(tagName);
    if (!m_attrs.isEmpty())
    {
      out.write(' ');
      m_attrs.emit(out);
    }
    out.write('>');
    for (Iterator c = m_contents.iterator(); c.hasNext();)
    {
      IContent content = (IContent)c.next();
      content.emit(out);
    }
    out.write("</");
    out.write(tagName);
    out.write('>');
  }
  
  public IElementList add(IContent content)
  {
    if (content != null) {
      m_contents.add(content);
    }
    return this;
  }
  
  public IElementList add(int index, IContent content)
  {
    if (content != null) {
      m_contents.add(index, content);
    }
    return this;
  }
  
  public int size()
  {
    return m_contents.size();
  }
  
  public IElement setText(String text, boolean nbsp)
  {
    if (text != null)
    {
      m_contents.clear();
      m_contents.add(new Text(text, nbsp));
    }
    return this;
  }
  
  IElement$Factory$ElementImpl(Tag tag, AttributeSet attrs)
  {
    super(tag, attrs);
    
    m_contents = new ArrayList();
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.IElement.Factory.ElementImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public abstract class IElement$Factory
{
  public static IElement create(Tag tag)
  {
    return new ElementImpl(tag, AttributeSet.create());
  }
  
  public static IElement create(Tag tag, AttributeSet attrs)
  {
    return new ElementImpl(tag, attrs);
  }
  
  static class ElementImpl
    extends ISimpleElement.Factory.SimpleElementImpl
    implements IElement
  {
    protected final List m_contents;
    private static final boolean DEBUG_HTML = false;
    
    public String toString()
    {
      return "<" + m_tag.getName() + ">";
    }
    
    public void emit(HTMLWriter out)
    {
      String tagName = m_tag.getName();
      
      out.write('<');
      out.write(tagName);
      if (!m_attrs.isEmpty())
      {
        out.write(' ');
        m_attrs.emit(out);
      }
      out.write('>');
      for (Iterator c = m_contents.iterator(); c.hasNext();)
      {
        IContent content = (IContent)c.next();
        content.emit(out);
      }
      out.write("</");
      out.write(tagName);
      out.write('>');
    }
    
    public IElementList add(IContent content)
    {
      if (content != null) {
        m_contents.add(content);
      }
      return this;
    }
    
    public IElementList add(int index, IContent content)
    {
      if (content != null) {
        m_contents.add(index, content);
      }
      return this;
    }
    
    public int size()
    {
      return m_contents.size();
    }
    
    public IElement setText(String text, boolean nbsp)
    {
      if (text != null)
      {
        m_contents.clear();
        m_contents.add(new Text(text, nbsp));
      }
      return this;
    }
    
    ElementImpl(Tag tag, AttributeSet attrs)
    {
      super(attrs);
      
      m_contents = new ArrayList();
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.IElement.Factory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public abstract interface IElement
  extends ISimpleElement, IElementList
{
  public abstract IElement setText(String paramString, boolean paramBoolean);
  
  public static abstract class Factory
  {
    public static IElement create(Tag tag)
    {
      return new ElementImpl(tag, AttributeSet.create());
    }
    
    public static IElement create(Tag tag, AttributeSet attrs)
    {
      return new ElementImpl(tag, attrs);
    }
    
    static class ElementImpl
      extends ISimpleElement.Factory.SimpleElementImpl
      implements IElement
    {
      protected final List m_contents;
      private static final boolean DEBUG_HTML = false;
      
      public String toString()
      {
        return "<" + m_tag.getName() + ">";
      }
      
      public void emit(HTMLWriter out)
      {
        String tagName = m_tag.getName();
        
        out.write('<');
        out.write(tagName);
        if (!m_attrs.isEmpty())
        {
          out.write(' ');
          m_attrs.emit(out);
        }
        out.write('>');
        for (Iterator c = m_contents.iterator(); c.hasNext();)
        {
          IContent content = (IContent)c.next();
          content.emit(out);
        }
        out.write("</");
        out.write(tagName);
        out.write('>');
      }
      
      public IElementList add(IContent content)
      {
        if (content != null) {
          m_contents.add(content);
        }
        return this;
      }
      
      public IElementList add(int index, IContent content)
      {
        if (content != null) {
          m_contents.add(index, content);
        }
        return this;
      }
      
      public int size()
      {
        return m_contents.size();
      }
      
      public IElement setText(String text, boolean nbsp)
      {
        if (text != null)
        {
          m_contents.clear();
          m_contents.add(new Text(text, nbsp));
        }
        return this;
      }
      
      ElementImpl(Tag tag, AttributeSet attrs)
      {
        super(attrs);
        
        m_contents = new ArrayList();
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.IElement
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

public abstract interface IElementList
  extends IContent
{
  public abstract IElementList add(IContent paramIContent);
  
  public abstract IElementList add(int paramInt, IContent paramIContent);
  
  public abstract int size();
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.IElementList
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

class ISimpleElement$Factory$SimpleElementImpl
  implements ISimpleElement
{
  protected final Tag m_tag;
  protected final AttributeSet m_attrs;
  
  public String toString()
  {
    return "<" + m_tag.getName() + "/>";
  }
  
  public Tag getTag()
  {
    return m_tag;
  }
  
  public ISimpleElement setClass(String classID)
  {
    if ((classID != null) && (classID.length() > 0)) {
      getAttributes().set(Attribute.CLASS, classID);
    }
    return this;
  }
  
  public AttributeSet getAttributes()
  {
    return m_attrs;
  }
  
  public void emit(HTMLWriter out)
  {
    out.write('<');
    out.write(m_tag.getName());
    if (!m_attrs.isEmpty())
    {
      out.write(' ');
      m_attrs.emit(out);
    }
    out.write("/>");
  }
  
  ISimpleElement$Factory$SimpleElementImpl(Tag tag, AttributeSet attrs)
  {
    m_tag = tag;
    m_attrs = attrs;
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.ISimpleElement.Factory.SimpleElementImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

public abstract class ISimpleElement$Factory
{
  public static ISimpleElement create(Tag tag)
  {
    return new SimpleElementImpl(tag, AttributeSet.create());
  }
  
  public static ISimpleElement create(Tag tag, AttributeSet attrs)
  {
    return new SimpleElementImpl(tag, attrs);
  }
  
  static class SimpleElementImpl
    implements ISimpleElement
  {
    protected final Tag m_tag;
    protected final AttributeSet m_attrs;
    
    public String toString()
    {
      return "<" + m_tag.getName() + "/>";
    }
    
    public Tag getTag()
    {
      return m_tag;
    }
    
    public ISimpleElement setClass(String classID)
    {
      if ((classID != null) && (classID.length() > 0)) {
        getAttributes().set(Attribute.CLASS, classID);
      }
      return this;
    }
    
    public AttributeSet getAttributes()
    {
      return m_attrs;
    }
    
    public void emit(HTMLWriter out)
    {
      out.write('<');
      out.write(m_tag.getName());
      if (!m_attrs.isEmpty())
      {
        out.write(' ');
        m_attrs.emit(out);
      }
      out.write("/>");
    }
    
    SimpleElementImpl(Tag tag, AttributeSet attrs)
    {
      m_tag = tag;
      m_attrs = attrs;
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.ISimpleElement.Factory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

public abstract interface ISimpleElement
  extends IContent
{
  public abstract Tag getTag();
  
  public abstract ISimpleElement setClass(String paramString);
  
  public abstract AttributeSet getAttributes();
  
  public static abstract class Factory
  {
    public static ISimpleElement create(Tag tag)
    {
      return new SimpleElementImpl(tag, AttributeSet.create());
    }
    
    public static ISimpleElement create(Tag tag, AttributeSet attrs)
    {
      return new SimpleElementImpl(tag, attrs);
    }
    
    static class SimpleElementImpl
      implements ISimpleElement
    {
      protected final Tag m_tag;
      protected final AttributeSet m_attrs;
      
      public String toString()
      {
        return "<" + m_tag.getName() + "/>";
      }
      
      public Tag getTag()
      {
        return m_tag;
      }
      
      public ISimpleElement setClass(String classID)
      {
        if ((classID != null) && (classID.length() > 0)) {
          getAttributes().set(Attribute.CLASS, classID);
        }
        return this;
      }
      
      public AttributeSet getAttributes()
      {
        return m_attrs;
      }
      
      public void emit(HTMLWriter out)
      {
        out.write('<');
        out.write(m_tag.getName());
        if (!m_attrs.isEmpty())
        {
          out.write(' ');
          m_attrs.emit(out);
        }
        out.write("/>");
      }
      
      SimpleElementImpl(Tag tag, AttributeSet attrs)
      {
        m_tag = tag;
        m_attrs = attrs;
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.ISimpleElement
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

final class Tag$TagImpl
  extends Tag
{
  private final String m_name;
  
  public void emit(HTMLWriter out)
  {
    out.write(m_name);
  }
  
  public String getName()
  {
    return m_name;
  }
  
  public String toString()
  {
    return m_name;
  }
  
  Tag$TagImpl(String name)
  {
    m_name = name;
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.Tag.TagImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

public abstract class Tag
  implements IContent
{
  public static final Tag HTML = new TagImpl("HTML");
  public static final Tag HEAD = new TagImpl("HEAD");
  public static final Tag BODY = new TagImpl("BODY");
  public static final Tag META = new TagImpl("META");
  public static final Tag STYLE = new TagImpl("STYLE");
  public static final Tag TITLE = new TagImpl("TITLE");
  public static final Tag H1 = new TagImpl("H1");
  public static final Tag H2 = new TagImpl("H2");
  public static final Tag H3 = new TagImpl("H3");
  public static final Tag H4 = new TagImpl("H4");
  public static final Tag H5 = new TagImpl("H5");
  public static final Tag H6 = new TagImpl("H6");
  public static final Tag LINK = new TagImpl("LINK");
  public static final Tag A = new TagImpl("A");
  public static final Tag TABLE = new TagImpl("TABLE");
  public static final Tag CAPTION = new TagImpl("CAPTION");
  public static final Tag TH = new TagImpl("TH");
  public static final Tag TR = new TagImpl("TR");
  public static final Tag TD = new TagImpl("TD");
  public static final Tag HR = new TagImpl("HR");
  public static final Tag P = new TagImpl("P");
  public static final Tag SPAN = new TagImpl("SPAN");
  public static final Tag[] Hs = { H1, H2, H3, H4, H4, H6 };
  
  public abstract String getName();
  
  private static final class TagImpl
    extends Tag
  {
    private final String m_name;
    
    public void emit(HTMLWriter out)
    {
      out.write(m_name);
    }
    
    public String getName()
    {
      return m_name;
    }
    
    public String toString()
    {
      return m_name;
    }
    
    TagImpl(String name)
    {
      m_name = name;
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.Tag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

import com.vladium.util.Strings;

public final class Text
  implements IContent
{
  private final String m_text;
  private final boolean m_nbsp;
  
  public Text(String text, boolean nbsp)
  {
    m_text = text;
    m_nbsp = nbsp;
  }
  
  public void emit(HTMLWriter out)
  {
    if (m_text != null) {
      if (m_nbsp) {
        out.write(Strings.HTMLEscapeSP(m_text));
      } else {
        out.write(Strings.HTMLEscape(m_text));
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.Text
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.html.doc;

public final class TextContent
  implements IContent
{
  private final String m_text;
  
  public TextContent(String text)
  {
    m_text = text;
  }
  
  public void emit(HTMLWriter out)
  {
    if (m_text != null) {
      out.write(m_text);
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.html.doc.TextContent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report;

import com.vladium.emma.Command;
import com.vladium.emma.EMMARuntimeException;
import com.vladium.util.ClassLoaderResolver;
import com.vladium.util.Strings;
import com.vladium.util.args.IOptsParser;
import com.vladium.util.args.IOptsParser.IOpt;
import com.vladium.util.args.IOptsParser.IOpts;
import java.io.IOException;

public final class reportCommand
  extends Command
{
  private String[] m_datapath;
  private String[] m_srcpath;
  private String[] m_reportTypes;
  
  public reportCommand(String usageToolName, String[] args)
  {
    super(usageToolName, args);
  }
  
  public synchronized void run()
  {
    ClassLoader loader;
    try
    {
      loader = ClassLoaderResolver.getClassLoader();
    }
    catch (Throwable t)
    {
      ClassLoader loader;
      loader = getClass().getClassLoader();
    }
    try
    {
      IOptsParser parser = getOptParser(loader);
      IOptsParser.IOpts parsedopts = parser.parse(m_args);
      
      int usageRequestLevel = parsedopts.usageRequestLevel();
      if (usageRequestLevel > 0)
      {
        usageexit(parser, usageRequestLevel, null);
        return;
      }
      IOptsParser.IOpt[] opts = parsedopts.getOpts();
      if (opts == null)
      {
        parsedopts.error(m_out, 80);
        usageexit(parser, 1, null);
        return;
      }
      try
      {
        for (int o = 0; o < opts.length; o++)
        {
          IOptsParser.IOpt opt = opts[o];
          String on = opt.getCanonicalName();
          if (!processOpt(opt)) {
            if ("in".equals(on)) {
              m_datapath = getListOptValue(opt, PATH_DELIMITERS, true);
            } else if ("sp".equals(on)) {
              m_srcpath = getListOptValue(opt, PATH_DELIMITERS, true);
            } else if ("r".equals(on)) {
              m_reportTypes = Strings.merge(opt.getValues(), ", \t\r\n", true);
            }
          }
        }
        if (!processFilePropertyOverrides()) {
          return;
        }
        processCmdPropertyOverrides(parsedopts);
      }
      catch (IOException ioe)
      {
        throw new EMMARuntimeException("ARGS_IO_FAILURE", ioe);
      }
      ReportProcessor processor = ReportProcessor.create();
      processor.setAppName("EMMA");
      
      processor.setDataPath(m_datapath);
      processor.setSourcePath(m_srcpath);
      
      processor.setReportTypes(m_reportTypes);
      processor.setPropertyOverrides(m_propertyOverrides);
      
      processor.run();
    }
    catch (EMMARuntimeException yre)
    {
      exit(true, yre.getMessage(), yre, 2);
      return;
    }
    catch (Throwable t)
    {
      exit(true, "unexpected failure: ", t, 2);
      return;
    }
    exit(false, null, null, 0);
  }
  
  protected void initialize()
  {
    super.initialize();
  }
  
  protected String usageArgsMsg()
  {
    return "[options]";
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.reportCommand
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.txt;

import com.vladium.emma.EMMAProperties;
import com.vladium.emma.EMMARuntimeException;
import com.vladium.emma.IAppErrorCodes;
import com.vladium.emma.data.ICoverageData;
import com.vladium.emma.data.IMetaData;
import com.vladium.emma.report.AbstractReportGenerator;
import com.vladium.emma.report.AllItem;
import com.vladium.emma.report.ClassItem;
import com.vladium.emma.report.IItem;
import com.vladium.emma.report.IItemAttribute;
import com.vladium.emma.report.IItemMetadata;
import com.vladium.emma.report.IReportDataView;
import com.vladium.emma.report.ItemComparator;
import com.vladium.emma.report.MethodItem;
import com.vladium.emma.report.PackageItem;
import com.vladium.emma.report.ReportProperties.ParsedProperties;
import com.vladium.emma.report.SourcePathCache;
import com.vladium.emma.report.SrcFileItem;
import com.vladium.logging.Logger;
import com.vladium.util.Files;
import com.vladium.util.IProperties;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;

public final class ReportGenerator
  extends AbstractReportGenerator
  implements IAppErrorCodes
{
  public String getType()
  {
    return "txt";
  }
  
  public void process(IMetaData mdata, ICoverageData cdata, SourcePathCache cache, IProperties properties)
    throws EMMARuntimeException
  {
    initialize(mdata, cdata, cache, properties);
    
    long start = 0L;
    boolean trace1 = m_log.atTRACE1();
    if (trace1) {
      start = System.currentTimeMillis();
    }
    m_queue = new LinkedList();
    for (m_queue.add(m_view.getRoot()); !m_queue.isEmpty();)
    {
      IItem head = (IItem)m_queue.removeFirst();
      
      head.accept(this, null);
    }
    line();
    
    close();
    if (trace1)
    {
      long end = System.currentTimeMillis();
      
      m_log.trace1("process", "[" + getType() + "] report generated in " + (end - start) + " ms");
    }
  }
  
  public void cleanup()
  {
    m_queue = null;
    close();
    
    super.cleanup();
  }
  
  public Object visit(AllItem item, Object ctx)
  {
    File outFile = m_settings.getOutFile();
    if (outFile == null)
    {
      outFile = new File("coverage.txt");
      m_settings.setOutFile(outFile);
    }
    File fullOutFile = Files.newFile(m_settings.getOutDir(), outFile);
    
    m_log.info("writing [" + getType() + "] report to [" + fullOutFile.getAbsolutePath() + "] ...");
    
    openOutFile(fullOutFile, m_settings.getOutEncoding(), true);
    try
    {
      StringBuffer label = new StringBuffer(101);
      
      label.append("[");
      label.append("EMMA");
      label.append(" v");label.append("2.0.5312");
      label.append(" report, generated ");
      label.append(new Date(EMMAProperties.getTimeStamp()));
      label.append("]");
      
      m_out.write(label.toString());
      m_out.newLine();
      
      m_out.flush();
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
    int[] columns = m_settings.getColumnOrder();
    
    line();
    
    addTitleRow("OVERALL COVERAGE SUMMARY", 0, 1);
    
    addHeaderRow(item, columns);
    
    addItemRow(item, columns);
    
    addTitleRow("OVERALL STATS SUMMARY", 1, 1);
    
    row("total packages:" + m_separator + item.getChildCount());
    row("total classes:" + m_separator + item.getAggregate(11));
    row("total methods:" + m_separator + item.getAggregate(10));
    if ((m_srcView) && (m_hasSrcFileInfo))
    {
      row("total executable files:" + m_separator + item.getAggregate(12));
      if (m_hasLineNumberInfo) {
        row("total executable lines:" + m_separator + item.getAggregate(7));
      }
    }
    boolean deeper = m_settings.getDepth() > item.getMetadata().getTypeID();
    
    addTitleRow("COVERAGE BREAKDOWN BY PACKAGE", 1, 1);
    
    boolean headerDone = false;
    ItemComparator order = m_typeSortComparators[PackageItem.getTypeMetadata().getTypeID()];
    for (Iterator packages = item.getChildren(order); packages.hasNext();)
    {
      IItem pkg = (IItem)packages.next();
      if (!headerDone)
      {
        addHeaderRow(pkg, columns);
        headerDone = true;
      }
      addItemRow(pkg, columns);
      if (deeper) {
        m_queue.addLast(pkg);
      }
    }
    return ctx;
  }
  
  public Object visit(PackageItem item, Object ctx)
  {
    if (m_verbose) {
      m_log.verbose("  report: processing package [" + item.getName() + "] ...");
    }
    int[] columns = m_settings.getColumnOrder();
    
    line();
    
    addTitleRow("COVERAGE SUMMARY FOR PACKAGE [".concat(item.getName()).concat("]"), 0, 1);
    
    addHeaderRow(item, columns);
    
    addItemRow(item, columns);
    
    boolean deeper = m_settings.getDepth() > item.getMetadata().getTypeID();
    
    String summaryTitle = m_srcView ? "COVERAGE BREAKDOWN BY SOURCE FILE" : "COVERAGE BREAKDOWN BY CLASS";
    addTitleRow(summaryTitle, 1, 1);
    
    boolean headerDone = false;
    ItemComparator order = m_typeSortComparators[ClassItem.getTypeMetadata().getTypeID()];
    for (Iterator srcORclsFiles = item.getChildren(order); srcORclsFiles.hasNext();)
    {
      IItem srcORcls = (IItem)srcORclsFiles.next();
      if (!headerDone)
      {
        addHeaderRow(srcORcls, columns);
        headerDone = true;
      }
      addItemRow(srcORcls, columns);
      if (deeper) {
        m_queue.addLast(srcORcls);
      }
    }
    return ctx;
  }
  
  public Object visit(SrcFileItem item, Object ctx)
  {
    int[] columns = m_settings.getColumnOrder();
    
    line();
    
    addTitleRow("COVERAGE SUMMARY FOR SOURCE FILE [".concat(item.getName()).concat("]"), 0, 1);
    
    addHeaderRow(item, columns);
    
    addItemRow(item, columns);
    
    addTitleRow("COVERAGE BREAKDOWN BY CLASS AND METHOD", 1, 1);
    
    boolean headerDone = false;
    ItemComparator order = m_typeSortComparators[ClassItem.getTypeMetadata().getTypeID()];
    for (Iterator classes = item.getChildren(order); classes.hasNext();)
    {
      IItem cls = (IItem)classes.next();
      if (!headerDone)
      {
        addHeaderRow(cls, columns);
        headerDone = true;
      }
      addTitleRow("class [" + cls.getName() + "] methods", 0, 0);
      
      ItemComparator order2 = m_typeSortComparators[MethodItem.getTypeMetadata().getTypeID()];
      for (methods = cls.getChildren(order2); methods.hasNext();)
      {
        MethodItem method = (MethodItem)methods.next();
        
        addItemRow(method, columns);
      }
    }
    Iterator methods;
    return ctx;
  }
  
  public Object visit(ClassItem item, Object ctx)
  {
    int[] columns = m_settings.getColumnOrder();
    
    line();
    
    addTitleRow("COVERAGE SUMMARY FOR CLASS [".concat(item.getName()).concat("]"), 0, 1);
    
    addHeaderRow(item, columns);
    
    addItemRow(item, columns);
    
    addTitleRow("COVERAGE BREAKDOWN BY METHOD", 1, 1);
    
    ItemComparator order = m_typeSortComparators[MethodItem.getTypeMetadata().getTypeID()];
    for (Iterator methods = item.getChildren(order); methods.hasNext();)
    {
      IItem method = (IItem)methods.next();
      
      addItemRow(method, columns);
    }
    return ctx;
  }
  
  private void addTitleRow(String text, int hlines, int flines)
  {
    for (int i = 0; i < hlines; i++) {
      eol();
    }
    row(new StringBuffer(text).append(":"));
    for (int i = 0; i < flines; i++) {
      eol();
    }
  }
  
  private void addHeaderRow(IItem item, int[] columns)
  {
    StringBuffer buf = new StringBuffer();
    
    int c = 0;
    for (int cLimit = columns.length; c < cLimit; c++)
    {
      int attrID = columns[c];
      IItemAttribute attr = item.getAttribute(attrID, m_settings.getUnitsType());
      if (attr != null)
      {
        buf.append('[');
        buf.append(attr.getName());
        buf.append(']');
      }
      if (c != cLimit - 1) {
        buf.append(m_separator);
      }
    }
    row(buf);
  }
  
  private void addItemRow(IItem item, int[] columns)
  {
    StringBuffer buf = new StringBuffer(11);
    
    int c = 0;
    for (int cLimit = columns.length; c < cLimit; c++)
    {
      int attrID = columns[c];
      IItemAttribute attr = item.getAttribute(attrID, m_settings.getUnitsType());
      if (attr != null)
      {
        boolean fail = (m_metrics[attrID] > 0) && (!attr.passes(item, m_metrics[attrID]));
        if (fail)
        {
          attr.format(item, buf);
          buf.append('!');
        }
        else
        {
          attr.format(item, buf);
        }
      }
      if (c != cLimit - 1) {
        buf.append(m_separator);
      }
    }
    row(buf);
  }
  
  private void row(StringBuffer str)
  {
    try
    {
      m_out.write(str.toString());
      m_out.newLine();
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
  }
  
  private void row(String str)
  {
    try
    {
      m_out.write(str);
      m_out.newLine();
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
  }
  
  private void line()
  {
    try
    {
      m_out.write("-------------------------------------------------------------------------------");
      m_out.newLine();
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
  }
  
  private void eol()
  {
    try
    {
      m_out.newLine();
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
  }
  
  private void close()
  {
    if (m_out != null) {
      try
      {
        m_out.flush();
        m_out.close();
      }
      catch (IOException ioe)
      {
        throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
      }
      finally
      {
        m_out = null;
      }
    }
  }
  
  private void openOutFile(File file, String encoding, boolean mkdirs)
  {
    try
    {
      if (mkdirs)
      {
        File parent = file.getParentFile();
        if (parent != null) {
          parent.mkdirs();
        }
      }
      m_out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding), 32768);
    }
    catch (UnsupportedEncodingException uee)
    {
      throw new EMMARuntimeException(uee);
    }
    catch (IOException fnfe)
    {
      throw new EMMARuntimeException(fnfe);
    }
  }
  
  private char m_separator = '\t';
  private LinkedList m_queue;
  private BufferedWriter m_out;
  private static final String TYPE = "txt";
  private static final String LINE = "-------------------------------------------------------------------------------";
  private static final int IO_BUF_SIZE = 32768;
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.txt.ReportGenerator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.xml;

import com.vladium.util.IConstants;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Writer;

final class ReportGenerator$IndentingWriter
  extends BufferedWriter
{
  private int m_indent;
  private int m_state;
  private transient String m_sindent;
  private static final int INDENT_INCREMENT = 2;
  
  public void newLine()
    throws IOException
  {
    m_state = 0;
    super.write(IConstants.EOL, 0, IConstants.EOL.length());
  }
  
  public void write(char[] cbuf, int off, int len)
    throws IOException
  {
    indent();
    super.write(cbuf, off, len);
  }
  
  public void write(int c)
    throws IOException
  {
    indent();
    super.write(c);
  }
  
  public void write(String s, int off, int len)
    throws IOException
  {
    indent();
    super.write(s, off, len);
  }
  
  ReportGenerator$IndentingWriter(Writer out, int buffer, int indent)
  {
    super(out, buffer);
    m_indent = indent;
  }
  
  void incIndent(int delta)
  {
    if (delta < 0) {
      throw new IllegalArgumentException("delta be non-negative: " + delta);
    }
    m_indent += delta;
  }
  
  void incIndent()
  {
    incIndent(2);
  }
  
  void decIndent(int delta)
  {
    if (delta < 0) {
      throw new IllegalArgumentException("delta be non-negative: " + delta);
    }
    if (delta > m_indent) {
      throw new IllegalArgumentException("delta = " + delta + ", current indent = " + m_indent);
    }
    m_indent -= delta;
  }
  
  void decIndent()
  {
    decIndent(2);
  }
  
  String getIndent()
  {
    if (m_indent <= 0) {
      return "";
    }
    if ((m_sindent == null) || (m_sindent.length() < m_indent))
    {
      char[] ca = new char[m_indent];
      for (int i = 0; i < m_indent; i++) {
        ca[i] = ' ';
      }
      m_sindent = new String(ca);
      
      return m_sindent;
    }
    return m_sindent.substring(0, m_indent);
  }
  
  private void indent()
    throws IOException
  {
    if (m_state == 0)
    {
      String indent = getIndent();
      super.write(indent, 0, indent.length());
      
      m_state = 1;
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.report.xml.ReportGenerator.IndentingWriter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.report.xml;

import com.vladium.emma.EMMAProperties;
import com.vladium.emma.EMMARuntimeException;
import com.vladium.emma.IAppErrorCodes;
import com.vladium.emma.data.ICoverageData;
import com.vladium.emma.data.IMetaData;
import com.vladium.emma.report.AbstractReportGenerator;
import com.vladium.emma.report.AllItem;
import com.vladium.emma.report.ClassItem;
import com.vladium.emma.report.IItem;
import com.vladium.emma.report.IItemAttribute;
import com.vladium.emma.report.IItemMetadata;
import com.vladium.emma.report.IReportDataView;
import com.vladium.emma.report.ItemComparator;
import com.vladium.emma.report.MethodItem;
import com.vladium.emma.report.PackageItem;
import com.vladium.emma.report.ReportProperties.ParsedProperties;
import com.vladium.emma.report.SourcePathCache;
import com.vladium.emma.report.SrcFileItem;
import com.vladium.logging.Logger;
import com.vladium.util.Files;
import com.vladium.util.IConstants;
import com.vladium.util.IProperties;
import com.vladium.util.Strings;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.Date;
import java.util.Iterator;

public final class ReportGenerator
  extends AbstractReportGenerator
  implements IAppErrorCodes
{
  private IndentingWriter m_out;
  private static final String TYPE = "xml";
  private static final int IO_BUF_SIZE = 65536;
  
  public String getType()
  {
    return "xml";
  }
  
  public void process(IMetaData mdata, ICoverageData cdata, SourcePathCache cache, IProperties properties)
    throws EMMARuntimeException
  {
    initialize(mdata, cdata, cache, properties);
    
    long start = 0L;
    boolean trace1 = m_log.atTRACE1();
    if (trace1) {
      start = System.currentTimeMillis();
    }
    m_view.getRoot().accept(this, null);
    close();
    if (trace1)
    {
      long end = System.currentTimeMillis();
      
      m_log.trace1("process", "[" + getType() + "] report generated in " + (end - start) + " ms");
    }
  }
  
  public void cleanup()
  {
    close();
    
    super.cleanup();
  }
  
  public Object visit(AllItem item, Object ctx)
  {
    try
    {
      File outFile = m_settings.getOutFile();
      if (outFile == null)
      {
        outFile = new File("coverage.xml");
        m_settings.setOutFile(outFile);
      }
      File fullOutFile = Files.newFile(m_settings.getOutDir(), outFile);
      
      m_log.info("writing [" + getType() + "] report to [" + fullOutFile.getAbsolutePath() + "] ...");
      
      openOutFile(fullOutFile, m_settings.getOutEncoding(), true);
      
      m_out.write("<?xml version=\"1.0\" encoding=\"" + m_settings.getOutEncoding() + "\"?>");
      try
      {
        StringBuffer label = new StringBuffer(101);
        
        label.append("<!-- ");
        label.append("EMMA");
        label.append(" v");label.append("2.0.5312");
        label.append(" report, generated ");
        label.append(new Date(EMMAProperties.getTimeStamp()));
        label.append(" -->");
        
        m_out.write(label.toString());
        m_out.newLine();
        
        m_out.flush();
      }
      catch (IOException ioe)
      {
        throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
      }
      eol();
      openElementTag("report");
      closeElementTag(false);
      m_out.incIndent();
      
      eol();
      openElementTag("stats");
      closeElementTag(false);
      m_out.incIndent();
      
      emitStatsCount("packages", item.getChildCount());
      emitStatsCount("classes", item.getAggregate(11));
      emitStatsCount("methods", item.getAggregate(10));
      if ((m_srcView) && (m_hasSrcFileInfo))
      {
        emitStatsCount("srcfiles", item.getAggregate(12));
        if (m_hasLineNumberInfo) {
          emitStatsCount("srclines", item.getAggregate(7));
        }
      }
      m_out.decIndent();
      eol();
      endElement("stats");
      
      eol();
      openElementTag("data");
      closeElementTag(false);
      m_out.incIndent();
      
      ItemComparator childrenOrder = m_typeSortComparators[PackageItem.getTypeMetadata().getTypeID()];
      emitItem(item, childrenOrder);
      
      m_out.decIndent();
      eol();
      endElement("data");
      
      m_out.decIndent();
      eol();
      endElement("report");
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
    return ctx;
  }
  
  public Object visit(PackageItem item, Object ctx)
  {
    if (m_verbose) {
      m_log.verbose("  report: processing package [" + item.getName() + "] ...");
    }
    try
    {
      ItemComparator childrenOrder = m_typeSortComparators[ClassItem.getTypeMetadata().getTypeID()];
      emitItem(item, childrenOrder);
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
    return ctx;
  }
  
  public Object visit(SrcFileItem item, Object ctx)
  {
    try
    {
      ItemComparator childrenOrder = m_typeSortComparators[ClassItem.getTypeMetadata().getTypeID()];
      emitItem(item, childrenOrder);
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
    return ctx;
  }
  
  public Object visit(ClassItem item, Object ctx)
  {
    try
    {
      ItemComparator childrenOrder = m_typeSortComparators[MethodItem.getTypeMetadata().getTypeID()];
      emitItem(item, childrenOrder);
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
    return ctx;
  }
  
  public Object visit(MethodItem item, Object ctx)
  {
    try
    {
      emitItem(item, null);
    }
    catch (IOException ioe)
    {
      throw new EMMARuntimeException("REPORT_IO_FAILURE", ioe);
    }
    return ctx;
  }
  
  private static final class IndentingWriter
    extends BufferedWriter
  {
    private int m_indent;
    private int m_state;
    private transient String m_sindent;
    private static final int INDENT_INCREMENT = 2;
    
    public void newLine()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd