Package adams.data.io.output
Class SimpleArffSpreadSheetWriter
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.output.AbstractSpreadSheetWriter
-
- adams.data.io.output.SimpleArffSpreadSheetWriter
-
- All Implemented Interfaces:
AdditionalInformationHandler,Destroyable,GlobalInfoSupporter,EncodingSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Stoppable,StoppableWithFeedback,SpreadSheetWriter,Serializable
public class SimpleArffSpreadSheetWriter extends AbstractSpreadSheetWriter
Simple writer for Weka ARFF files, only supports NUMERIC, NOMINAL, STRING and DATE attributes.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-max-nominal-values <int> (property: maxNominalValues) The maximum number of different values to accept for NOMINAL attributes before switching to STRING. default: 25 minimum: 0
-max-decimals <int> (property: maxDecimals) The maximum number of decimals to use for numeric values. default: 6 minimum: 0
-date-format <adams.data.DateFormatString> (property: dateFormat) The format to use for the date attributes. default: yyyy-MM-dd HH:mm:ss more: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
- 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.output.AbstractSpreadSheetWriter
AbstractSpreadSheetWriter.OutputType
-
-
Field Summary
Fields Modifier and Type Field Description protected DateFormatStringm_DateFormatthe format to use.protected DateFormatm_Formatterfor generating the timestamp.protected intm_MaxDecimalsthe maximum number of decimals to use for numeric values.protected intm_MaxNominalValuesthe maximum number of values for nominal attributes.-
Fields inherited from class adams.data.io.output.AbstractSpreadSheetWriter
m_Encoding, m_Stopped
-
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 SimpleArffSpreadSheetWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcleanUpTypes(HashSet<Cell.ContentType> cellTypes)Cleans up the cell types.StringdateFormatTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected booleandoWrite(SpreadSheet content, Writer writer)Performs the actual writing.SpreadSheetReadergetCorrespondingReader()Returns, if available, the corresponding reader.DateFormatStringgetDateFormat()Returns the date format string in use.protected DateFormatStringgetDefaultFormat()Returns the default format to use.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.protected DateFormatgetFormatter()Returns the instance of a date formatter to use.intgetMaxDecimals()Returns the maximum number of decimals to use for numeric values.intgetMaxNominalValues()Returns the maximum number of different values to accept for NOMINAL attributes before switching to STRING.protected AbstractSpreadSheetWriter.OutputTypegetOutputType()Returns how the data is written.StringglobalInfo()Returns a string describing the object.StringmaxDecimalsTipText()Returns the tip text for this property.StringmaxNominalValuesTipText()Returns the tip text for this property.voidsetDateFormat(DateFormatString value)Sets the date format string to use.voidsetMaxDecimals(int value)Sets the maximum number of decimals to use for numeric values.voidsetMaxNominalValues(int value)Sets the maximum number of different values to accept for NOMINAL attributes before switching to STRING.protected booleansupportsCompressedOutput()Returns whether to automatically compress.-
Methods inherited from class adams.data.io.output.AbstractSpreadSheetWriter
canCompress, doWrite, doWrite, encodingTipText, getAdditionalInformation, getDefaultFormatExtension, getEncoding, getWriters, initialize, isStopped, preWriteFile, reset, setEncoding, stopExecution, 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
-
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
-
m_MaxNominalValues
protected int m_MaxNominalValues
the maximum number of values for nominal attributes.
-
m_MaxDecimals
protected int m_MaxDecimals
the maximum number of decimals to use for numeric values.
-
m_DateFormat
protected DateFormatString m_DateFormat
the format to use.
-
m_Formatter
protected transient DateFormat m_Formatter
for generating the timestamp.
-
-
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 classAbstractOptionHandler
-
setMaxNominalValues
public void setMaxNominalValues(int value)
Sets the maximum number of different values to accept for NOMINAL attributes before switching to STRING.- Parameters:
value- the maximum
-
getMaxNominalValues
public int getMaxNominalValues()
Returns the maximum number of different values to accept for NOMINAL attributes before switching to STRING.- Returns:
- the maximum
-
maxNominalValuesTipText
public String maxNominalValuesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMaxDecimals
public void setMaxDecimals(int value)
Sets the maximum number of decimals to use for numeric values.- Parameters:
value- the maximum
-
getMaxDecimals
public int getMaxDecimals()
Returns the maximum number of decimals to use for numeric values.- Returns:
- the maximum
-
maxDecimalsTipText
public String maxDecimalsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getFormatter
protected DateFormat getFormatter()
Returns the instance of a date formatter to use.- Returns:
- the formatter object
-
getDefaultFormat
protected DateFormatString getDefaultFormat()
Returns the default format to use.- Returns:
- the format
-
setDateFormat
public void setDateFormat(DateFormatString value)
Sets the date format string to use.- Parameters:
value- the format
-
getDateFormat
public DateFormatString getDateFormat()
Returns the date format string in use.- Returns:
- the format
-
dateFormatTipText
public String dateFormatTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getCorrespondingReader
public SpreadSheetReader getCorrespondingReader()
Returns, if available, the corresponding reader.- Returns:
- the reader, null if none available
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescriptionin interfaceSpreadSheetWriter- Specified by:
getFormatDescriptionin classAbstractSpreadSheetWriter- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceSpreadSheetWriter- Specified by:
getFormatExtensionsin classAbstractSpreadSheetWriter- Returns:
- the extension (without the dot!)
-
getOutputType
protected AbstractSpreadSheetWriter.OutputType getOutputType()
Returns how the data is written.- Specified by:
getOutputTypein classAbstractSpreadSheetWriter- Returns:
- the type
-
supportsCompressedOutput
protected boolean supportsCompressedOutput()
Returns whether to automatically compress.- Overrides:
supportsCompressedOutputin classAbstractSpreadSheetWriter- Returns:
- true if to automatically decompress
-
cleanUpTypes
protected void cleanUpTypes(HashSet<Cell.ContentType> cellTypes)
Cleans up the cell types.- Parameters:
cellTypes- the cell types to process
-
doWrite
protected boolean doWrite(SpreadSheet content, Writer writer)
Performs the actual writing. The caller must ensure that the writer gets closed.- Overrides:
doWritein classAbstractSpreadSheetWriter- Parameters:
content- the spreadsheet to writewriter- the writer to write the spreadsheet to- Returns:
- true if successfully written
-
-