All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.supercsv.ext.cellprocessor.Trim Maven / Gradle / Ivy

The newest version!
/*
 * Trim.java
 * created in 2013/04/19
 *
 * (C) Copyright 2003-2013 GreenDay Project. All rights reserved.
 */
package org.supercsv.ext.cellprocessor;

import org.supercsv.cellprocessor.ift.BoolCellProcessor;
import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.cellprocessor.ift.DateCellProcessor;
import org.supercsv.cellprocessor.ift.DoubleCellProcessor;
import org.supercsv.cellprocessor.ift.LongCellProcessor;
import org.supercsv.cellprocessor.ift.StringCellProcessor;
import org.supercsv.ext.exception.SuperCsvCellProcessorException;
import org.supercsv.util.CSVContext;


/**
 * Ensure that Strings or String-representations of objects are trimmed (contain no surrounding whitespace).
 * 

can be used {@link StringCellProcessor} but also{@link CellProcessor}. * * @version 1.1 * @since 1.0 * @author T.TSUCHIE * */ public class Trim extends ExtCellProcessorAdaptor implements BoolCellProcessor, DateCellProcessor, DoubleCellProcessor, LongCellProcessor, StringCellProcessor { /** * Constructs a new Trim processor, which trims a String to ensure it has no surrounding whitespace. */ public Trim() { super(); } /** * Constructs a new Trim processor, which trims a String to ensure it has no surrounding whitespace then * calls the next processor in the chain. * * @param next the next processor in the chain * @throws NullPointerException if next is null */ public Trim(final CellProcessor next) { super(next); } /** * {@inheritDoc} * * @throws SuperCsvCellProcessorException if value is null */ @Override public Object execute(final Object value, final CSVContext context) { validateInputNotNull(value, context); final String result = value.toString().trim(); return next.execute(result, context); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy