Coverage Report - org.mule.management.stats.printers.CSVPrinter
 
Classes in this File Line Coverage Branch Coverage Complexity
CSVPrinter
0%
0/21
0%
0/4
1.8
 
 1  
 /*
 2  
  * $Id: CSVPrinter.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.management.stats.printers;
 12  
 
 13  
 import java.io.OutputStream;
 14  
 import java.io.Writer;
 15  
 import java.util.Collection;
 16  
 
 17  
 /**
 18  
  * <code>CSVPrinter</code> prints component stats in CSV format
 19  
  * 
 20  
  * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
 21  
  * @version $Revision: 7976 $
 22  
  */
 23  
 public class CSVPrinter extends AbstractTablePrinter
 24  
 {
 25  0
     private String delim = ",";
 26  0
     private boolean printHeaders = true;
 27  
 
 28  
     public CSVPrinter(Writer out)
 29  
     {
 30  0
         super(out);
 31  0
     }
 32  
 
 33  
     public CSVPrinter(OutputStream out)
 34  
     {
 35  0
         super(out);
 36  0
     }
 37  
 
 38  
     public void print(Collection stats)
 39  
     {
 40  
         try
 41  
         {
 42  0
             String[][] table = getTable(stats);
 43  0
             int i = (printHeaders ? 0 : 1);
 44  0
             for (; i < table.length; i++)
 45  
             {
 46  0
                 for (int j = 0; j < table[0].length; j++)
 47  
                 {
 48  0
                     print(table[i][j]);
 49  0
                     if (j + 1 != table[i].length)
 50  
                     {
 51  0
                         print(delim);
 52  
                     }
 53  
                 }
 54  0
                 println();
 55  
             }
 56  
         }
 57  0
         catch (Throwable e)
 58  
         {
 59  
             // TODO MULE-863: Unlikely to be sufficient
 60  
             // (and nothing explicitly thrown above)
 61  0
             e.printStackTrace();
 62  0
         }
 63  0
     }
 64  
 
 65  
     public boolean isPrintHeaders()
 66  
     {
 67  0
         return printHeaders;
 68  
     }
 69  
 
 70  
     public void setPrintHeaders(boolean printHeaders)
 71  
     {
 72  0
         this.printHeaders = printHeaders;
 73  0
     }
 74  
 }