Package jflex

Class Interval

java.lang.Object
jflex.Interval

public final class Interval extends Object
An interval of characters with basic operations.
Version:
JFlex 1.7.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
     
    int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Interval(int start, int end)
    Construct a new interval from start to end.
    Copy constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(int point)
    Return true iff point is contained in this interval.
    boolean
    Return true iff this interval completely contains the other one.
    Make a copy of this interval.
    boolean
    private static boolean
    isPrintable(int c)
    Check whether a character is printable.
    void
    setEnd(int end)
    Set a new last character
    void
    setStart(int start)
    Set a new first character
    Get a String representation of this interval.

    Methods inherited from class java.lang.Object

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

    • start

      public int start
    • end

      public int end
  • Constructor Details

    • Interval

      public Interval(int start, int end)
      Construct a new interval from start to end.
      Parameters:
      start - first character the interval should contain
      end - last character the interval should contain
    • Interval

      public Interval(Interval other)
      Copy constructor.
      Parameters:
      other - a Interval object.
  • Method Details

    • contains

      public boolean contains(int point)
      Return true iff point is contained in this interval.
      Parameters:
      point - the character to check
      Returns:
      whether the codepoint is contained in the interval.
    • contains

      public boolean contains(Interval other)
      Return true iff this interval completely contains the other one.
      Parameters:
      other - the other interval
      Returns:
      whether this interval completely contains the other one.
    • equals

      public boolean equals(Object o)

      Return true if o is an interval with the same borders.

      Overrides:
      equals in class Object
    • setEnd

      public void setEnd(int end)
      Set a new last character
      Parameters:
      end - the new last character of this interval
    • setStart

      public void setStart(int start)
      Set a new first character
      Parameters:
      start - the new first character of this interval
    • isPrintable

      private static boolean isPrintable(int c)
      Check whether a character is printable.
      Parameters:
      c - the character to check
    • toString

      public String toString()
      Get a String representation of this interval.
      Overrides:
      toString in class Object
      Returns:
      a string "[start-end]" or "[start]" (if there is only one character in the interval) where start and end are either a number (the character code) or something of the from 'a'.
    • copy

      public Interval copy()
      Make a copy of this interval.
      Returns:
      the copy