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

com.github.mygreen.supercsv.cellprocessor.conversion.Trim Maven / Gradle / Ivy

Go to download

CSVのJavaライブラリであるSuperCSVに、アノテーション機能を追加したライブラリです。

There is a newer version: 2.3
Show newest version
package com.github.mygreen.supercsv.cellprocessor.conversion;

import org.supercsv.cellprocessor.CellProcessorAdaptor;
import org.supercsv.cellprocessor.ift.StringCellProcessor;
import org.supercsv.util.CsvContext;


/**
 * 文字列をトリムするCellProcessor。
 * 

値がNullの時も処理を続行する

* * @since 1.0.2 * @author T.TSUCHIE * */ public class Trim extends CellProcessorAdaptor implements 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 {@literal if next is null} */ public Trim(final StringCellProcessor next) { super(next); } @SuppressWarnings("unchecked") public Object execute(final Object value, final CsvContext context) { if(value == null) { return next.execute(value, context); } final String result = value.toString().trim(); return next.execute(result, context); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy