Class 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
    • 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_Formatter

        protected transient DateFormat m_Formatter
        for generating the timestamp.
    • Constructor Detail

      • SimpleArffSpreadSheetWriter

        public SimpleArffSpreadSheetWriter()
    • Method Detail

      • 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
      • 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:
        doWrite in class AbstractSpreadSheetWriter
        Parameters:
        content - the spreadsheet to write
        writer - the writer to write the spreadsheet to
        Returns:
        true if successfully written