Package adams.parser.spreadsheetquery
Class ParserHelper
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.parser.ParserHelper
-
- adams.parser.spreadsheetquery.ParserHelper
-
- All Implemented Interfaces:
LoggingSupporter,SizeOfHandler,Serializable
public class ParserHelper extends ParserHelper
Helper class for spreadsheet formulas.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_Aggregatewhether to aggregate.protected HashMap<SpreadSheetAggregate.Aggregate,List<String>>m_Aggregatesthe aggregates to generate (aggregate - list of columns).protected booleanm_AllColumnswhether all columns are retrieved.protected List<String>m_Columnsthe columns to retrieve.protected DateFormatm_DateFormatfor formatting dates.protected booleanm_Deletewhether to delete rows.protected List<String>m_GroupByColumnsthe group by columns to retrieve.protected intm_LimitMaxthe limit.protected intm_LimitOffsetthe offset for the limit.protected HashMap<String,String>m_RenameColumnsthe columns to rename.protected HashMap<String,String>m_RenamedAggregatesthe new names for the aggregates (old - new).protected List<RowFinder>m_RowFindersthe row finders to use.protected int[]m_Rowsthe rows to select.protected booleanm_Selectwhether to create subset.protected SpreadSheetm_Sheetthe underlying spreadsheet.protected List<Boolean>m_SortAscthe columns to sort on.protected List<String>m_SortColumnsthe columns to sort on.protected SubProcessm_SubProcessthe partial flow for converting the spreadsheet.protected RowFinderm_Subsamplethe rowfinder to use for generating a subsample.protected booleanm_Updatewhether to update cells.protected HashMap<String,Object>m_UpdateColumnsthe columns to update (column - new value).-
Fields inherited from class adams.parser.ParserHelper
m_BusinessDays, m_Calendar, m_Functions, m_Procedures, m_Symbols
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description ParserHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAggregate(SpreadSheetAggregate.Aggregate agg, String col)Adds the aggregate to generate from a column.voidaddColumn(String col)Adds the name of a column to return.voidaddGroupByColumn(String col)Adds the name of a group by column.voidaddSortColumn(String col, boolean asc)Adds the name of a sort column.voidaddUpdateColumn(String col, Object value)Adds the name of a column to update with a new value.voidaggregate()Sets to create subset from aggregates.int[]applyRowFinder(RowFinder finder, String log)Applies the row finder.int[]combineWithAnd(int[] c1, int[] c2)Combines the row finders with logical AND.int[]combineWithOr(int[] c1, int[] c2)Combines the row finders with logical OR.voiddelete()Sets to delete rows.DateFormatgetDateFormat()Returns the date formatter.DateFormatStringgetDateFormatString()Returns the format string of the current date/time format.SpreadSheetgetResult()Returns the result of the evaluation.int[]getRows()Returns the rows to use.SpreadSheetgetSheet()Returns the current spreadsheet in use.SubProcessgetSubProcess()Returns the partial flow that was generated to process the spreadsheet.protected voidinitialize()Initializes the members.int[]invert(int[] c)Inverts the row finders.voidrenameAggregate(SpreadSheetAggregate.Aggregate agg, String col, String newCol)Sets the new column name for the aggregate generated from a column.voidrenameColumn(String col, String newCol)Adds the name of a column to rename.voidselect()Sets to create subset.voidsetLimit(int offset, int max)Sets the limit.voidsetRows(int[] value)Sets the rows to use.voidsetSheet(SpreadSheet value)Sets the spreadsheet to use.voidsetSubsampleRowFinder(RowFinder finder, String log)Sets the row finder to generate a subsample.voidupdate()Sets to update cells.voiduseAllColumns()Sets to return all columns.-
Methods inherited from class adams.parser.ParserHelper
add, adjustAmount, callFunction, callProcedure, compare, getBusinessDays, getCalendar, getCalendar, getDateFieldFromString, getFunction, getFunctionOverview, getProcedure, getProcedureOverview, getSymbols, initFunctions, initProcedures, isBusinessDay, left, mid, repeat, replace, reportToSymbols, right, setBusinessDays, setSymbols, substitute, substitute, toBoolean, toDate, toDouble, toInteger, toNumber, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Sheet
protected SpreadSheet m_Sheet
the underlying spreadsheet.
-
m_AllColumns
protected boolean m_AllColumns
whether all columns are retrieved.
-
m_Select
protected boolean m_Select
whether to create subset.
-
m_Delete
protected boolean m_Delete
whether to delete rows.
-
m_Update
protected boolean m_Update
whether to update cells.
-
m_Aggregate
protected boolean m_Aggregate
whether to aggregate.
-
m_UpdateColumns
protected HashMap<String,Object> m_UpdateColumns
the columns to update (column - new value).
-
m_Subsample
protected RowFinder m_Subsample
the rowfinder to use for generating a subsample.
-
m_SubProcess
protected SubProcess m_SubProcess
the partial flow for converting the spreadsheet.
-
m_Rows
protected int[] m_Rows
the rows to select.
-
m_LimitMax
protected int m_LimitMax
the limit.
-
m_LimitOffset
protected int m_LimitOffset
the offset for the limit.
-
m_Aggregates
protected HashMap<SpreadSheetAggregate.Aggregate,List<String>> m_Aggregates
the aggregates to generate (aggregate - list of columns).
-
m_RenamedAggregates
protected HashMap<String,String> m_RenamedAggregates
the new names for the aggregates (old - new).
-
m_DateFormat
protected DateFormat m_DateFormat
for formatting dates.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classParserHelper
-
setSheet
public void setSheet(SpreadSheet value)
Sets the spreadsheet to use.- Parameters:
value- the spreadsheet
-
getSheet
public SpreadSheet getSheet()
Returns the current spreadsheet in use.- Returns:
- the spreadsheet
-
getDateFormat
public DateFormat getDateFormat()
Returns the date formatter.- Returns:
- the formatter
-
getDateFormatString
public DateFormatString getDateFormatString()
Returns the format string of the current date/time format.- Returns:
- the format string
- See Also:
getDateFormat()
-
useAllColumns
public void useAllColumns()
Sets to return all columns.
-
addColumn
public void addColumn(String col)
Adds the name of a column to return.- Parameters:
col- the column name
-
renameColumn
public void renameColumn(String col, String newCol)
Adds the name of a column to rename.- Parameters:
col- the current column namenewCol- the new column name
-
addSortColumn
public void addSortColumn(String col, boolean asc)
Adds the name of a sort column.- Parameters:
col- the column nameasc- whether to sort ascending
-
addUpdateColumn
public void addUpdateColumn(String col, Object value)
Adds the name of a column to update with a new value.- Parameters:
col- the column namevalue- the new value
-
addAggregate
public void addAggregate(SpreadSheetAggregate.Aggregate agg, String col)
Adds the aggregate to generate from a column.- Parameters:
agg- the aggregatecol- the column name, null if COUNT
-
renameAggregate
public void renameAggregate(SpreadSheetAggregate.Aggregate agg, String col, String newCol)
Sets the new column name for the aggregate generated from a column.- Parameters:
agg- the aggregatecol- the column name, null if COUNTnewCol- the new column name
-
addGroupByColumn
public void addGroupByColumn(String col)
Adds the name of a group by column.- Parameters:
col- the column name
-
applyRowFinder
public int[] applyRowFinder(RowFinder finder, String log)
Applies the row finder.- Parameters:
finder- the row finder to applylog- a logging message- Returns:
- the selected rows
-
setSubsampleRowFinder
public void setSubsampleRowFinder(RowFinder finder, String log)
Sets the row finder to generate a subsample.- Parameters:
finder- the row finder to applylog- a logging message
-
select
public void select()
Sets to create subset.
-
delete
public void delete()
Sets to delete rows.
-
update
public void update()
Sets to update cells.
-
aggregate
public void aggregate()
Sets to create subset from aggregates.
-
combineWithAnd
public int[] combineWithAnd(int[] c1, int[] c2)Combines the row finders with logical AND.- Parameters:
c1- the first set of rowsc2- the second set of rows- Returns:
- the combined rows
-
combineWithOr
public int[] combineWithOr(int[] c1, int[] c2)Combines the row finders with logical OR.- Parameters:
c1- the first set of rowsc2- the second set of rows- Returns:
- the combined rows
-
invert
public int[] invert(int[] c)
Inverts the row finders.- Parameters:
c- the rows to invert- Returns:
- the inverted rows
-
setLimit
public void setLimit(int offset, int max)Sets the limit.- Parameters:
offset- the offset (0 is offset for first row)max- the maximum number of rows (>= 1)
-
setRows
public void setRows(int[] value)
Sets the rows to use.- Parameters:
value- the rows
-
getRows
public int[] getRows()
Returns the rows to use.- Returns:
- the rows
-
getSubProcess
public SubProcess getSubProcess()
Returns the partial flow that was generated to process the spreadsheet.- Returns:
- the partial flow, null if none available
-
getResult
public SpreadSheet getResult()
Returns the result of the evaluation.- Returns:
- the result
-
-