Issue 447 - allow users to specify delimiters for toTitlecase function
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2253 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
884d0ea8d4
commit
1b197d93d8
@ -52,12 +52,12 @@ public class ToTitlecase implements Function {
|
||||
Object o = args[0];
|
||||
String s = o instanceof String ? (String) o : o.toString();
|
||||
return WordUtils.capitalizeFully(s, delimiters);
|
||||
// } else if (args.length == 2 && args[0] != null && args[1] != null) {
|
||||
// Object o = args[0];
|
||||
// String s = o instanceof String ? (String) o : o.toString();
|
||||
// o = args[1];
|
||||
// String delims = o instanceof String ? (String) o: o.toString();
|
||||
// return WordUtils.capitalizeFully(s,delims.toCharArray());
|
||||
} else if (args.length == 2 && args[0] != null && args[1] != null) {
|
||||
Object o = args[0];
|
||||
String s = o instanceof String ? (String) o : o.toString();
|
||||
o = args[1];
|
||||
String delims = o instanceof String ? (String) o: o.toString();
|
||||
return WordUtils.capitalizeFully(s,delims.toCharArray());
|
||||
} else {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a one or two strings");
|
||||
}
|
||||
|
@ -93,7 +93,6 @@ public class StringCaseTests extends RefineTest {
|
||||
@Test
|
||||
public void testToTitlecaseInvalidParams() {
|
||||
Assert.assertTrue(invoke("toTitlecase") instanceof EvalError);
|
||||
Assert.assertTrue(invoke("toTitlecase", "one","two") instanceof EvalError);
|
||||
Assert.assertTrue(invoke("toTitlecase", "one","two","three") instanceof EvalError);
|
||||
}
|
||||
|
||||
@ -103,8 +102,8 @@ public class StringCaseTests extends RefineTest {
|
||||
Assert.assertEquals((String)(invoke("toTitlecase", "ONE")),"One");
|
||||
Assert.assertEquals((String)(invoke("toTitlecase", "one two three")),"One Two Three");
|
||||
Assert.assertEquals((String)(invoke("toTitlecase", "C.R. SANDIDGE WINES, INC.")),"C.R. Sandidge Wines, Inc.");
|
||||
// Assert.assertEquals((String)(invoke("toTitlecase", "C.R. SANDIDGE WINES, INC.",",. ")),"C.R. Sandidge Wines, Inc.");
|
||||
// Assert.assertEquals((String)(invoke("toTitlecase", "one-two-three","-")),"One-Two-Three");
|
||||
Assert.assertEquals((String)(invoke("toTitlecase", "C.R. SANDIDGE WINES, INC.",",. ")),"C.R. Sandidge Wines, Inc.");
|
||||
Assert.assertEquals((String)(invoke("toTitlecase", "one-two-three","-")),"One-Two-Three");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user