### Question:
ValueFilterSlice extends AbstractValueFilter { @Override public ValueObject filter(ValueObject value) { if (value == null) { return value; } int f = from; int t = to; int i = Math.min(1, Math.abs(inc)); if (value.getObjectType() == ValueObject.TYPE.ARRAY) { ValueArray arr = value.asArray(); if (f >= arr.size()) { return null; } ValueArray ret = ValueFactory.createArray(arr.size()); if (f < 0) { f = arr.size() + f; } if (t < 0) { t = arr.size() + t + 1; } if (t < f) { int x = t; t = f; f = x; i = 0 - i; } if (i > 0) { for (int x = f; x < t && x < arr.size(); x += i) { ret.add(arr.get(x)); } } else { for (int x = f; x > t; x += i) { ret.add(arr.get(x)); } } return ret; } else { String str = ValueUtil.asNativeString(value); int sl = str.length(); if (f >= sl) { return value; } if (f < 0) { f = sl + f; } if (t < 0) { t = sl + t + 1; } if (t < f) { int x = t; t = f; f = x; i = 0 - i; } if (i == 1) { try { if (t > sl || f >= sl) { return null; } return ValueFactory.create(str.substring(f, t)); } catch (IndexOutOfBoundsException e) { System.out.println("** index:err ** from=" + f + " to=" + t + " iter=" + i + " str=" + str); return null; } } else { char[] ch = new char[Math.abs(t - f)]; char[] src = str.toCharArray(); if (i > 0) { for (int x = f; x < t; x += i) { ch[x - f] = src[x]; } } else { for (int x = f; x > t; x += i) { ch[x - f] = src[x]; } } return ValueFactory.create(new String(ch)); } } } ValueFilterSlice();  ValueFilterSlice(int from, int to, int inc); @Override ValueObject filter(ValueObject value); @Override ValueObject filterValue(ValueObject value);  }### Answer:
@Test public void stringSlice() { ValueFilterStringSlice vf = new ValueFilterStringSlice(",", "|", 0, 2); assertEquals("a|b", vf.filter("a,b,c")); assertEquals(null, vf.filter((String) null)); }
@Test public void trickyStringSlice() { ValueFilterStringSlice vf = new ValueFilterStringSlice(",", 1); assertEquals("2,3,4,5", vf.filter("1,2,3,4,5")); }
@Test public void slice() { ValueFilterSlice vf = new ValueFilterSlice(2, 4, 1); assertEquals("23", vf.filter(ValueFactory.create("0123456")).toString()); vf = new ValueFilterSlice(2, -1, 1); assertEquals("23456", vf.filter(ValueFactory.create("0123456")).toString()); vf = new ValueFilterSlice(2, -2, 1); assertEquals("2345", vf.filter(ValueFactory.create("0123456")).toString()); }