Package adams.data.io.input
Class PropertiesSpreadSheetReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractSpreadSheetReader
-
- adams.data.io.input.PropertiesSpreadSheetReader
-
- All Implemented Interfaces:
AdditionalInformationHandler,Destroyable,ErrorProvider,GlobalInfoSupporter,EncodingSupporter,FileFormatHandler,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Stoppable,StoppableWithFeedback,SpreadSheetReader,DataRowTypeHandler,SpreadSheetTypeHandler,Serializable
public class PropertiesSpreadSheetReader extends AbstractSpreadSheetReader
Turns Java properties files into spreadsheets with two columns: Key and Value.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-data-row-type <adams.data.spreadsheet.DataRow> (property: dataRowType) The type of row to use for the data. default: adams.data.spreadsheet.DenseDataRow
-spreadsheet-type <adams.data.spreadsheet.SpreadSheet> (property: spreadSheetType) The type of spreadsheet to use for the data. default: adams.data.spreadsheet.DefaultSpreadSheet
-force-string <boolean> (property: forceString) If enabled, the property values are set as string, bypassing the spreadsheet's parsing. default: false
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.data.io.input.AbstractSpreadSheetReader
AbstractSpreadSheetReader.InputType
-
-
Field Summary
Fields Modifier and Type Field Description static StringHEADER_KEYthe header for the key column.static StringHEADER_VALUEthe header for the value column.protected booleanm_ForceStringwhether to set values as string.-
Fields inherited from class adams.data.io.input.AbstractSpreadSheetReader
m_DataRowType, m_Encoding, m_LastError, m_SpreadSheetType, m_Stopped, OPTION_INPUT, OPTION_OUTPUT
-
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 PropertiesSpreadSheetReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddefineOptions()Adds options to the internal list of options.protected SpreadSheetdoRead(File file)Performs the actual reading.StringforceStringTipText()Returns the tip text for this property.SpreadSheetWritergetCorrespondingWriter()Returns, if available, the corresponding writer.booleangetForceString()Returns whether to force setting the values as string, bypassing the spreadsheet's parsing.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.protected AbstractSpreadSheetReader.InputTypegetInputType()Returns how to read the data, from a file, stream or reader.StringglobalInfo()Returns a string describing the object.static voidmain(String[] args)Runs the reader from the command-line.voidsetForceString(boolean value)Sets whether to force setting the values as string, bypassing the spreadsheet's parsing.-
Methods inherited from class adams.data.io.input.AbstractSpreadSheetReader
canDecompress, check, dataRowTypeTipText, doRead, doRead, encodingTipText, getAdditionalInformation, getDataRowType, getDefaultDataRowType, getDefaultFormatExtension, getDefaultSpreadSheet, getEncoding, getLastError, getReaders, getSpreadSheetType, hasLastError, initialize, isStopped, read, read, read, read, runReader, setDataRowType, setEncoding, setLastError, setSpreadSheetType, spreadSheetTypeTipText, stopExecution, supportsCompressedInput
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
HEADER_KEY
public static final String HEADER_KEY
the header for the key column.- See Also:
- Constant Field Values
-
HEADER_VALUE
public static final String HEADER_VALUE
the header for the value column.- See Also:
- Constant Field Values
-
m_ForceString
protected boolean m_ForceString
whether to set values as string.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractSpreadSheetReader
-
setForceString
public void setForceString(boolean value)
Sets whether to force setting the values as string, bypassing the spreadsheet's parsing.- Parameters:
value- true if to force string
-
getForceString
public boolean getForceString()
Returns whether to force setting the values as string, bypassing the spreadsheet's parsing.- Returns:
- true if string type is enforced
-
forceStringTipText
public String forceStringTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getCorrespondingWriter
public SpreadSheetWriter getCorrespondingWriter()
Returns, if available, the corresponding writer.- Returns:
- the writer, null if none available
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescriptionin interfaceFileFormatHandler- Specified by:
getFormatDescriptionin interfaceSpreadSheetReader- Specified by:
getFormatDescriptionin classAbstractSpreadSheetReader- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceFileFormatHandler- Specified by:
getFormatExtensionsin interfaceSpreadSheetReader- Specified by:
getFormatExtensionsin classAbstractSpreadSheetReader- Returns:
- the extension (without the dot!)
-
getInputType
protected AbstractSpreadSheetReader.InputType getInputType()
Returns how to read the data, from a file, stream or reader.- Specified by:
getInputTypein classAbstractSpreadSheetReader- Returns:
- how to read the data
-
doRead
protected SpreadSheet doRead(File file)
Performs the actual reading. Must handle compression itself, ifAbstractSpreadSheetReader.supportsCompressedInput()returns true.- Overrides:
doReadin classAbstractSpreadSheetReader- Parameters:
file- the file to read from- Returns:
- the spreadsheet or null in case of an error
- See Also:
getInputType(),AbstractSpreadSheetReader.supportsCompressedInput()
-
main
public static void main(String[] args)
Runs the reader from the command-line. Use the optionAbstractSpreadSheetReader.OPTION_INPUTto specify the input file. If the optionAbstractSpreadSheetReader.OPTION_OUTPUTis specified then the read sheet gets output as .csv files in that directory.- Parameters:
args- the command-line options to use
-
-