Class AbstractColumnFinder
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.spreadsheet.columnfinder.AbstractColumnFinder
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<ColumnFinder>
,SizeOfHandler
,ColumnFinder
,Serializable
- Direct Known Subclasses:
AbstractTrainableColumnFinder
,AllFinder
,ByContentType
,ByExactName
,ByIndex
,ByName
,DownSample
,FilteredColumnFinder
,NullFinder
,SubSample
public abstract class AbstractColumnFinder extends AbstractOptionHandler implements ColumnFinder, ShallowCopySupporter<ColumnFinder>
Ancestor for classes that find columns of interest in spreadsheets.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractColumnFinder()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static HashSet<Integer>
arrayToHashSet(int[] indices)
Turns the array into a hashset.protected void
check(SpreadSheet data)
Checks the data.int
compareTo(Object o)
Compares this object with the specified object for order.protected abstract int[]
doFindColumns(SpreadSheet data)
Returns the columns of interest in the spreadsheet.boolean
equals(Object o)
Returns whether the two objects are the same.static SpreadSheet
filter(SpreadSheet input, int[] indices)
Filters the columns of a spreadsheet, keeping the specified columns.static SpreadSheet
filter(SpreadSheet input, ColumnFinder finder)
Filters the columns of a spreadsheet with the given column finder.int[]
findColumns(SpreadSheet data)
Returns the columns of interest in the spreadsheet.static ColumnFinder
forCommandLine(String cmdline)
Instantiates the column finder from the given commandline (i.e., classname and optional options).static ColumnFinder
forName(String classname, String[] options)
Instantiates the column finder with the given options.static String[]
getColumnFinders()
Returns a list with classnames of column finders.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.ColumnFinder
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.ColumnFinder
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
check
protected void check(SpreadSheet data)
Checks the data.
Default implementation only checks whether we have any data at all.- Parameters:
data
- the data to check
-
doFindColumns
protected abstract int[] doFindColumns(SpreadSheet data)
Returns the columns of interest in the spreadsheet.- Parameters:
data
- the spreadsheet to inspect- Returns:
- the columns of interest
-
findColumns
public int[] findColumns(SpreadSheet data)
Returns the columns of interest in the spreadsheet.- Specified by:
findColumns
in interfaceColumnFinder
- Parameters:
data
- the spreadsheet to inspect- Returns:
- the columns of interest
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Only compares the commandlines of the two objects.- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
equals
public boolean equals(Object o)
Returns whether the two objects are the same.
Only compares the commandlines of the two objects.
-
shallowCopy
public ColumnFinder shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<ColumnFinder>
- Returns:
- the shallow copy
-
shallowCopy
public ColumnFinder shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<ColumnFinder>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
getColumnFinders
public static String[] getColumnFinders()
Returns a list with classnames of column finders.- Returns:
- the column finder classnames
-
forName
public static ColumnFinder forName(String classname, String[] options)
Instantiates the column finder with the given options.- Parameters:
classname
- the classname of the column finder to instantiateoptions
- the options for the column finder- Returns:
- the instantiated column finder or null if an error occurred
-
forCommandLine
public static ColumnFinder forCommandLine(String cmdline)
Instantiates the column finder from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the column finder to instantiate- Returns:
- the instantiated column finder or null if an error occurred
-
arrayToHashSet
public static HashSet<Integer> arrayToHashSet(int[] indices)
Turns the array into a hashset.- Parameters:
indices
- the indices to turn into hashset- Returns:
- the generated hashset
-
filter
public static SpreadSheet filter(SpreadSheet input, ColumnFinder finder)
Filters the columns of a spreadsheet with the given column finder.- Parameters:
input
- the spreadsheet to filterfinder
- the column finder to use- Returns:
- the generated output
-
filter
public static SpreadSheet filter(SpreadSheet input, int[] indices)
Filters the columns of a spreadsheet, keeping the specified columns.- Parameters:
input
- the spreadsheet to filterindices
- the column indices to keep- Returns:
- the generated output
-
-