Package adams.data.io.output
Class GnuplotSpreadSheetWriter
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.output.AbstractSpreadSheetWriter
-
- adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
-
- adams.data.io.output.GnuplotSpreadSheetWriter
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler,adams.core.Destroyable,adams.core.GlobalInfoSupporter,adams.core.io.EncodingSupporter,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.option.OptionHandler,adams.core.SizeOfHandler,adams.core.Stoppable,adams.core.StoppableWithFeedback,adams.data.io.output.AppendableSpreadSheetWriter,adams.data.io.output.SpreadSheetWriter,Serializable
public class GnuplotSpreadSheetWriter extends adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport implements adams.data.io.output.AppendableSpreadSheetWriterOutputs all numeric columns of a spreadsheet in Gnuplot format.
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
-missing <java.lang.String> (property: missingValue) The placeholder for missing values. default: -999
-columns <adams.core.Range> (property: columns) The columns in the spreadsheet to output. default: first-last
-invert (property: invert) If set to true, then the matching sense is inverted.
-appending (property: appending) If enabled, multiple spreadsheets with the same structure can be written to the same file.
-keep-existing (property: keepExisting) If enabled, any output file that exists when the writer is executed for the first time won't get replaced with the current header; useful when outputting data in multiple locations in the flow, but one needs to be cautious as to not stored mixed content (eg varying number of columns, etc).
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_Appendingwhether to append spreadsheets.protected adams.core.Rangem_Columnsthe range of columns to output in the data file.protected booleanm_FileExistswhether the file already exists.protected adams.data.spreadsheet.SpreadSheetm_Headerthe header of the first spreadsheet written to file, if appending is active.protected boolean[]m_IsNumericindicator whether a column is numeric or not.protected booleanm_KeepExistingwhether to keep existing files the first time the writer is called.
-
Constructor Summary
Constructors Constructor Description GnuplotSpreadSheetWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringappendingTipText()Returns the tip text for this property.booleancanAppend(adams.data.spreadsheet.SpreadSheet sheet)Checks whether we can append the specified spreadsheet to the existing file.StringcolumnsTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected booleandoWrite(adams.data.spreadsheet.SpreadSheet content, Writer writer)Performs the actual writing.adams.core.RangegetColumns()Returns the current placeholder for missing values.adams.data.io.input.SpreadSheetReadergetCorrespondingReader()Returns, if available, the corresponding reader.protected StringgetDefaultMissingValue()Returns the default missing value.booleangetFileExists()Returns whether the output file already exists.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.booleangetInvert()Returns whether to invert the matching sense.booleangetKeepExisting()Returns whether any existing file is kept on first execution.protected adams.data.io.output.AbstractSpreadSheetWriter.OutputTypegetOutputType()Returns how the data is written.StringglobalInfo()Returns a string describing the object.protected voidinitialize()Initializes the members.StringinvertTipText()Returns the tip text for this property.booleanisAppending()Returns whether the next spreadsheet will get appended.StringkeepExistingTipText()Returns the tip text for this property.voidreset()Resets the writer.voidsetAppending(boolean value)Sets whether the next write call is to append the data to the existing file.voidsetColumns(adams.core.Range value)Sets the placeholder for missing values.voidsetFileExists(boolean value)Sets whether the output file already exists.voidsetInvert(boolean value)Sets whether to invert the matching sense.voidsetKeepExisting(boolean value)Sets whether to keep any existing file on first execution.-
Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
getMissingValue, missingValueTipText, setMissingValue
-
Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriter
canCompress, doWrite, doWrite, encodingTipText, getAdditionalInformation, getDefaultFormatExtension, getEncoding, getWriters, isStopped, preWriteFile, setEncoding, stopExecution, supportsCompressedOutput, write, write, write, write
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Columns
protected adams.core.Range m_Columns
the range of columns to output in the data file.
-
m_Appending
protected boolean m_Appending
whether to append spreadsheets.
-
m_Header
protected adams.data.spreadsheet.SpreadSheet m_Header
the header of the first spreadsheet written to file, if appending is active.
-
m_KeepExisting
protected boolean m_KeepExisting
whether to keep existing files the first time the writer is called.
-
m_IsNumeric
protected boolean[] m_IsNumeric
indicator whether a column is numeric or not.
-
m_FileExists
protected boolean m_FileExists
whether the file already exists.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.core.option.AbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classadams.data.io.output.AbstractSpreadSheetWriter
-
reset
public void reset()
Resets the writer.- Specified by:
resetin interfaceadams.data.io.output.SpreadSheetWriter- Overrides:
resetin classadams.data.io.output.AbstractSpreadSheetWriter
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescriptionin interfaceadams.data.io.output.SpreadSheetWriter- Specified by:
getFormatDescriptionin classadams.data.io.output.AbstractSpreadSheetWriter- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceadams.data.io.output.SpreadSheetWriter- Specified by:
getFormatExtensionsin classadams.data.io.output.AbstractSpreadSheetWriter- Returns:
- the extension (without the dot!)
-
getCorrespondingReader
public adams.data.io.input.SpreadSheetReader getCorrespondingReader()
Returns, if available, the corresponding reader.- Specified by:
getCorrespondingReaderin interfaceadams.data.io.output.SpreadSheetWriter- Returns:
- the reader, null if none available
-
getDefaultMissingValue
protected String getDefaultMissingValue()
Returns the default missing value.- Overrides:
getDefaultMissingValuein classadams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport- Returns:
- the default for missing values
-
setColumns
public void setColumns(adams.core.Range value)
Sets the placeholder for missing values.- Parameters:
value- the placeholder
-
getColumns
public adams.core.Range getColumns()
Returns the current placeholder for missing values.- Returns:
- the placeholder
-
columnsTipText
public String columnsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setInvert
public void setInvert(boolean value)
Sets whether to invert the matching sense.- Parameters:
value- true if inverting matching sense
-
getInvert
public boolean getInvert()
Returns whether to invert the matching sense.- Returns:
- true if matching sense is inverted
-
invertTipText
public String invertTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
canAppend
public boolean canAppend(adams.data.spreadsheet.SpreadSheet sheet)
Checks whether we can append the specified spreadsheet to the existing file.- Specified by:
canAppendin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Parameters:
sheet- the spreadsheet to append to the existing one- Returns:
- true if appending is possible
-
setAppending
public void setAppending(boolean value)
Sets whether the next write call is to append the data to the existing file.- Specified by:
setAppendingin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Parameters:
value- true if to append
-
isAppending
public boolean isAppending()
Returns whether the next spreadsheet will get appended.- Specified by:
isAppendingin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Returns:
- true if append is active
-
appendingTipText
public String appendingTipText()
Returns the tip text for this property.- Specified by:
appendingTipTextin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setKeepExisting
public void setKeepExisting(boolean value)
Sets whether to keep any existing file on first execution.- Specified by:
setKeepExistingin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Parameters:
value- if true then existing file is kept
-
getKeepExisting
public boolean getKeepExisting()
Returns whether any existing file is kept on first execution.- Specified by:
getKeepExistingin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Returns:
- true if existing file is kept
-
keepExistingTipText
public String keepExistingTipText()
Returns the tip text for this property.- Specified by:
keepExistingTipTextin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFileExists
public void setFileExists(boolean value)
Sets whether the output file already exists.- Specified by:
setFileExistsin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Parameters:
value- true if the output file already exists
-
getFileExists
public boolean getFileExists()
Returns whether the output file already exists.- Specified by:
getFileExistsin interfaceadams.data.io.output.AppendableSpreadSheetWriter- Returns:
- true if the output file already exists
-
getOutputType
protected adams.data.io.output.AbstractSpreadSheetWriter.OutputType getOutputType()
Returns how the data is written.- Specified by:
getOutputTypein classadams.data.io.output.AbstractSpreadSheetWriter- Returns:
- the type
-
doWrite
protected boolean doWrite(adams.data.spreadsheet.SpreadSheet content, Writer writer)Performs the actual writing. The caller must ensure that the writer gets closed.- Overrides:
doWritein classadams.data.io.output.AbstractSpreadSheetWriter- Parameters:
content- the spreadsheet to writewriter- the writer to write the spreadsheet to- Returns:
- true if successfully written
-
-