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  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.management.stats.printers;
 8  
 
 9  
 import java.io.OutputStream;
 10  
 import java.io.Writer;
 11  
 import java.util.Collection;
 12  
 
 13  
 /**
 14  
  * <code>CSVPrinter</code> prints service stats in CSV format
 15  
  */
 16  
 public class CSVPrinter extends AbstractTablePrinter
 17  
 {
 18  0
     private String delim = ",";
 19  0
     private boolean printHeaders = true;
 20  
 
 21  
     public CSVPrinter(Writer out)
 22  
     {
 23  0
         super(out);
 24  0
     }
 25  
 
 26  
     public CSVPrinter(OutputStream out)
 27  
     {
 28  0
         super(out);
 29  0
     }
 30  
 
 31  
     public void print(Collection stats)
 32  
     {
 33  
         try
 34  
         {
 35  0
             String[][] table = getTable(stats);
 36  0
             int i = (printHeaders ? 0 : 1);
 37  0
             for (; i < table.length; i++)
 38  
             {
 39  0
                 for (int j = 0; j < table[0].length; j++)
 40  
                 {
 41  0
                     print(table[i][j]);
 42  0
                     if (j + 1 != table[i].length)
 43  
                     {
 44  0
                         print(delim);
 45  
                     }
 46  
                 }
 47  0
                 println();
 48  
             }
 49  
         }
 50  0
         catch (Throwable e)
 51  
         {
 52  
             // TODO MULE-863: Unlikely to be sufficient
 53  
             // (and nothing explicitly thrown above)
 54  0
             e.printStackTrace();
 55  0
         }
 56  0
     }
 57  
 
 58  
     public boolean isPrintHeaders()
 59  
     {
 60  0
         return printHeaders;
 61  
     }
 62  
 
 63  
     public void setPrintHeaders(boolean printHeaders)
 64  
     {
 65  0
         this.printHeaders = printHeaders;
 66  0
     }
 67  
 }