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.AppendableSpreadSheetWriter
Outputs 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 boolean
m_Appending
whether to append spreadsheets.protected adams.core.Range
m_Columns
the range of columns to output in the data file.protected boolean
m_FileExists
whether the file already exists.protected adams.data.spreadsheet.SpreadSheet
m_Header
the header of the first spreadsheet written to file, if appending is active.protected boolean[]
m_IsNumeric
indicator whether a column is numeric or not.protected boolean
m_KeepExisting
whether 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 String
appendingTipText()
Returns the tip text for this property.boolean
canAppend(adams.data.spreadsheet.SpreadSheet sheet)
Checks whether we can append the specified spreadsheet to the existing file.String
columnsTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected boolean
doWrite(adams.data.spreadsheet.SpreadSheet content, Writer writer)
Performs the actual writing.adams.core.Range
getColumns()
Returns the current placeholder for missing values.adams.data.io.input.SpreadSheetReader
getCorrespondingReader()
Returns, if available, the corresponding reader.protected String
getDefaultMissingValue()
Returns the default missing value.boolean
getFileExists()
Returns whether the output file already exists.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.boolean
getInvert()
Returns whether to invert the matching sense.boolean
getKeepExisting()
Returns whether any existing file is kept on first execution.protected adams.data.io.output.AbstractSpreadSheetWriter.OutputType
getOutputType()
Returns how the data is written.String
globalInfo()
Returns a string describing the object.protected void
initialize()
Initializes the members.String
invertTipText()
Returns the tip text for this property.boolean
isAppending()
Returns whether the next spreadsheet will get appended.String
keepExistingTipText()
Returns the tip text for this property.void
reset()
Resets the writer.void
setAppending(boolean value)
Sets whether the next write call is to append the data to the existing file.void
setColumns(adams.core.Range value)
Sets the placeholder for missing values.void
setFileExists(boolean value)
Sets whether the output file already exists.void
setInvert(boolean value)
Sets whether to invert the matching sense.void
setKeepExisting(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:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in 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:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.data.io.output.AbstractSpreadSheetWriterWithMissingValueSupport
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.data.io.output.AbstractSpreadSheetWriter
-
reset
public void reset()
Resets the writer.- Specified by:
reset
in interfaceadams.data.io.output.SpreadSheetWriter
- Overrides:
reset
in classadams.data.io.output.AbstractSpreadSheetWriter
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceadams.data.io.output.SpreadSheetWriter
- Specified by:
getFormatDescription
in 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:
getFormatExtensions
in interfaceadams.data.io.output.SpreadSheetWriter
- Specified by:
getFormatExtensions
in 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:
getCorrespondingReader
in interfaceadams.data.io.output.SpreadSheetWriter
- Returns:
- the reader, null if none available
-
getDefaultMissingValue
protected String getDefaultMissingValue()
Returns the default missing value.- Overrides:
getDefaultMissingValue
in 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:
canAppend
in 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:
setAppending
in 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:
isAppending
in interfaceadams.data.io.output.AppendableSpreadSheetWriter
- Returns:
- true if append is active
-
appendingTipText
public String appendingTipText()
Returns the tip text for this property.- Specified by:
appendingTipText
in 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:
setKeepExisting
in 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:
getKeepExisting
in 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:
keepExistingTipText
in 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:
setFileExists
in 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:
getFileExists
in 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:
getOutputType
in 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:
doWrite
in classadams.data.io.output.AbstractSpreadSheetWriter
- Parameters:
content
- the spreadsheet to writewriter
- the writer to write the spreadsheet to- Returns:
- true if successfully written
-
-