Package org.parboiled.support
Class Characters
- java.lang.Object
-
- org.parboiled.support.Characters
-
public class Characters extends java.lang.Object
An immutable, set-like aggregation of (relatively few) characters that allows for an inverted semantic ("all chars except these few").
-
-
Field Summary
Fields Modifier and Type Field Description static Characters
ALL
The Characters set including all character.static Characters
NONE
The empty Characters set
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Characters
add(char c)
Adds the given character to the set.Characters
add(Characters other)
Returns a new Characters object containing all the characters of this instance plus all characters of the given instance.static Characters
allBut(char c)
Creates a new Characters instance containing all characters minus the given one.static Characters
allBut(char... chars)
Creates a new Characters instance containing all characters minus the given ones.static Characters
allBut(java.lang.String chars)
Creates a new Characters instance containing all characters minus the given ones.boolean
contains(char c)
Determines whether this instance contains the given character.boolean
equals(java.lang.Object o)
char[]
getChars()
Returns the characters in this set, if it is additive.int
hashCode()
boolean
isSubtractive()
static Characters
of(char c)
Creates a new Characters instance containing only the given char.static Characters
of(char... chars)
Creates a new Characters instance containing only the given chars.static Characters
of(java.lang.String chars)
Creates a new Characters instance containing only the given chars.Characters
remove(char c)
Removes the given character from the set.Characters
remove(Characters other)
Returns a new Characters object containing all the characters of this instance minus all characters of the given instance.java.lang.String
toString()
-
-
-
Field Detail
-
NONE
public static final Characters NONE
The empty Characters set
-
ALL
public static final Characters ALL
The Characters set including all character.
-
-
Method Detail
-
isSubtractive
public boolean isSubtractive()
- Returns:
- true if the set is subtractive
-
getChars
public char[] getChars()
Returns the characters in this set, if it is additive. If the set is subtractive the method returns the characters not in the set.- Returns:
- the characters
-
add
public Characters add(char c)
Adds the given character to the set.- Parameters:
c
- the character to add- Returns:
- a new Characters object
-
remove
public Characters remove(char c)
Removes the given character from the set.- Parameters:
c
- the character to remove- Returns:
- a new Characters object
-
contains
public boolean contains(char c)
Determines whether this instance contains the given character.- Parameters:
c
- the character to check for- Returns:
- true if this instance contains c
-
add
public Characters add(Characters other)
Returns a new Characters object containing all the characters of this instance plus all characters of the given instance.- Parameters:
other
- the other Characters to add- Returns:
- a new Characters object
-
remove
public Characters remove(Characters other)
Returns a new Characters object containing all the characters of this instance minus all characters of the given instance.- Parameters:
other
- the other Characters to remove- Returns:
- a new Characters object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
of
public static Characters of(char c)
Creates a new Characters instance containing only the given char.- Parameters:
c
- the char- Returns:
- a new Characters object
-
of
public static Characters of(char... chars)
Creates a new Characters instance containing only the given chars.- Parameters:
chars
- the chars- Returns:
- a new Characters object
-
of
public static Characters of(java.lang.String chars)
Creates a new Characters instance containing only the given chars.- Parameters:
chars
- the chars- Returns:
- a new Characters object
-
allBut
public static Characters allBut(char c)
Creates a new Characters instance containing all characters minus the given one.- Parameters:
c
- the char to NOT include- Returns:
- a new Characters object
-
allBut
public static Characters allBut(char... chars)
Creates a new Characters instance containing all characters minus the given ones.- Parameters:
chars
- the chars to NOT include- Returns:
- a new Characters object
-
allBut
public static Characters allBut(java.lang.String chars)
Creates a new Characters instance containing all characters minus the given ones.- Parameters:
chars
- the chars to NOT include- Returns:
- a new Characters object
-
-