1 12 package org.displaytag.export; 13 14 import org.apache.commons.lang.StringUtils; 15 import org.displaytag.model.TableModel; 16 17 18 23 public class CsvView extends BaseExportView 24 { 25 26 29 public void setParameters(TableModel tableModel, boolean exportFullList, boolean includeHeader, 30 boolean decorateValues) 31 { 32 super.setParameters(tableModel, exportFullList, includeHeader, decorateValues); 33 } 34 35 38 protected String getRowEnd() 39 { 40 return "\n"; } 42 43 46 protected String getCellEnd() 47 { 48 return ","; } 50 51 54 protected boolean getAlwaysAppendCellEnd() 55 { 56 return false; 57 } 58 59 62 protected boolean getAlwaysAppendRowEnd() 63 { 64 return true; 65 } 66 67 70 public String getMimeType() 71 { 72 return "text/csv"; } 74 75 84 protected String escapeColumnValue(Object value) 85 { 86 String stringValue = StringUtils.trim(value.toString()); 87 if (!StringUtils.containsNone(stringValue, new char[]{'\n', ','})) 88 { 89 return "\"" + StringUtils.replace(stringValue, "\"", "\\\"") + "\""; } 92 93 return stringValue; 94 } 95 96 } 97 | Popular Tags |