public class SingleIndex extends java.lang.Object implements java.io.Serializable, RevisionHandler, CustomDisplayStringProvider
first
last
1
3
The number is internally converted from 1-based to 0-based (so methods that set or get numbers not in string format should use 0-based numbers).
Constructor and Description |
---|
SingleIndex()
Default constructor.
|
SingleIndex(java.lang.String index)
Constructor to set initial index.
|
Modifier and Type | Method and Description |
---|---|
int |
getIndex()
Gets the selected index.
|
java.lang.String |
getRevision()
Returns the revision string.
|
java.lang.String |
getSingleIndex()
Gets the string representing the selected range of values.
|
static java.lang.String |
indexToString(int index)
Creates a string representation of the given index.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
void |
setSingleIndex(java.lang.String index)
Sets the index from a string representation.
|
void |
setUpper(int newUpper)
Sets the value of "last".
|
java.lang.String |
toDisplay()
Returns the custom display string.
|
java.lang.String |
toString()
Constructs a representation of the current range.
|
public SingleIndex()
public SingleIndex(java.lang.String index)
index
- the initial indexjava.lang.IllegalArgumentException
- if the index is invalidpublic void setUpper(int newUpper)
newUpper
- the value of "last"public java.lang.String getSingleIndex()
public void setSingleIndex(java.lang.String index)
index
- the index setjava.lang.IllegalArgumentException
- if the index was not well formedpublic java.lang.String toString()
toString
in class java.lang.Object
public int getIndex()
java.lang.RuntimeException
- if the upper limit of the index hasn't been definedpublic static java.lang.String indexToString(int index)
index
- the index to turn into a string.
Since the index will typically come from a program, indices are assumed
from 0, and thus will have 1 added in the String representation.public java.lang.String getRevision()
getRevision
in interface RevisionHandler
public java.lang.String toDisplay()
toDisplay
in interface CustomDisplayStringProvider
public static void main(java.lang.String[] argv)
argv
- one parameter: a test index specification