Package adams.core
Class AbstractDataBackedUnorderedRange<T>
- java.lang.Object
-
- adams.core.UnorderedRange
-
- adams.core.AbstractDataBackedUnorderedRange<T>
-
- Type Parameters:
T
- the type of the underlying data
- All Implemented Interfaces:
CloneHandler<UnorderedRange>
,CustomDisplayStringProvider
,ExampleProvider
,HelpProvider
,Serializable
,Comparable<UnorderedRange>
- Direct Known Subclasses:
SpreadSheetUnorderedColumnRange
,SpreadSheetUnorderedRowRange
,WekaUnorderedAttributeRange
public abstract class AbstractDataBackedUnorderedRange<T> extends UnorderedRange
Ancestor for unordered range classes that allow additional names in the range string, just like placeholders for 'first', 'second', etc). If names contain "-" or "," then they need to be surrounded by double-quotes.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractDataBackedUnorderedRange.InvertedStringLengthComparator
Simply compares the length of the strings, with longer strings rating lower.
-
Constructor Summary
Constructors Constructor Description AbstractDataBackedUnorderedRange()
Initializes with no range.AbstractDataBackedUnorderedRange(String range)
Initializes with the given range, but no maximum.AbstractDataBackedUnorderedRange(String range, int max)
Initializes with the given range and maximum.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AbstractDataBackedUnorderedRange<T>
getClone()
Returns a clone of the object.T
getData()
Returns the underlying data.int[]
getIntIndices(T data)
Returns the integer indices.protected abstract String
getName(T data, int colIndex)
Returns the name at the specified index.protected abstract int
getNumNames(T data)
Returns the number of names the data has.protected void
initialize()
For initializing the object.boolean
isInRange(T data, int index)
Checks whether the provided 0-based index is within the range.void
setData(T value)
Sets the data to use for interpreting the names.-
Methods inherited from class adams.core.UnorderedRange
compareTo, getExample, getHelpDescription, getHelpIcon, getHelpTitle, getHelpURL, getIntIndices, getMax, getRange, hasRange, isAllRange, isEmpty, isInRange, isValid, parse, parseSubRange, reset, setIndices, setIndices, setMax, setRange, splitRange, toDisplay, toExplicitRange, toRange, toString
-
-
-
-
Field Detail
-
m_Data
protected T m_Data
the underlying dataset.
-
-
Constructor Detail
-
AbstractDataBackedUnorderedRange
public AbstractDataBackedUnorderedRange()
Initializes with no range.
-
AbstractDataBackedUnorderedRange
public AbstractDataBackedUnorderedRange(String range)
Initializes with the given range, but no maximum.- Parameters:
range
- the range to use
-
AbstractDataBackedUnorderedRange
public AbstractDataBackedUnorderedRange(String range, int max)
Initializes with the given range and maximum.- Parameters:
range
- the range to usemax
- the maximum of the 1-based index (e.g., use "10" to allow "1-10" or -1 for uninitialized)
-
-
Method Detail
-
initialize
protected void initialize()
For initializing the object.- Overrides:
initialize
in classUnorderedRange
-
getClone
public AbstractDataBackedUnorderedRange<T> getClone()
Returns a clone of the object.- Specified by:
getClone
in interfaceCloneHandler<T>
- Overrides:
getClone
in classUnorderedRange
- Returns:
- the clone
-
setData
public void setData(T value)
Sets the data to use for interpreting the names.- Parameters:
value
- the data to use, can be null
-
getData
public T getData()
Returns the underlying data.- Returns:
- the underlying data, null if none set
-
getIntIndices
public int[] getIntIndices(T data)
Returns the integer indices. Gets always generated on-the-fly! Uses on a clone of itself as not to keep a reference to the data.- Parameters:
data
- the data to use for the indices- Returns:
- the indices, 0-length array if not possible
-
isInRange
public boolean isInRange(T data, int index)
Checks whether the provided 0-based index is within the range. Uses on a clone of itself as not to keep a reference to the data.- Parameters:
data
- the data to use for the indicesindex
- the index to check- Returns:
- true if in range
-
getNumNames
protected abstract int getNumNames(T data)
Returns the number of names the data has.- Parameters:
data
- the data to retrieve the number of names
-
-