All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.core.Range

java.lang.Object
    |
    +----weka.core.Range

public class Range
extends java.lang.Object
implements java.io.Serializable
Class representing a range of cardinal numbers. The range is set by a string representation such as:

all first-last 1,2,3,4

or combinations thereof. The range 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.10 $
Author:
Len Trigg (trigg@cs.waikato.ac.nz)

Constructor Index

 o Range()
Default constructor.
 o Range(String)
Constructor to set initial range.

Method Index

 o getInvert()
Gets whether the range sense is inverted, i.e.
 o getRanges()
Gets the string representing the selected range of values
 o getSelection()
Gets an array containing all the selected values, in the order that they were selected (or ascending order if range inversion is on)
 o indicesToRangeList(int[])
Creates a string representation of the indices in the supplied array.
 o isInRange(int)
Gets whether the supplied cardinal number is included in the current range.
 o main(String[])
Main method for testing this class.
 o setInvert(boolean)
Sets whether the range sense is inverted, i.e.
 o setRanges(String)
Sets the ranges from a string representation.
 o setUpper(int)
Sets the value of "last".
 o toString()
Constructs a representation of the current range.

Constructor Detail

 o Range
public Range()
          Default constructor.
 o Range
public Range(java.lang.String rangeList)
          Constructor to set initial range.
Parameters:
rangeList - the initial range
Throws:
java.lang.IllegalArgumentException - if the range list is invalid

Method Detail

 o setUpper
public void setUpper(int newUpper)
          Sets the value of "last".
Parameters:
newUpper - the value of "last"
 o getInvert
public boolean getInvert()
          Gets whether the range sense is inverted, i.e. all except the values included by the range string are selected.
Returns:
whether the matching sense is inverted
 o setInvert
public void setInvert(boolean newSetting)
          Sets whether the range sense is inverted, i.e. all except the values included by the range string are selected.
Parameters:
newSetting - true if the matching sense is inverted
 o getRanges
public java.lang.String getRanges()
          Gets the string representing the selected range of values
Returns:
the range selection string
 o setRanges
public void setRanges(java.lang.String rangeList)
          Sets the ranges from a string representation.
Parameters:
rangeList - the comma separated list of ranges. The empty string sets the range to empty.
Throws:
java.lang.IllegalArgumentException - if the rangeList was not well formed
 o isInRange
public boolean isInRange(int index)
          Gets whether the supplied cardinal number is included in the current range.
Parameters:
index - the number of interest
Returns:
true if index is in the current range
Throws:
java.lang.RuntimeException - if the upper limit of the range hasn't been defined
 o 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
Overrides:
toString in class java.lang.Object
 o getSelection
public int[] getSelection()
          Gets an array containing all the selected values, in the order that they were selected (or ascending order if range inversion is on)
Returns:
the array of selected values
Throws:
java.lang.RuntimeException - if the upper limit of the range hasn't been defined
 o indicesToRangeList
public static java.lang.String indicesToRangeList(int indices[])
          Creates a string representation of the indices in the supplied array.
Parameters:
indices - an array containing indices to select. Since the array will typically come from a program, indices are assumed from 0, and thus will have 1 added in the String representation.
 o main
public static void main(java.lang.String argv[])
          Main method for testing this class.
Parameters:
argv - one parameter: a test range specification

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home