Clover coverage report - Maven Clover report
Coverage timestamp: Sun Jan 3 2010 19:08:46 CET
file stats: LOC: 96   Methods: 7
NCLOC: 41   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CsvView.java 50% 90% 100% 89.5%
coverage coverage
 1    /**
 2    * Licensed under the Artistic License; you may not use this file
 3    * except in compliance with the License.
 4    * You may obtain a copy of the License at
 5    *
 6    * http://displaytag.sourceforge.net/license.html
 7    *
 8    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
 9    * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 10    * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 11    */
 12    package org.displaytag.export;
 13   
 14    import org.apache.commons.lang.StringUtils;
 15    import org.displaytag.model.TableModel;
 16   
 17   
 18    /**
 19    * Export view for comma separated value exporting.
 20    * @author Fabrizio Giustina
 21    * @version $Revision: 1081 $ ($Author: fgiust $)
 22    */
 23    public class CsvView extends BaseExportView
 24    {
 25   
 26    /**
 27    * @see org.displaytag.export.BaseExportView#setParameters(TableModel, boolean, boolean, boolean)
 28    */
 29  18 public void setParameters(TableModel tableModel, boolean exportFullList, boolean includeHeader,
 30    boolean decorateValues)
 31    {
 32  18 super.setParameters(tableModel, exportFullList, includeHeader, decorateValues);
 33    }
 34   
 35    /**
 36    * @see org.displaytag.export.BaseExportView#getRowEnd()
 37    */
 38  18 protected String getRowEnd()
 39    {
 40  18 return "\n"; //$NON-NLS-1$
 41    }
 42   
 43    /**
 44    * @see org.displaytag.export.BaseExportView#getCellEnd()
 45    */
 46  18 protected String getCellEnd()
 47    {
 48  18 return ","; //$NON-NLS-1$
 49    }
 50   
 51    /**
 52    * @see org.displaytag.export.BaseExportView#getAlwaysAppendCellEnd()
 53    */
 54  18 protected boolean getAlwaysAppendCellEnd()
 55    {
 56  18 return false;
 57    }
 58   
 59    /**
 60    * @see org.displaytag.export.BaseExportView#getAlwaysAppendRowEnd()
 61    */
 62  18 protected boolean getAlwaysAppendRowEnd()
 63    {
 64  18 return true;
 65    }
 66   
 67    /**
 68    * @see org.displaytag.export.ExportView#getMimeType()
 69    */
 70  18 public String getMimeType()
 71    {
 72  18 return "text/csv"; //$NON-NLS-1$
 73    }
 74   
 75    /**
 76    * Escaping for csv format.
 77    * <ul>
 78    * <li>Quotes inside quoted strings are escaped with a /</li>
 79    * <li>Fields containings newlines or , are surrounded by "</li>
 80    * </ul>
 81    * Note this is the standard CVS format and it's not handled well by excel.
 82    * @see org.displaytag.export.BaseExportView#escapeColumnValue(java.lang.Object)
 83    */
 84  72 protected String escapeColumnValue(Object value)
 85    {
 86  72 String stringValue = StringUtils.trim(value.toString());
 87  72 if (!StringUtils.containsNone(stringValue, new char[]{'\n', ','}))
 88    {
 89  0 return "\"" + //$NON-NLS-1$
 90    StringUtils.replace(stringValue, "\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 91    }
 92   
 93  72 return stringValue;
 94    }
 95   
 96    }