Class Characters

java.lang.Object
org.parboiled.support.Characters

public class Characters extends 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 final Characters
    The Characters set including all character.
    static final Characters
    The empty Characters set
  • Method Summary

    Modifier and Type
    Method
    Description
    add(char c)
    Adds the given character to the set.
    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(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
     
    char[]
    Returns the characters in this set, if it is additive.
    int
     
    boolean
     
    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(String chars)
    Creates a new Characters instance containing only the given chars.
    remove(char c)
    Removes the given character from the set.
    Returns a new Characters object containing all the characters of this instance minus all characters of the given instance.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • NONE

      public static final Characters NONE
      The empty Characters set
    • ALL

      public static final Characters ALL
      The Characters set including all character.
  • Method Details

    • 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 String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class 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(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(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