javolution37.javolution.lang
Class CharSet
- java.lang.Object
-
- javolution37.javolution.lang.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, TextFormat.Cursor cursor) { FastTable<Integer> numbers = FastTable.newInstance(); while (cursor.skip(CharSet.WHITESPACES, csq)) { numbers.add(TypeFormat.parseInt(csq, cursor)); } return numbers; }
-
-
Field Summary
Fields Modifier and Type Field and Description static CharSetEMPTYRepresents an empty character set.static CharSetISO_CONTROLSRepresents ISO control characters according to Java (seeCharacter.isISOControl(char)).static CharSetSPACESRepresents spaces characters according to Java (seeCharacter.isSpaceChar(char)).static CharSetWHITESPACESRepresents white spaces characters according to Java (seeCharacter.isWhitespace(char)).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleancontains(char c)Indicates if the specified character is contained by this character set.CharSetminus(CharSet that)Returns the character set containing the characters from this character minus the characters from the character set specified.CharSetplus(CharSet that)Returns the character set containing the characters from this character set plus the characters from the character set specified.static CharSetrangeOf(char first, char last)Returns the character set holding the characters in the specified range.java.lang.StringtoString()Returns the textual representation of this character set.static CharSetvalueOf(char... chars)Returns the character set holding the specified characters.
-
-
-
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 (seeCharacter.isWhitespace(char)).
-
SPACES
public static final CharSet SPACES
Represents spaces characters according to Java (seeCharacter.isSpaceChar(char)).
-
ISO_CONTROLS
public static final CharSet ISO_CONTROLS
Represents ISO control characters according to Java (seeCharacter.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- iffirst > 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:
trueif this character set contains the specified character;falseotherwise.
-
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:
toStringin classjava.lang.Object- Returns:
- the textual representation.
-
-
DMelt 3.0 © DataMelt by jWork.ORG