/** Copyright (c) 2007 Ricebridge. BSD License. */ package com.ricebridge.example.updown; import java.util.Properties; import com.ricebridge.csvman.CsvSpec; /** Setup the CSV format using a set of properties. * The properties are populated from HTML form values. */ public class CsvSpecHandler { /** Only the field separator is supported, but you can easily extend this * method to handle other settings in the CsvSpec class. */ public static CsvSpec makeCsvSpec( Properties pProperties ) { CsvSpec csvspec = new CsvSpec(); // set these so that we can keep processing data even if there are some // errors - we'll collect the errors and report them later csvspec.setIgnoreBadLines(true); csvspec.setIgnoreEmptyLines(true); String sep = pProperties.getProperty("Separator"); if( null != sep && !"".equals(sep) ) { csvspec.setSeparator(sep); } return csvspec; } }