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() }; } }
@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); } } }
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; }
final CharIterator ci = new CharIterator(string); while (ci.hasNext()) { final char c = ci.next(); if (ci.is(configuration.getThousandsSeparator()) || ci.is(configuration.getDecimalSeparator())) { boolean treatAsSeparator = false; if (lastToken != null && lastToken.getType() == TokenType.NUMBER) { if (ci.hasNext()) { final char next = ci.next(); if (ci.isDigit()) { lastToken = registerChar(result, lastToken, next, TokenType.NUMBER); } else { ci.previous(); } else if (ci.is(configuration.getMinusSign())) { if (ci.hasNext()) { final char next = ci.next(); if (ci.isDigit()) { lastToken = registerChar(result, lastToken, next, TokenType.NUMBER); } else { ci.previous(); } else if (ci.isDigit()) { lastToken = registerChar(result, lastToken, c, TokenType.NUMBER); } else if (ci.isLetter()) {
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; }
final CharIterator it = new CharIterator(value); while (it.hasNext()) { it.next(); if (it.isLetter()) { numLetters += distinctCount; if (it.isUpperCase()) { numUppercase += distinctCount; if (!firstLetter) { numLowercase += distinctCount; if (it.isDiacritic()) { numDiacritics += distinctCount; } else { numNonLetters += distinctCount; if (it.isDigit()) { numDigits += distinctCount; if (it.isWhitespace()) { numWhitespace++; if (it.is('.')) { firstLetter = true;
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(); } } } } }
int endingBrackets = 0; final CharIterator it = new CharIterator(str); while (it.hasNext()) { it.next(); if (it.is('[')) { beginningBrackets++; } else if (it.is(']')) { endingBrackets++; it.reset(); logger.debug("brackets statistics: beginning={}, ending={}", beginningBrackets, endingBrackets); if (beginningBrackets != endingBrackets) {
public CharIterator subIterator(final int fromIndex, final int toIndex) { final int length = toIndex - fromIndex; assert length > 0; final char[] chars = new char[length]; System.arraycopy(_chars, fromIndex, chars, 0, length); return new CharIterator(chars); }