Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.3 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javolution.text
Class CharSet

    java.lang.Object
      javolution.text.CharSet

All Implemented Interfaces:
  Immutable

    public final class CharSet

extends java.lang.Object
implements Immutable

This class represents a set of characters.

Instances of this class are typically used for parsing purpose (faster than regular expressions for simple patterns). For example:``

         // Integration with Text.
         Text number;
         int exponentIndex = num.indexOfAny(CharSet.valueOf('e', 'E'));

         // Integration with TextFormat.
         public List<Integer> parse(CharSequence csq, Cursor cursor) {
             FastTable<Integer> numbers = FastTable.newInstance();
             while (cursor.skip(CharSet.WHITESPACES, csq)) {
                 numbers.add(TypeFormat.parseInt(csq, cursor));
             }
             return numbers;
         }

Version:
  3.7, January 1, 2006
Author:
  Jean-Marie Dautelle

Field Summary
`static CharSet` | `EMPTY` Represents an empty character set.
`static CharSet` | `ISO_CONTROLS` Represents ISO control characters according to Java (see `Character.isISOControl(char)`).
`static CharSet` | `SPACES` Represents spaces characters according to Java (see `Character.isSpaceChar(char)`).
`static CharSet` | `WHITESPACES` Represents white spaces characters according to Java (see `Character.isWhitespace(char)`).

Method Summary
`boolean` | `contains(char c)` Indicates if the specified character is contained by this character set.
`int` | `indexIn(char[] chars)` Equivalent to `indexIn(chars, 0)`
`int` | `indexIn(char[] chars, int fromIndex)` Returns the first index in the specified character array of one of the character of this set.
`int` | `indexIn(java.lang.CharSequence csq)` Equivalent to `indexIn(csq, 0)`
`int` | `indexIn(java.lang.CharSequence csq, int fromIndex)` Returns the first index in the specified character sequence of one of the character of this set.
`int` | `lastIndexIn(char[] chars)` Equivalent to `lastIndexIn(chars, chars.length-1)`
`int` | `lastIndexIn(char[] chars, int fromIndex)` Returns the last index in the specified character array of one of the character of this set.
`int` | `lastIndexIn(java.lang.CharSequence csq)` Equivalent to `lastIndexIn(csq, csq.length()-1)`
`int` | `lastIndexIn(java.lang.CharSequence csq, int fromIndex)` Returns the last index in the specified character sequence of one of the character of this set.
`CharSet` | `minus(CharSet that)` Returns the character set containing the characters from this character minus the characters from the character set specified.
`CharSet` | `plus(CharSet that)` Returns the character set containing the characters from this character set plus the characters from the character set specified.
`static CharSet` | `rangeOf(char first, char last)` Returns the character set holding the characters in the specified range.
`java.lang.String` | `toString()` Returns the textual representation of this character set.
`static CharSet` | `valueOf(char... chars)` Returns the character set holding the specified characters.

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

Field Detail

### EMPTY

    public static final CharSet EMPTY

  Represents an empty character set.

### WHITESPACES

    public static final CharSet WHITESPACES

  Represents white spaces characters according to Java (see `Character.isWhitespace(char)`).

### SPACES

    public static final CharSet SPACES

  Represents spaces characters according to Java (see `Character.isSpaceChar(char)`).

### ISO_CONTROLS

    public static final CharSet ISO_CONTROLS

  Represents ISO control characters according to Java (see `Character.isISOControl(char)`).

Method Detail

### valueOf

    public static CharSet valueOf(char... chars)

  Returns the character set holding the specified characters.

  Parameters:
    `chars` - the characters contained by this character set.
  Returns:
    the corresponding character set.

### rangeOf

    public static CharSet rangeOf(char first,
                                  char last)

  Returns the character set holding the characters in the specified range.

  Parameters:
    `first` - the first character.
    `last` - the last character.
  Returns:
    the corresponding character set.
  Throws:
    `java.lang.IllegalArgumentException` - if `first > last`

### contains

    public boolean contains(char c)

  Indicates if the specified character is contained by this character set.

  Parameters:
    `c` - the character to test.
  Returns:
    `true` if this character set contains the specified character; `false` otherwise.

### indexIn

    public int indexIn(java.lang.CharSequence csq)

  Equivalent to `indexIn(csq, 0)`

  Parameters:
    `csq` - the character sequence to be searched.
  Returns:
    the index in the specified character sequence or `-1` if none found.

### indexIn

    public int indexIn(java.lang.CharSequence csq,
                       int fromIndex)

  Returns the first index in the specified character sequence of one of the character of this set.

  Parameters:
    `csq` - the character sequence to be searched.
    `fromIndex` - the index to search from.
  Returns:
    the index in the specified character sequence or `-1` if none found.

### indexIn

    public int indexIn(char[] chars)

  Equivalent to `indexIn(chars, 0)`

  Returns:
    the index in the specified character sequence or `-1` if none found.

### indexIn

    public int indexIn(char[] chars,
                       int fromIndex)

  Returns the first index in the specified character array of one of the character of this set.

  Parameters:
    `chars` - the character array to be searched.
    `fromIndex` - the index to search from.
  Returns:
    the index in the specified character sequence or `-1` if none found.

### lastIndexIn

    public int lastIndexIn(java.lang.CharSequence csq)

  Equivalent to `lastIndexIn(csq, csq.length()-1)`

  Parameters:
    `csq` - the character sequence to be searched.
  Returns:
    the last index in the specified character sequence or `-1` if none found.

### lastIndexIn

    public int lastIndexIn(java.lang.CharSequence csq,
                           int fromIndex)

  Returns the last index in the specified character sequence of one of the character of this set.

  Parameters:
    `csq` - the character sequence to be searched.
    `fromIndex` - the index to search from (backward).
  Returns:
    the index in the specified character sequence or `-1` if none found.

### lastIndexIn

    public int lastIndexIn(char[] chars)

  Equivalent to `lastIndexIn(chars, chars.length-1)`

  Returns:
    the index in the specified character sequence or `-1` if none found.

### lastIndexIn

    public int lastIndexIn(char[] chars,
                           int fromIndex)

  Returns the last index in the specified character array of one of the character of this set.

  Parameters:
    `chars` - the character array to be searched.
    `fromIndex` - the index to search from (backward).
  Returns:
    the index in the specified character sequence or `-1` if none found.

### plus

    public CharSet plus(CharSet that)

  Returns the character set containing the characters from this character set plus the characters from the character set specified.

  Parameters:
    `that` - the set containing the characters to be added.
  Returns:
    `this + that`

### minus

    public CharSet minus(CharSet that)

  Returns the character set containing the characters from this character minus the characters from the character set specified.

  Parameters:
    `that` - the set containing the character to be removed.
  Returns:
    `this - that`

### toString

    public java.lang.String toString()

  Returns the textual representation of this character set.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the textual representation.

Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.3 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005 - 2009 Javolution.