Package skyview.test

Class HCounter

java.lang.Object
skyview.test.HCounter

public class HCounter extends Object
This class defines a hierarchical counter that is may be used to index a hierarchy of objects (tests, version, ...). The counter is simply a string of integers connected with dots. The user can increment the current level or a higher level in the hierarchy.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a default counter
    HCounter(int init)
    Create a counter starting at a specified integer
    HCounter(int[] init)
    Create a counter starting at the specified location
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    after(String input)
    IS the current value after (or equal to) this input?
    boolean
    before(String input)
    Is the current value before (or equal to) this input?
    int
    compare(String input)
    Does the given string come before or after the current value.
    void
    Add a new level to the counter hierarchy starting at 1.
    void
    down(int i)
    Add a new level to the counter hierarcy starting at a specified value.
    void
    Increment the deepest level of the counter
    void
    increment(int level)
    Increment a specific level of the counter.
    int
    How many levels in the hierarchy currently in the counter?
    static void
    main(String[] args)
    Run some simple tests.
    What is the current value of the counter expressed as a string?
    void
    up()
    Discard a level in the hierarchy.

    Methods inherited from class java.lang.Object

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

    • HCounter

      public HCounter()
      Create a default counter
    • HCounter

      public HCounter(int init)
      Create a counter starting at a specified integer
    • HCounter

      public HCounter(int[] init)
      Create a counter starting at the specified location
  • Method Details

    • levels

      public int levels()
      How many levels in the hierarchy currently in the counter?
    • toString

      public String toString()
      What is the current value of the counter expressed as a string?
      Overrides:
      toString in class Object
    • increment

      public void increment()
      Increment the deepest level of the counter
    • increment

      public void increment(int level)
      Increment a specific level of the counter. If this is not the deepest level of the counter the counter will lose the deeper levels.
      Parameters:
      level -
    • down

      public void down()
      Add a new level to the counter hierarchy starting at 1.
    • down

      public void down(int i)
      Add a new level to the counter hierarcy starting at a specified value.
    • up

      public void up()
      Discard a level in the hierarchy.
    • before

      public boolean before(String input)
      Is the current value before (or equal to) this input?
    • after

      public boolean after(String input)
      IS the current value after (or equal to) this input?
    • compare

      public int compare(String input)
      Does the given string come before or after the current value. The following sequence is increasing: 1 1.1 1.2 1.2.1 1.2.2 1.3. Returns -1 if the current value comes before the input string, 0 if they are equal or 1 if the current value comes after the input.
    • main

      public static void main(String[] args)
      Run some simple tests.