@Test public void test2() { SubString udf = new SubString(null); assertTrue(udf.evaluate("abc", 2).equals("bc")); assertTrue(udf.evaluate("abc", 1).equals("abc")); assertTrue(udf.evaluate("abc", 0).equals("abc")); assertTrue(udf.evaluate("abc", -1).equals("c")); }
public String evaluate(String s, int pos, int len) { if (s == null) { return null; } if (len <= 0) { return ""; } int[] idx = makeIndex(pos, len, s.length()); if (idx == null) { return ""; } return new String(s.toString().substring(idx[0], idx[1])); }
SubString extends UDF { public String evaluate(String s, int pos, int len) { if (s == null) { return null; } if (len <= 0) { return ""; } int[] idx = makeIndex(pos, len, s.length()); if (idx == null) { return ""; } return new String(s.toString().substring(idx[0], idx[1])); } }
SubString extends UDF { public String evaluate(String s, int pos, int len) { if (s == null) { return null; } if (len <= 0) { return ""; } int[] idx = makeIndex(pos, len, s.length()); if (idx == null) { return ""; } return new String(s.toString().substring(idx[0], idx[1])); } SubString(Map<String, String> config); }
SubString extends UDF { public String evaluate(String s, int pos, int len) { if (s == null) { return null; } if (len <= 0) { return ""; } int[] idx = makeIndex(pos, len, s.length()); if (idx == null) { return ""; } return new String(s.toString().substring(idx[0], idx[1])); } SubString(Map<String, String> config); String evaluate(String s, int pos, int len); String evaluate(String s, int pos); }
SubString extends UDF { public String evaluate(String s, int pos, int len) { if (s == null) { return null; } if (len <= 0) { return ""; } int[] idx = makeIndex(pos, len, s.length()); if (idx == null) { return ""; } return new String(s.toString().substring(idx[0], idx[1])); } SubString(Map<String, String> config); String evaluate(String s, int pos, int len); String evaluate(String s, int pos);  }