@Test public void testConvToArray() { String[] r; setDelimiter(" "); setMinLength(1); r = convToArray("AA BBB CC"); logger.trace("{} tokens; {} {}", r.length, (Object)r); assertThat("Wrong number of tokens", r.length, CoreMatchers.equalTo(3)); r = convToArray("AA BBB CC "); logger.trace("{} tokens; {} {}", r.length, (Object)r); assertThat("Wrong number of tokens", r.length, CoreMatchers.equalTo(3)); setMinLength(0); r = convToArray("AA BBB CC "); logger.trace("{} tokens; {} {}", r.length, (Object)r); assertThat("Wrong number of tokens", r.length, CoreMatchers.equalTo(10)); setDelimiter("B"); r = convToArray("AA BBB CC "); logger.trace("{} tokens; {} {}", r.length, (Object)r); assertThat("Wrong number of tokens", r.length, CoreMatchers.equalTo(4)); setDelimiter("BBB"); r = convToArray("AA BBB CC "); logger.trace("{} tokens; {} {}", r.length, (Object)r); assertThat("Wrong number of tokens", r.length, CoreMatchers.equalTo(2)); setDelimiter("A"); r = convToArray("AA BBB CC "); logger.trace("{} tokens; {} {}", r.length, (Object)r); assertThat("Wrong number of tokens", r.length, CoreMatchers.equalTo(3)); }
protected String[] convToArray(String s) { if (s == null) { return new String[0]; } String[] a = s.split(this.delimiter, -1); if (this.getDelimiter().isEmpty()) a = Arrays.copyOfRange(a, 1, a.length -1); if (minLength > 0) { int bi = 0; String[] b = new String[a.length]; for (int ai = 0; ai < a.length; ai++) { if (a[ai].length() >= minLength) { b[bi++] = a[ai]; } } a = Arrays.copyOf(b, bi); } return a; }
TokeniserMatcher implements Matcher { protected String[] convToArray(String s) { if (s == null) { return new String[0]; } String[] a = s.split(this.delimiter, -1); if (this.getDelimiter().isEmpty()) a = Arrays.copyOfRange(a, 1, a.length -1); if (minLength > 0) { int bi = 0; String[] b = new String[a.length]; for (int ai = 0; ai < a.length; ai++) { if (a[ai].length() >= minLength) { b[bi++] = a[ai]; } } a = Arrays.copyOf(b, bi); } return a; } }
TokeniserMatcher implements Matcher { protected String[] convToArray(String s) { if (s == null) { return new String[0]; } String[] a = s.split(this.delimiter, -1); if (this.getDelimiter().isEmpty()) a = Arrays.copyOfRange(a, 1, a.length -1); if (minLength > 0) { int bi = 0; String[] b = new String[a.length]; for (int ai = 0; ai < a.length; ai++) { if (a[ai].length() >= minLength) { b[bi++] = a[ai]; } } a = Arrays.copyOf(b, bi); } return a; }  }
TokeniserMatcher implements Matcher { protected String[] convToArray(String s) { if (s == null) { return new String[0]; } String[] a = s.split(this.delimiter, -1); if (this.getDelimiter().isEmpty()) a = Arrays.copyOfRange(a, 1, a.length -1); if (minLength > 0) { int bi = 0; String[] b = new String[a.length]; for (int ai = 0; ai < a.length; ai++) { if (a[ai].length() >= minLength) { b[bi++] = a[ai]; } } a = Arrays.copyOf(b, bi); } return a; }  String getDelimiter(); void setDelimiter(String delimiter); int getMinLength(); void setMinLength(int minLength); }
TokeniserMatcher implements Matcher { protected String[] convToArray(String s) { if (s == null) { return new String[0]; } String[] a = s.split(this.delimiter, -1); if (this.getDelimiter().isEmpty()) a = Arrays.copyOfRange(a, 1, a.length -1); if (minLength > 0) { int bi = 0; String[] b = new String[a.length]; for (int ai = 0; ai < a.length; ai++) { if (a[ai].length() >= minLength) { b[bi++] = a[ai]; } } a = Arrays.copyOf(b, bi); } return a; }  String getDelimiter(); void setDelimiter(String delimiter); int getMinLength(); void setMinLength(int minLength);  }