Package skyview.test

Class HCounter

java.lang.Object
skyview.test.HCounter

public class HCounter
extends java.lang.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
    HCounter()
    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​(java.lang.String input)
    IS the current value after (or equal to) this input?
    boolean before​(java.lang.String input)
    Is the current value before (or equal to) this input?
    int compare​(java.lang.String input)
    Does the given string come before or after the current value.
    void down()
    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()
    Increment the deepest level of the counter
    void increment​(int level)
    Increment a specific level of the counter.
    int levels()
    How many levels in the hierarchy currently in the counter?
    static void main​(java.lang.String[] args)
    Run some simple tests.
    java.lang.String toString()
    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 java.lang.String toString()
      What is the current value of the counter expressed as a string?
      Overrides:
      toString in class java.lang.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​(java.lang.String input)
      Is the current value before (or equal to) this input?
    • after

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

      public int compare​(java.lang.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​(java.lang.String[] args)
      Run some simple tests.