Example usage for org.apache.commons.csv CSVStrategy DEFAULT_STRATEGY

List of usage examples for org.apache.commons.csv CSVStrategy DEFAULT_STRATEGY

Introduction

In this page you can find the example usage for org.apache.commons.csv CSVStrategy DEFAULT_STRATEGY.

Prototype

CSVStrategy DEFAULT_STRATEGY

To view the source code for org.apache.commons.csv CSVStrategy DEFAULT_STRATEGY.

Click Source Link

Usage

From source file:com.griddynamics.jagger.xml.beanParsers.workload.queryProvider.CsvProviderDefinitionParser.java

@Override
protected void parse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    Preconditions.checkArgument(element.hasAttribute("path"));
    builder.addPropertyValue("path", element.getAttribute("path"));

    if (element.hasAttribute("readHeader")) {
        builder.addPropertyValue("readHeader", element.getAttribute("readHeader").equals("true"));
    }/* w w  w.ja  v a2s.  c o  m*/
    if (element.hasAttribute("strategy")) {
        if (element.getAttribute("strategy").equals("DEFAULT")) {
            builder.addPropertyValue("strategy", CSVStrategy.DEFAULT_STRATEGY);
        } else if (element.getAttribute("strategy").equals("EXCEL")) {
            builder.addPropertyValue("strategy", CSVStrategy.EXCEL_STRATEGY);
        } else if (element.getAttribute("strategy").equals("TDF")) {
            builder.addPropertyValue("strategy", CSVStrategy.TDF_STRATEGY);
        } else {
            throw new TechnicalException("Strategy '" + element.getAttribute("strategy") + "' not found!");
        }
    }
    List childes = parseCustomListElement(element, parserContext, builder.getBeanDefinition());
    Preconditions.checkState(childes != null, "Must specify objectCreator in CSVProvider");
    builder.addPropertyValue("objectCreator", childes.get(0));
}

From source file:org.apache.camel.dataformat.csv.CsvUnmarshalPipeDelimiterTest.java

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override//from  ww  w  .j a  v a2 s.  c  o m
        public void configure() throws Exception {
            CsvDataFormat csv = new CsvDataFormat();
            CSVStrategy strategy = CSVStrategy.DEFAULT_STRATEGY;
            strategy.setDelimiter('|');
            csv.setStrategy(strategy);

            // also possible
            // CsvDataFormat csv = new CsvDataFormat();
            // csv.setDelimiter("|");

            from("direct:start").unmarshal(csv).to("mock:result");
        }
    };
}