Coverage Report - org.mule.management.stats.printers.CSVPrinter
 
Classes in this File Line Coverage Branch Coverage Complexity
CSVPrinter
0%
0/21
0%
0/8
1.8
 
 1  
 /*
 2  
  * $Id: CSVPrinter.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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 service stats in CSV format
 19  
  */
 20  
 public class CSVPrinter extends AbstractTablePrinter
 21  
 {
 22  0
     private String delim = ",";
 23  0
     private boolean printHeaders = true;
 24  
 
 25  
     public CSVPrinter(Writer out)
 26  
     {
 27  0
         super(out);
 28  0
     }
 29  
 
 30  
     public CSVPrinter(OutputStream out)
 31  
     {
 32  0
         super(out);
 33  0
     }
 34  
 
 35  
     public void print(Collection stats)
 36  
     {
 37  
         try
 38  
         {
 39  0
             String[][] table = getTable(stats);
 40  0
             int i = (printHeaders ? 0 : 1);
 41  0
             for (; i < table.length; i++)
 42  
             {
 43  0
                 for (int j = 0; j < table[0].length; j++)
 44  
                 {
 45  0
                     print(table[i][j]);
 46  0
                     if (j + 1 != table[i].length)
 47  
                     {
 48  0
                         print(delim);
 49  
                     }
 50  
                 }
 51  0
                 println();
 52  
             }
 53  
         }
 54  0
         catch (Throwable e)
 55  
         {
 56  
             // TODO MULE-863: Unlikely to be sufficient
 57  
             // (and nothing explicitly thrown above)
 58  0
             e.printStackTrace();
 59  0
         }
 60  0
     }
 61  
 
 62  
     public boolean isPrintHeaders()
 63  
     {
 64  0
         return printHeaders;
 65  
     }
 66  
 
 67  
     public void setPrintHeaders(boolean printHeaders)
 68  
     {
 69  0
         this.printHeaders = printHeaders;
 70  0
     }
 71  
 }