adams.data.spreadsheet
Class SpreadSheetColumnRange

java.lang.Object
  extended by adams.core.Range
      extended by adams.data.spreadsheet.SpreadSheetColumnRange
All Implemented Interfaces:
CustomDisplayStringProvider, ExampleProvider, Serializable, Comparable<Range>

public class SpreadSheetColumnRange
extends Range

Extended Range class that also allows column names for specifying column positions (names are case-insensitive, just like placeholders for 'first', 'second', etc). If column names contain "-" or "," then they need to be surrounded by double-quotes.

Version:
$Revision: 6867 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class adams.core.Range
Range.SubRange
 
Field Summary
protected  HashMap<String,Integer> m_Indices
          the indices of the column names.
protected  List<String> m_Names
          the column names to replace.
protected  SpreadSheet m_Sheet
          the underlying spreadsheet.
 
Fields inherited from class adams.core.Range
ALL, FIRST, INV_END, INV_START, LAST, LAST_1, LAST_2, m_ActualRange, m_Inverted, m_Max, m_Range, m_Raw, m_SubRanges, RANGE, SECOND, SEPARATOR, THIRD
 
Constructor Summary
SpreadSheetColumnRange()
          Initializes with no range.
SpreadSheetColumnRange(String range)
          Initializes with the given range, but no maximum.
SpreadSheetColumnRange(String range, int max)
          Initializes with the given range and maximum.
 
Method Summary
protected  boolean canReplaceInvalidChars()
          Returns whether invalid characters should get removed.
 HashMap<String,Integer> getIndices()
          Returns the indices in use.
protected  List<String> getNames()
          Returns the column names.
protected  List<String> getPlaceholders()
          Returns the placeholders to allow in the ranges.
 SpreadSheet getSpreadSheet()
          Returns the underlying spreadsheet.
protected  void initialize()
          For initializing the object.
protected  boolean isColumnName(String s)
          Checks whether the strings represents a column name.
protected  int parse(String s, int max)
          Parses the 1-based index, 'first' and 'last' are accepted as well.
 void setSpreadSheet(SpreadSheet value)
          Sets the spreadsheet to use for interpreting the column name.
protected  String[] splitList(String s)
          Attempts to split a list into the parts resembling it.
protected  String[] splitRange(String s)
          Attempts to split a range into the parts resembling it.
 
Methods inherited from class adams.core.Range
clean, compareTo, equals, getActualRange, getExample, getIntIndices, getIntSegments, getMax, getRange, getSubRanges, hashCode, hasRange, isInRange, isInverted, isPlaceholder, isValid, parse, parse, parsePlaceholder, removeInvalidChars, removeInvalidChars, reset, setIndices, setIndices, setInverted, setMax, setRange, toDisplay, toExplicitRange, toRange, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Sheet

protected SpreadSheet m_Sheet
the underlying spreadsheet.


m_Names

protected List<String> m_Names
the column names to replace.


m_Indices

protected HashMap<String,Integer> m_Indices
the indices of the column names.

Constructor Detail

SpreadSheetColumnRange

public SpreadSheetColumnRange()
Initializes with no range.


SpreadSheetColumnRange

public SpreadSheetColumnRange(String range)
Initializes with the given range, but no maximum.

Parameters:
range - the range to use

SpreadSheetColumnRange

public SpreadSheetColumnRange(String range,
                              int max)
Initializes with the given range and maximum.

Parameters:
range - the range to use
max - 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 class Range

setSpreadSheet

public void setSpreadSheet(SpreadSheet value)
Sets the spreadsheet to use for interpreting the column name.

Parameters:
value - the spreadsheet to use, can be null

getSpreadSheet

public SpreadSheet getSpreadSheet()
Returns the underlying spreadsheet.

Returns:
the underlying spreadsheet, null if none set

getNames

protected List<String> getNames()
Returns the column names.

Returns:
the column names

getIndices

public HashMap<String,Integer> getIndices()
Returns the indices in use.

Returns:
the indices

isColumnName

protected boolean isColumnName(String s)
Checks whether the strings represents a column name.

Parameters:
s - the string to process
Returns:
true if string is a column name

getPlaceholders

protected List<String> getPlaceholders()
Returns the placeholders to allow in the ranges. This includes the column names.

Overrides:
getPlaceholders in class Range
Returns:
the placeholders
See Also:
getNames()

canReplaceInvalidChars

protected boolean canReplaceInvalidChars()
Returns whether invalid characters should get removed.

Overrides:
canReplaceInvalidChars in class Range
Returns:
true if to replace invalid chars

splitRange

protected String[] splitRange(String s)
Attempts to split a range into the parts resembling it.

Overrides:
splitRange in class Range
Parameters:
s - the string to split
Returns:
the parts (single array element if no range)

splitList

protected String[] splitList(String s)
Attempts to split a list into the parts resembling it.

Overrides:
splitList in class Range
Parameters:
s - the string to split
Returns:
the parts (single array element if no list)

parse

protected int parse(String s,
                    int max)
Parses the 1-based index, 'first' and 'last' are accepted as well.

Overrides:
parse in class Range
Parameters:
s - the string to parse
max - the maximum value to use
Returns:
the 0-based index


Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.