Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.lang3
Class CharRange

    java.lang.Object
      org.apache.commons.lang3.CharRange

All Implemented Interfaces:
  Serializable, Iterable<Character>

    public final class CharRange

extends Object
implements Iterable<Character>, Serializable

A contiguous range of characters, optionally negated.

Instances are immutable.

#ThreadSafe#

Since:
  1.0
Version:
  $Id: CharRange.java 918868 2010-03-04 06:22:16Z bayard $
Author:
  Apache Software Foundation, Chris Feldhacker, Gary Gregory
See Also:
  Serialized Form

Method Summary
`boolean` | `contains(char ch)` Is the character specified contained in this range.
`boolean` | `contains(CharRange range)` Are all the characters of the passed in range contained in this range.
`boolean` | `equals(Object obj)` Compares two CharRange objects, returning true if they represent exactly the same range of characters defined in the same way.
`char` | `getEnd()` Gets the end character for this character range.
`char` | `getStart()` Gets the start character for this character range.
`int` | `hashCode()` Gets a hashCode compatible with the equals method.
`static CharRange` | `is(char ch)` Constructs a `CharRange` over a single character.
`static CharRange` | `isIn(char start, char end)` Constructs a `CharRange` over a set of characters.
`boolean` | `isNegated()` Is this `CharRange` negated.
`static CharRange` | `isNot(char ch)` Constructs a negated `CharRange` over a single character.
`static CharRange` | `isNotIn(char start, char end)` Constructs a negated `CharRange` over a set of characters.
`Iterator<Character>` | `iterator()` Returns an iterator which can be used to walk through the characters described by this range.
`String` | `toString()` Gets a string representation of the character range.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Method Detail

### is

    public static CharRange is(char ch)

  Constructs a `CharRange` over a single character.

  Parameters:
    `ch` - only character in this range
  Returns:
    the new CharRange object
  Since:
    2.5
  See Also:
    `CharRange(char, char, boolean)`

### isNot

    public static CharRange isNot(char ch)

  Constructs a negated `CharRange` over a single character.

  Parameters:
    `ch` - only character in this range
  Returns:
    the new CharRange object
  Since:
    2.5
  See Also:
    `CharRange(char, char, boolean)`

### isIn

    public static CharRange isIn(char start,
                                 char end)

  Constructs a `CharRange` over a set of characters.

  Parameters:
    `start` - first character, inclusive, in this range
    `end` - last character, inclusive, in this range
  Returns:
    the new CharRange object
  Since:
    2.5
  See Also:
    `CharRange(char, char, boolean)`

### isNotIn

    public static CharRange isNotIn(char start,
                                    char end)

  Constructs a negated `CharRange` over a set of characters.

  Parameters:
    `start` - first character, inclusive, in this range
    `end` - last character, inclusive, in this range
  Returns:
    the new CharRange object
  Since:
    2.5
  See Also:
    `CharRange(char, char, boolean)`

### getStart

    public char getStart()

  Gets the start character for this character range.

  Returns:
    the start char (inclusive)

### getEnd

    public char getEnd()

  Gets the end character for this character range.

  Returns:
    the end char (inclusive)

### isNegated

    public boolean isNegated()

  Is this `CharRange` negated.

  A negated range includes everything except that defined by the start and end characters.

  Returns:
    `true` is negated

### contains

    public boolean contains(char ch)

  Is the character specified contained in this range.

  Parameters:
    `ch` - the character to check
  Returns:
    `true` if this range contains the input character

### contains

    public boolean contains(CharRange range)

  Are all the characters of the passed in range contained in this range.

  Parameters:
    `range` - the range to check against
  Returns:
    `true` if this range entirely contains the input range
  Throws:
    `IllegalArgumentException` - if `null` input

### equals

    public boolean equals(Object obj)

  Compares two CharRange objects, returning true if they represent exactly the same range of characters defined in the same way.

  Overrides:
    `equals` in class `Object`
  Parameters:
    `obj` - the object to compare to
  Returns:
    true if equal

### hashCode

    public int hashCode()

  Gets a hashCode compatible with the equals method.

  Overrides:
    `hashCode` in class `Object`
  Returns:
    a suitable hashCode

### toString

    public String toString()

  Gets a string representation of the character range.

  Overrides:
    `toString` in class `Object`
  Returns:
    string representation of this range

### iterator

    public Iterator<Character> iterator()

  Returns an iterator which can be used to walk through the characters described by this range.

  #NotThreadSafe# the iterator is not threadsafe

  Specified by:
    `iterator` in interface `Iterable<Character>`
  Returns:
    an iterator to the chars represented by this range
  Since:
    2.5

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.