package org.supercsv.cellprocessor;

import org.supercsv.cellprocessor.ift.StringCellProcessor;
import org.supercsv.exception.SuperCSVException;
import org.supercsv.util.CSVContext;

public class StrReplace extends CellProcessorAdaptor {
private String searchText, replaceText;

public StrReplace(final String searchText, final String replaceText) {
	super();
	handleArguments(searchText, replaceText);
}

public StrReplace(final String searchText, final String replaceText, final StringCellProcessor next) {
	super(next);
	handleArguments(searchText, replaceText);
}

/**
 * {@inheritDoc}
 */
@Override
public Object execute(final Object value, final CSVContext context) throws SuperCSVException {
	return value.toString().replaceAll(searchText, replaceText);
}

private void handleArguments(final String searchText, final String replaceText) throws IllegalArgumentException {
	if( searchText == null ) { throw new SuperCSVException("argument searchText cannot be null"); }
	if( replaceText == null ) { throw new SuperCSVException("argument replaceText cannot be null"); }
	if( searchText.equals("") ) { throw new SuperCSVException(
		"argument searchText cannot be \"\" as this has no effect"); }
	this.searchText = searchText;
	this.replaceText = replaceText;
}
}

@@ -32,16 +32,250 @@
 sor;%0D%0A%0D%0A
+import org.supercsv.cellprocessor.ift.BoolCellProcessor;%0D%0Aimport org.supercsv.cellprocessor.ift.DateCellProcessor;%0D%0Aimport org.supercsv.cellprocessor.ift.DoubleCellProcessor;%0D%0Aimport org.supercsv.cellprocessor.ift.LongCellProcessor;%0D%0A
 import o
@@ -318,32 +318,83 @@
 CellProcessor;%0D%0A
+import org.supercsv.exception.NullInputException;%0D%0A
 import org.super
@@ -471,105 +471,477 @@
 %0D%0A%0D%0A
-public class StrReplace extends CellProcessorAdaptor %7B%0D%0Aprivate String searchText, replaceText;%0D%0A
+/**%0D%0A * String replacer.%0D%0A * @author Kasper B. Graversen%0D%0A * @author Dominique De Vito (ddv36a78@yahoo.fr)%0D%0A */%0D%0Apublic class StrReplace extends CellProcessorAdaptor implements BoolCellProcessor,%0D%0ADateCellProcessor, DoubleCellProcessor, LongCellProcessor, StringCellProcessor %7B%0D%0Aprivate String searchText, replaceText;%0D%0A%0D%0A/**%0D%0A * String replace%0D%0A * %0D%0A * @param searchText%0D%0A *            text to search for%0D%0A * @param replaceText%0D%0A *            text to replace with%0D%0A */
 %0D%0Apu
@@ -1349,34 +1349,109 @@
 xt) 
-throws SuperCSVException %7B
+%7B%0D%0A%09if (value == null) %7B%0D%0A%09%09throw new NullInputException(%22Input cannot be null%22, context, this); %0D%0A%09%7D
 %0D%0A%09r
@@ -1665,32 +1665,33 @@
 %7B throw new 
-SuperCSV
+NullInput
 Exception(%22a
@@ -1689,32 +1689,23 @@
 eption(%22
-argument 
 search
-T
+t
 ext cann
@@ -1707,32 +1707,38 @@
  cannot be null%22
+, this
 ); %7D%0D%0A%09if( repla
@@ -1762,32 +1762,33 @@
 %7B throw new 
-SuperCSV
+NullInput
 Exception(%22a
@@ -1790,25 +1790,17 @@
 on(%22
-argument 
 replace
-T
+tt
 ext 
@@ -1814,16 +1814,22 @@
 be null%22
+, this
 ); %7D%0D%0A%09i
@@ -1947,16 +1947,22 @@
  effect%22
+, this
 ); %7D%0D%0A%09t

add of the input value check into the execute() method + this class implements now all CellProcessor as it can accept (ans was accepting before) all kind of values as input.