Fixed Issue 447: Extend toTitlecase() function with support for char[] delimiters in Apache WordUtils.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2247 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2011-09-19 09:48:37 +00:00
parent db3bbb5c86
commit 9111157172

View File

@ -44,6 +44,7 @@ import com.google.refine.grel.ControlFunctionRegistry;
import com.google.refine.grel.Function; import com.google.refine.grel.Function;
public class ToTitlecase implements Function { public class ToTitlecase implements Function {
final static private char[] delimiters = { ' ', '\t', '\r', '\n', '.' };
@Override @Override
public Object call(Properties bindings, Object[] args) { public Object call(Properties bindings, Object[] args) {
@ -51,7 +52,7 @@ public class ToTitlecase implements Function {
Object o = args[0]; Object o = args[0];
String s = o instanceof String ? (String) o : o.toString(); String s = o instanceof String ? (String) o : o.toString();
return WordUtils.capitalizeFully(s); return WordUtils.capitalizeFully(s, delimiters);
} }
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a string"); return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a string");
} }