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 boolean
m_Aggregate
whether to aggregate.protected HashMap<SpreadSheetAggregate.Aggregate,List<String>>
m_Aggregates
the aggregates to generate (aggregate - list of columns).protected boolean
m_AllColumns
whether all columns are retrieved.protected List<String>
m_Columns
the columns to retrieve.protected DateFormat
m_DateFormat
for formatting dates.protected boolean
m_Delete
whether to delete rows.protected List<String>
m_GroupByColumns
the group by columns to retrieve.protected int
m_LimitMax
the limit.protected int
m_LimitOffset
the offset for the limit.protected HashMap<String,String>
m_RenameColumns
the columns to rename.protected HashMap<String,String>
m_RenamedAggregates
the new names for the aggregates (old - new).protected List<RowFinder>
m_RowFinders
the row finders to use.protected int[]
m_Rows
the rows to select.protected boolean
m_Select
whether to create subset.protected SpreadSheet
m_Sheet
the underlying spreadsheet.protected List<Boolean>
m_SortAsc
the columns to sort on.protected List<String>
m_SortColumns
the columns to sort on.protected SubProcess
m_SubProcess
the partial flow for converting the spreadsheet.protected RowFinder
m_Subsample
the rowfinder to use for generating a subsample.protected boolean
m_Update
whether to update cells.protected HashMap<String,Object>
m_UpdateColumns
the 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 void
addAggregate(SpreadSheetAggregate.Aggregate agg, String col)
Adds the aggregate to generate from a column.void
addColumn(String col)
Adds the name of a column to return.void
addGroupByColumn(String col)
Adds the name of a group by column.void
addSortColumn(String col, boolean asc)
Adds the name of a sort column.void
addUpdateColumn(String col, Object value)
Adds the name of a column to update with a new value.void
aggregate()
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.void
delete()
Sets to delete rows.DateFormat
getDateFormat()
Returns the date formatter.DateFormatString
getDateFormatString()
Returns the format string of the current date/time format.SpreadSheet
getResult()
Returns the result of the evaluation.int[]
getRows()
Returns the rows to use.SpreadSheet
getSheet()
Returns the current spreadsheet in use.SubProcess
getSubProcess()
Returns the partial flow that was generated to process the spreadsheet.protected void
initialize()
Initializes the members.int[]
invert(int[] c)
Inverts the row finders.void
renameAggregate(SpreadSheetAggregate.Aggregate agg, String col, String newCol)
Sets the new column name for the aggregate generated from a column.void
renameColumn(String col, String newCol)
Adds the name of a column to rename.void
select()
Sets to create subset.void
setLimit(int offset, int max)
Sets the limit.void
setRows(int[] value)
Sets the rows to use.void
setSheet(SpreadSheet value)
Sets the spreadsheet to use.void
setSubsampleRowFinder(RowFinder finder, String log)
Sets the row finder to generate a subsample.void
update()
Sets to update cells.void
useAllColumns()
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:
initialize
in 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
-
-