Class CharSet

java.lang.Object
eu.bandm.tools.d2d2.infra.CharSet
All Implemented Interfaces:
CharSet, Serializable, Predicate<Character>

public class CharSet extends Object implements CharSet, Serializable
Implements Character Sets as an ordered sequence of ranges.
Behaves immutable.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Realizes the ranges which make up the character sets.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CharSet
    All supported characters, currently MORE than unicode ! DOCME
    static final CharSet
    evident
    static final char
    Highest possible character value, needed for the definition of negate().
    static final char
    Lowest possible character value, currently 0x0000, needed for the definition of negate().
  • Constructor Summary

    Constructors
    Constructor
    Description
    CharSet(char l)
    Construct a singleton character set.
    CharSet(char l, char u)
    Construct an instance which ontains the range from l to u.
    Construct an instance which contains the all characters contained in the string argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    and(CharSet cs2)
    Calculates the intersection of both sets.
    boolean
    contains(char c)
    Evident
    boolean
    Evident
    boolean
     
    int
     
    static CharSet
    Constructs an instance which contains all characters contained in the string argument.
    Calculates the netation of this set, w.r.t.
    or(CharSet cs2)
    Calculates the union of the two sets.
    Evident.
    static String
    Static variant of stringRepD2d().
    Generate a numeric representation of the character ranges in the set.
    Convert back into the representation used in d2d-definition sources (="ddf").
    protected static String
    xn(char c)
    Generate a numeric representation of a character, whenever sensible.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface eu.bandm.tools.ops.CharSet

    and, or, test

    Methods inherited from interface java.util.function.Predicate

    and, or
  • Field Details

    • LOW

      public static final char LOW
      Lowest possible character value, currently 0x0000, needed for the definition of negate().
      See Also:
    • HI

      public static final char HI
      Highest possible character value, needed for the definition of negate().
      See Also:
    • EMPTY_SET

      public static final CharSet EMPTY_SET
      evident
    • ALL_CHARS

      public static final CharSet ALL_CHARS
      All supported characters, currently MORE than unicode ! DOCME
  • Constructor Details

    • CharSet

      public CharSet(char l, char u)
      Construct an instance which ontains the range from l to u.
      Throws:
      IllegalArgumentException - in case l is numerically larger than u.
    • CharSet

      public CharSet(char l)
      Construct a singleton character set.
    • CharSet

      public CharSet(String s)
      Construct an instance which contains the all characters contained in the string argument.
  • Method Details

    • equals

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

      public boolean equals(CharSet o)
      Evident
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • makeCharSet

      public static CharSet makeCharSet(String chars)
      Constructs an instance which contains all characters contained in the string argument.
    • contains

      public boolean contains(char c)
      Evident
      Specified by:
      contains in interface CharSet
    • singletonContents

      @Opt public @Opt Character singletonContents()
      Evident.
      Returns:
      the only member of this, if it is a singleton set, otherwise null.
    • and

      public CharSet and(CharSet cs2)
      Calculates the intersection of both sets.
    • negate

      public CharSet negate()
      Calculates the netation of this set, w.r.t. the unversal range from LOW to HI.
      Specified by:
      negate in interface CharSet
      Specified by:
      negate in interface Predicate<Character>
    • or

      public CharSet or(CharSet cs2)
      Calculates the union of the two sets. Implemented by stepping through the ordered list of ranges and "zipping" them.
    • xn

      protected static String xn(char c)
      Generate a numeric representation of a character, whenever sensible.
    • stringRep

      public String stringRep()
      Generate a numeric representation of the character ranges in the set.
      Returns:
      a symbolic string representation, showing characters and decimal values.
    • stringRepD2d

      public String stringRepD2d()
      Convert back into the representation used in d2d-definition sources (="ddf").
      Returns:
      the un-parsed representation according to D2d module syntax.
    • staticStringRepD2d

      public static String staticStringRepD2d(CharSet cs)
      Static variant of stringRepD2d().