Class CharRangeSet

java.lang.Object
fc.util.CharRangeSet

public class CharRangeSet extends Object
A set of char ranges.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new CharRangeSet with the initial set containing only the specified charrange
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    inRange(char c)
    Consider a set of ranges A, B added as a union (logical or) and ranges C and D added as an intersection (logical and).
    void
    Adds the specified range as an intersection to the existing ranges (for purposes of inRange(char) method).
    static void
    main(String[] args)
     
     
    void
    Adds this specified range as a union to the existing set of ranges (for purposes of inRange(char) method).

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CharRangeSet

      public CharRangeSet(CharRange cs)
      Constructs a new CharRangeSet with the initial set containing only the specified charrange
      Parameters:
      cs - the initial charrange
  • Method Details

    • union

      public void union(CharRange r)
      Adds this specified range as a union to the existing set of ranges (for purposes of inRange(char) method). Overlapping ranges are ok.
      Parameters:
      cs - a charrange to unite with
      Throws:
      IllegalArgumentException - if the specified range was null
    • intersection

      public void intersection(CharRange r)
      Adds the specified range as an intersection to the existing ranges (for purposes of inRange(char) method). Overlapping ranges are ok.
      Parameters:
      r - the range to add
    • inRange

      public boolean inRange(char c)
      Consider a set of ranges A, B added as a union (logical or) and ranges C and D added as an intersection (logical and). A character c is in range if it exists in:
      (A.inRange(c) || B.inRange(c) || ...) invalid input: '&'invalid input: '&' C.inRange(c) invalid input: '&'invalid input: '&' D.inRange(c) invalid input: '&'invalid input: '&' ...
      This can be generalized to an arbitrary number of sub ranges. If intersection or union ranges don't exist, then they are not considered in the above expression. Note, the interaction may be subtle if any of the ranges (A, B, C...etc) are individually negated because in that case the inRange method for that negated range would return true if the specified character was not in that range.
      Returns:
      true if the passed in character is allowed by this set of ranges.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • main

      public static void main(String[] args)