protected ValidationCategory filter(final String value) { if (value == null || value.length() == 0) { return ValidationCategory.INVALID; } final CharIterator it = new CharIterator(value); while (it.hasNext()) { it.next(); if (!it.isLetter()) { return ValidationCategory.INVALID; } } return ValidationCategory.VALID; }
public synchronized void run(final String value, final InputRow row, final int distinctCount) { final List<Entry<String, UnicodeSet>> unicodeSetsRemaining = new ArrayList<>(_unicodeSets.entrySet()); final CharIterator charIterator = new CharIterator(value); while (charIterator.hasNext()) { final Character c = charIterator.next(); if (charIterator.isWhitespace() || charIterator.isDigit()) { logger.debug("Skipping whitespace/digit char: {}", c); } else { final Iterator<Entry<String, UnicodeSet>> it = unicodeSetsRemaining.iterator(); while (it.hasNext()) { final Entry<String, UnicodeSet> unicodeSet = it.next(); if (unicodeSet.getValue().contains(c)) { final String name = unicodeSet.getKey(); final RowAnnotation annotation = _annotations.get(name); _annotationFactory.annotate(row, distinctCount, annotation); // remove this unicode set from the remaining checks on // this value. it.remove(); } } } } }
while (it.hasNext()) { it.next(); if (it.is('[')) {
public static String safeName(String str) { if (StringUtils.isNullOrEmpty(str)) { throw new IllegalArgumentException("Cannot create safe name from empty/null string: " + str); } final CharIterator ci = new CharIterator(str); while (ci.hasNext()) { ci.next(); if (!ci.isLetter() && !ci.isDigit()) { // replaces unexpected chars with underscore ci.set('_'); } } str = ci.toString(); if (!Character.isLetter(str.charAt(0))) { str = "db" + str; } return str; }
@Override public void insertString(final int offs, final String str, final AttributeSet a) throws BadLocationException { boolean valid = true; final CharIterator it = new CharIterator(str); while (it.hasNext() && valid) { it.next(); if (it.isDigit() || it.is('%')) { continue; } if (it.is('-') && _allowNegative) { continue; } if (it.is('.') && _allowDecimal) { continue; } valid = false; break; } if (valid) { super.insertString(offs, str, a); } } }
public Object[] transform(final String value) { if (value == null) { return new Object[1]; } final CharIterator it = new CharIterator(value); while (it.hasNext()) { it.next(); if (it.isWhitespace()) { if (removeWhitespaces) { it.remove(); } } else if (it.isLetter()) { if (removeLetters) { it.remove(); } } else if (it.isDigit()) { if (removeDigits) { it.remove(); } } else if (removeSigns) { it.remove(); } } return new Object[] { it.toString() }; } }
while (it.hasNext()) { it.next(); if (it.isLetter()) {