Package org.parboiled.support
Class Characters
- java.lang.Object
-
- org.parboiled.support.Characters
-
public class Characters extends java.lang.ObjectAn 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 CharactersALLThe Characters set including all character.static CharactersNONEThe empty Characters set
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Charactersadd(char c)Adds the given character to the set.Charactersadd(Characters other)Returns a new Characters object containing all the characters of this instance plus all characters of the given instance.static CharactersallBut(char c)Creates a new Characters instance containing all characters minus the given one.static CharactersallBut(char... chars)Creates a new Characters instance containing all characters minus the given ones.static CharactersallBut(java.lang.String chars)Creates a new Characters instance containing all characters minus the given ones.booleancontains(char c)Determines whether this instance contains the given character.booleanequals(java.lang.Object o)char[]getChars()Returns the characters in this set, if it is additive.inthashCode()booleanisSubtractive()static Charactersof(char c)Creates a new Characters instance containing only the given char.static Charactersof(char... chars)Creates a new Characters instance containing only the given chars.static Charactersof(java.lang.String chars)Creates a new Characters instance containing only the given chars.Charactersremove(char c)Removes the given character from the set.Charactersremove(Characters other)Returns a new Characters object containing all the characters of this instance minus all characters of the given instance.java.lang.StringtoString()
-
-
-
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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein 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
-
-