weka.core
Class SingleIndex

java.lang.Object
  extended byweka.core.SingleIndex
All Implemented Interfaces:
java.io.Serializable

public class SingleIndex
extends java.lang.Object
implements java.io.Serializable

Class representing a single cardinal number. The number is set by a string representation such as:

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).

Version:
$Revision: 1.1 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
protected  java.lang.String m_IndexString
          Record the string representation of the number
protected  int m_SelectedIndex
          The selected index
protected  int m_Upper
          Store the maximum value permitted. -1 indicates that no upper value has been set
 
Constructor Summary
SingleIndex()
          Default constructor.
SingleIndex(java.lang.String index)
          Constructor to set initial index.
 
Method Summary
 int getIndex()
          Gets the selected index
 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".
protected  void setValue()
          Translates a single string selection into it's internal 0-based equivalent
 java.lang.String toString()
          Constructs a representation of the current range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_IndexString

protected java.lang.String m_IndexString
Record the string representation of the number


m_SelectedIndex

protected int m_SelectedIndex
The selected index


m_Upper

protected int m_Upper
Store the maximum value permitted. -1 indicates that no upper value has been set

Constructor Detail

SingleIndex

public SingleIndex()
Default constructor.


SingleIndex

public SingleIndex(java.lang.String index)
Constructor to set initial index.

Throws:
java.lang.IllegalArgumentException - if the index is invalid
Method Detail

setUpper

public void setUpper(int newUpper)
Sets the value of "last".

Parameters:
newUpper - the value of "last"

getSingleIndex

public java.lang.String getSingleIndex()
Gets the string representing the selected range of values

Returns:
the range selection string

setSingleIndex

public void setSingleIndex(java.lang.String index)
Sets the index from a string representation. Note that setUpper() must be called for the value to be actually set

Parameters:
index - the index set
Throws:
java.lang.IllegalArgumentException - if the index was not well formed

toString

public java.lang.String toString()
Constructs a representation of the current range. Being a string representation, the numbers are based from 1.

Returns:
the string representation of the current range

getIndex

public int getIndex()
Gets the selected index

Returns:
the selected index
Throws:
java.lang.RuntimeException - if the upper limit of the index hasn't been defined

indexToString

public static java.lang.String indexToString(int index)
Creates a string representation of the given index.


setValue

protected void setValue()
Translates a single string selection into it's internal 0-based equivalent

Returns:
the number corresponding to the selected value

main

public static void main(java.lang.String[] argv)
Main method for testing this class.

Parameters:
argv - one parameter: a test index specification