Package skyview.test
Class HCounter
java.lang.Object
skyview.test.HCounter
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 -
Method Summary
Modifier and TypeMethodDescriptionboolean
IS the current value after (or equal to) this input?boolean
Is the current value before (or equal to) this input?int
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 the deepest level of the countervoid
increment
(int level) Increment a specific level of the counter.int
levels()
How many levels in the hierarchy currently in the counter?static void
Run some simple tests.toString()
What is the current value of the counter expressed as a string?void
up()
Discard a level in the hierarchy.
-
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
What is the current value of the counter expressed as a string? -
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
Is the current value before (or equal to) this input? -
after
IS the current value after (or equal to) this input? -
compare
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
Run some simple tests.
-