/** * <p>Constructs a negated <code>CharRange</code> over a set of characters.</p> * * @param start first character, inclusive, in this range * @param end last character, inclusive, in this range * @return the new CharRange object * @see CharRange#CharRange(char, char, boolean) * @since 2.5 */ public static CharRange isNotIn(char start, char end) { return new CharRange(start, end, true); }
/** * <p>Does the <code>CharSet</code> contain the specified * character <code>ch</code>.</p> * * @param ch the character to check for * @return <code>true</code> if the set contains the characters */ public boolean contains(char ch) { for (Iterator it = set.iterator(); it.hasNext();) { CharRange range = (CharRange) it.next(); if (range.contains(ch)) { return true; } } return false; }
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') { set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3))); pos += 4; } else if (remainder >= 3 && str.charAt(pos + 1) == '-') { set.add(CharRange.isIn(str.charAt(pos), str.charAt(pos + 2))); pos += 3; } else if (remainder >= 2 && str.charAt(pos) == '^') { set.add(CharRange.isNot(str.charAt(pos + 1))); pos += 2; } else { set.add(CharRange.is(str.charAt(pos))); pos += 1;
/** * <p>Gets a string representation of the character range.</p> * * @return string representation of this range */ public String toString() { if (iToString == null) { StrBuilder buf = new StrBuilder(4); if (isNegated()) { buf.append('^'); } buf.append(start); if (start != end) { buf.append('-'); buf.append(end); } iToString = buf.toString(); } return iToString; }
@SuppressWarnings("unchecked") private String buildCharset(LinkedList<Object> interval) { char start = ((String) interval.removeFirst()).charAt(0); char end = ((String) interval.removeFirst()).charAt(0); Iterator<Character> it = (Iterator<Character>) new CharRange(start, end).iterator(); StringBuilder values = new StringBuilder(); while (it.hasNext()) { values.append(it.next()); } return values.toString(); }
/** * <p>Gets a string representation of the character range.</p> * * @return string representation of this range */ public String toString() { if (iToString == null) { StringBuffer buf = new StringBuffer(4); if (isNegated()) { buf.append('^'); } buf.append(start); if (start != end) { buf.append('-'); buf.append(end); } iToString = buf.toString(); } return iToString; }
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') { set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3))); pos += 4; } else if (remainder >= 3 && str.charAt(pos + 1) == '-') { set.add(CharRange.isIn(str.charAt(pos), str.charAt(pos + 2))); pos += 3; } else if (remainder >= 2 && str.charAt(pos) == '^') { set.add(CharRange.isNot(str.charAt(pos + 1))); pos += 2; } else { set.add(CharRange.is(str.charAt(pos))); pos += 1;
/** * <p>Constructs a <code>CharRange</code> over a single character.</p> * * @param ch only character in this range * @return the new CharRange object * @see CharRange#CharRange(char, char, boolean) * @since 2.5 */ public static CharRange is(char ch) { return new CharRange(ch, ch, false); }
/** * <p>Does the <code>CharSet</code> contain the specified * character <code>ch</code>.</p> * * @param ch the character to check for * @return <code>true</code> if the set contains the characters */ public boolean contains(char ch) { for (Iterator it = set.iterator(); it.hasNext();) { CharRange range = (CharRange) it.next(); if (range.contains(ch)) { return true; } } return false; }
/** * <p>Gets a string representation of the character range.</p> * * @return string representation of this range */ public String toString() { if (iToString == null) { StringBuffer buf = new StringBuffer(4); if (isNegated()) { buf.append('^'); } buf.append(start); if (start != end) { buf.append('-'); buf.append(end); } iToString = buf.toString(); } return iToString; }
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') { set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3))); pos += 4; } else if (remainder >= 3 && str.charAt(pos + 1) == '-') { set.add(CharRange.isIn(str.charAt(pos), str.charAt(pos + 2))); pos += 3; } else if (remainder >= 2 && str.charAt(pos) == '^') { set.add(CharRange.isNot(str.charAt(pos + 1))); pos += 2; } else { set.add(CharRange.is(str.charAt(pos))); pos += 1;
/** * <p>Constructs a <code>CharRange</code> over a set of characters.</p> * * @param start first character, inclusive, in this range * @param end last character, inclusive, in this range * @return the new CharRange object * @see CharRange#CharRange(char, char, boolean) * @since 2.5 */ public static CharRange isIn(char start, char end) { return new CharRange(start, end, false); }
/** * <p>Does the <code>CharSet</code> contain the specified * character <code>ch</code>.</p> * * @param ch the character to check for * @return <code>true</code> if the set contains the characters */ public boolean contains(char ch) { for (Iterator it = set.iterator(); it.hasNext();) { CharRange range = (CharRange) it.next(); if (range.contains(ch)) { return true; } } return false; }
/** * <p>Gets a string representation of the character range.</p> * * @return string representation of this range */ public String toString() { if (iToString == null) { StrBuilder buf = new StrBuilder(4); if (isNegated()) { buf.append('^'); } buf.append(start); if (start != end) { buf.append('-'); buf.append(end); } iToString = buf.toString(); } return iToString; }
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') { set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3))); pos += 4; } else if (remainder >= 3 && str.charAt(pos + 1) == '-') { set.add(CharRange.isIn(str.charAt(pos), str.charAt(pos + 2))); pos += 3; } else if (remainder >= 2 && str.charAt(pos) == '^') { set.add(CharRange.isNot(str.charAt(pos + 1))); pos += 2; } else { set.add(CharRange.is(str.charAt(pos))); pos += 1;
/** * <p>Constructs a negated <code>CharRange</code> over a single character.</p> * * @param ch only character in this range * @return the new CharRange object * @see CharRange#CharRange(char, char, boolean) * @since 2.5 */ public static CharRange isNot(char ch) { return new CharRange(ch, ch, true); }
/** * <p>Does the <code>CharSet</code> contain the specified * character <code>ch</code>.</p> * * @param ch the character to check for * @return <code>true</code> if the set contains the characters */ public boolean contains(char ch) { for (Iterator it = set.iterator(); it.hasNext();) { CharRange range = (CharRange) it.next(); if (range.contains(ch)) { return true; } } return false; }
/** * <p>Gets a string representation of the character range.</p> * * @return string representation of this range */ public String toString() { if (iToString == null) { StrBuilder buf = new StrBuilder(4); if (isNegated()) { buf.append('^'); } buf.append(start); if (start != end) { buf.append('-'); buf.append(end); } iToString = buf.toString(); } return iToString; }
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') { set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3))); pos += 4; } else if (remainder >= 3 && str.charAt(pos + 1) == '-') { set.add(CharRange.isIn(str.charAt(pos), str.charAt(pos + 2))); pos += 3; } else if (remainder >= 2 && str.charAt(pos) == '^') { set.add(CharRange.isNot(str.charAt(pos + 1))); pos += 2; } else { set.add(CharRange.is(str.charAt(pos))); pos += 1;
/** * <p>Constructs a <code>CharRange</code> over a single character.</p> * * @param ch only character in this range * @return the new CharRange object * @see CharRange#CharRange(char, char, boolean) * @since 2.5 */ public static CharRange is(char ch) { return new CharRange(ch, ch, false); }