adams.data.conversion
Class AggregateSpreadSheet

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.data.conversion.AbstractConversion
              extended by adams.data.conversion.AbstractSpreadSheetConversion
                  extended by adams.data.conversion.AggregateSpreadSheet
All Implemented Interfaces:
CleanUpHandler, Debuggable, Destroyable, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<AbstractConversion>, SizeOfHandler, Conversion, Serializable

public class AggregateSpreadSheet
extends AbstractSpreadSheetConversion

Aggregates rows (min, max, avg, etc) in a spreadsheet using key columns.
All numeric columns in the specified aggregrate range (excluding the key columns) get aggregated. For each of the specified aggregates a new column is generated.

Valid options are:

-D <int> (property: debugLevel)
    The greater the number the more additional info the scheme may output to 
    the console (0 = off).
    default: 0
    minimum: 0
 
-key-columns <adams.core.Range> (property: keyColumns)
    The columns to use as keys for identifying rows in the spreadsheets; A range 
    is a comma-separated list of single 1-based indices or sub-ranges of indices 
    ('start-en2d'); 'inv(...)' inverts the range '...'; the following placeholders 
    can be used as well: first, second, third, last_2, last_1, last
    default: first
 
-aggregate-columns <adams.core.Range> (property: aggregateColumns)
    The columns to aggregate (only numeric ones will be used); A range is a 
    comma-separated list of single 1-based indices or sub-ranges of indices 
    ('start-end'); 'inv(...)' inverts the range '...'; the following placeholders 
    can be used as well: first, second, third, last_2, last_1, last
    default: first-last
 
-aggregate <SUM|MIN|MAX|AVERAGE|MEDIAN|STDEV|STDEVP|INTERQUARTILE> [-aggregate ...] (property: aggregates)
    The aggregates to calculate and introduce as columns.
    default: SUM
 

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

Nested Class Summary
static class AggregateSpreadSheet.Aggregate
          The types of aggregates to generate.
 
Field Summary
protected  Range m_AggregateColumns
          the range of columns to aggregate.
protected  AggregateSpreadSheet.Aggregate[] m_Aggregates
          the aggregates to generate.
protected  Range m_KeyColumns
          the range of column indices to use as key for identifying a row.
 
Fields inherited from class adams.data.conversion.AbstractConversion
m_Input, m_Output, m_Owner
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
AggregateSpreadSheet()
           
 
Method Summary
 String aggregateColumnsTipText()
          Returns the tip text for this property.
 String aggregatesTipText()
          Returns the tip text for this property.
protected  double computeAggregate(SpreadSheet input, List<Integer> subset, Row rowNew, int index, AggregateSpreadSheet.Aggregate agg)
          Computes the aggregate.
protected  SpreadSheet convert(SpreadSheet input)
          Generates the new spreadsheet from the input.
 void defineOptions()
          Adds options to the internal list of options.
 Range getAggregateColumns()
          Returns the colums that should get aggregated.
 AggregateSpreadSheet.Aggregate[] getAggregates()
          Returns the aggregates to calculate.
 Range getKeyColumns()
          Returns the colums that identify a rowx
 String globalInfo()
          Returns a string describing the object.
 String keyColumnsTipText()
          Returns the tip text for this property.
 void setAggregateColumns(Range value)
          Sets the colums that should get aggregated.
 void setAggregates(AggregateSpreadSheet.Aggregate[] value)
          Sets the aggregates to calculate.
 void setKeyColumns(Range value)
          Sets the colums that identify a row.
 
Methods inherited from class adams.data.conversion.AbstractSpreadSheetConversion
accepts, doConvert, generates
 
Methods inherited from class adams.data.conversion.AbstractConversion
checkData, cleanUp, convert, getInput, getOutput, getOwner, getQuickInfo, reset, setInput, setOwner, shallowCopy, shallowCopy
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, initialize, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_KeyColumns

protected Range m_KeyColumns
the range of column indices to use as key for identifying a row.


m_AggregateColumns

protected Range m_AggregateColumns
the range of columns to aggregate.


m_Aggregates

protected AggregateSpreadSheet.Aggregate[] m_Aggregates
the aggregates to generate.

Constructor Detail

AggregateSpreadSheet

public AggregateSpreadSheet()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractOptionHandler

setKeyColumns

public void setKeyColumns(Range value)
Sets the colums that identify a row.

Parameters:
value - the range

getKeyColumns

public Range getKeyColumns()
Returns the colums that identify a rowx

Returns:
the range

keyColumnsTipText

public String keyColumnsTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setAggregateColumns

public void setAggregateColumns(Range value)
Sets the colums that should get aggregated.

Parameters:
value - the range

getAggregateColumns

public Range getAggregateColumns()
Returns the colums that should get aggregated.

Returns:
the range

aggregateColumnsTipText

public String aggregateColumnsTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setAggregates

public void setAggregates(AggregateSpreadSheet.Aggregate[] value)
Sets the aggregates to calculate.

Parameters:
value - the aggregates

getAggregates

public AggregateSpreadSheet.Aggregate[] getAggregates()
Returns the aggregates to calculate.

Returns:
the aggregates

aggregatesTipText

public String aggregatesTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

computeAggregate

protected double computeAggregate(SpreadSheet input,
                                  List<Integer> subset,
                                  Row rowNew,
                                  int index,
                                  AggregateSpreadSheet.Aggregate agg)
Computes the aggregate.

Parameters:
input - the original sheet
subset - the subset of rows to use for the computation
rowNew - the row to add the aggregate to
index - the column in the original spreadsheet
agg - the aggregate to compute
Returns:
the computed value

convert

protected SpreadSheet convert(SpreadSheet input)
                       throws Exception
Generates the new spreadsheet from the input.

Specified by:
convert in class AbstractSpreadSheetConversion
Parameters:
input - the incoming spreadsheet
Returns:
the generated spreadsheet
Throws:
Exception - if conversion fails for some reason


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