|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.Range
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).
Field Summary | |
(package private) boolean |
m_Invert
Whether matching should be inverted |
(package private) java.util.Vector |
m_RangeStrings
Record the string representations of the columns to delete |
(package private) boolean[] |
m_SelectFlags
The array of flags for whether an column is selected |
(package private) int |
m_Upper
Store the maximum value permitted in the range. -1 indicates that no upper value has been set |
Constructor Summary | |
Range()
Default constructor. |
|
Range(java.lang.String rangeList)
Constructor to set initial range. |
Method Summary | |
boolean |
getInvert()
Gets whether the range sense is inverted, i.e. all except the values included by the range string are selected. |
java.lang.String |
getRanges()
Gets the string representing the selected range of values |
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) |
static java.lang.String |
indicesToRangeList(int[] indices)
Creates a string representation of the indices in the supplied array. |
boolean |
isInRange(int index)
Gets whether the supplied cardinal number is included in the current range. |
protected boolean |
isValidRange(java.lang.String range)
Determines if a string represents a valid index or simple range. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
protected int |
rangeLower(java.lang.String range)
Translates a range into it's lower index. |
protected int |
rangeSingle(java.lang.String single)
Translates a single string selection into it's internal 0-based equivalent |
protected int |
rangeUpper(java.lang.String range)
Translates a range into it's upper index. |
protected void |
setFlags()
Sets the flags array. |
void |
setInvert(boolean newSetting)
Sets whether the range sense is inverted, i.e. all except the values included by the range string are selected. |
void |
setRanges(java.lang.String rangeList)
Sets the ranges from a string representation. |
void |
setUpper(int newUpper)
Sets the value of "last". |
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 |
java.util.Vector m_RangeStrings
boolean m_Invert
boolean[] m_SelectFlags
int m_Upper
Constructor Detail |
public Range()
public Range(java.lang.String rangeList)
rangeList
- the initial range
java.lang.IllegalArgumentException
- if the range list is invalidMethod Detail |
public void setUpper(int newUpper)
newUpper
- the value of "last"public boolean getInvert()
public void setInvert(boolean newSetting)
newSetting
- true if the matching sense is invertedpublic java.lang.String getRanges()
public void setRanges(java.lang.String rangeList)
rangeList
- the comma separated list of ranges. The empty
string sets the range to empty.
java.lang.IllegalArgumentException
- if the rangeList was not well formedpublic boolean isInRange(int index)
index
- the number of interest
java.lang.RuntimeException
- if the upper limit of the range hasn't been definedpublic java.lang.String toString()
public int[] getSelection()
java.lang.RuntimeException
- if the upper limit of the range hasn't been definedpublic static java.lang.String indicesToRangeList(int[] indices)
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.protected void setFlags()
protected int rangeSingle(java.lang.String single)
single
- the string representing the selection (eg: 1 first last)
protected int rangeLower(java.lang.String range)
range
- the string representation of the range
protected int rangeUpper(java.lang.String range)
range
- the string representation of the range
protected boolean isValidRange(java.lang.String range)
first last 2 first-last first-4 4-last
Doesn't check that a < b for a-b
range
-
public static void main(java.lang.String[] argv)
argv
- one parameter: a test range specification
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |