Class AbstractSpreadSheetWriter

    • Field Detail

      • m_Stopped

        protected boolean m_Stopped
        whether the read process was stopped through an external source.
      • m_Encoding

        protected BaseCharset m_Encoding
        the encoding to use.
    • Constructor Detail

      • AbstractSpreadSheetWriter

        public AbstractSpreadSheetWriter()
    • Method Detail

      • getFormatDescription

        public abstract String getFormatDescription()
        Returns a string describing the format (used in the file chooser).
        Specified by:
        getFormatDescription in interface SpreadSheetWriter
        Returns:
        a description suitable for displaying in the file chooser
      • getFormatExtensions

        public abstract String[] getFormatExtensions()
        Returns the extension(s) of the format.
        Specified by:
        getFormatExtensions in interface SpreadSheetWriter
        Returns:
        the extension (without the dot!)
      • getDefaultFormatExtension

        public String getDefaultFormatExtension()
        Returns the default extension of the format.
        Returns:
        the default extension (without the dot!)
      • setEncoding

        public void setEncoding​(BaseCharset value)
        Sets the encoding to use.
        Specified by:
        setEncoding in interface EncodingSupporter
        Parameters:
        value - the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
      • getEncoding

        public BaseCharset getEncoding()
        Returns the encoding to use.
        Specified by:
        getEncoding in interface EncodingSupporter
        Returns:
        the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
      • encodingTipText

        public String encodingTipText()
        Returns the tip text for this property.
        Specified by:
        encodingTipText in interface EncodingSupporter
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • supportsCompressedOutput

        protected boolean supportsCompressedOutput()
        Returns whether to automatically compress.

        Default implementation returns false.
        Returns:
        true if to automatically decompress
      • canCompress

        protected boolean canCompress​(String filename)
        Returns whether the file should get compressed, i.e., supportsCompressedOutput() returns true and the filename ends with ".gz".
        Parameters:
        filename - the filename to check
        Returns:
        true if decompression should occur
      • preWriteFile

        protected void preWriteFile​(String filename)
        Hook method before writing to a file.
        Default implementation does nothing.
        Parameters:
        filename - the filename to check
      • write

        public boolean write​(SpreadSheet content,
                             OutputStream stream)
        Writes the spreadsheet in CSV format to the given output stream. The caller must ensure that the stream gets closed.
        Specified by:
        write in interface SpreadSheetWriter
        Parameters:
        content - the spreadsheet to write
        stream - the output stream to write the spreadsheet to
        Returns:
        true if successfully written
      • write

        public boolean write​(SpreadSheet content,
                             Writer writer)
        Writes the spreadsheet in CSV format to the given writer. The caller must ensure that the writer gets closed.
        Specified by:
        write in interface SpreadSheetWriter
        Parameters:
        content - the spreadsheet to write
        writer - the writer to write the spreadsheet to
        Returns:
        true if successfully written
      • doWrite

        protected boolean doWrite​(SpreadSheet content,
                                  String filename)
        Performs the actual writing.

        Default implementation returns always false.
        Parameters:
        content - the spreadsheet to write
        filename - the file to write the spreadsheet to
        Returns:
        true if successfully written
      • doWrite

        protected boolean doWrite​(SpreadSheet content,
                                  Writer writer)
        Performs the actual writing. The caller must ensure that the writer gets closed.

        Default implementation returns always false.
        Parameters:
        content - the spreadsheet to write
        writer - the writer to write the spreadsheet to
        Returns:
        true if successfully written
      • doWrite

        protected boolean doWrite​(SpreadSheet content,
                                  OutputStream out)
        Performs the actual writing. The caller must ensure that the output stream gets closed.

        Default implementation returns always false.
        Parameters:
        content - the spreadsheet to write
        out - the output stream to write the spreadsheet to
        Returns:
        true if successfully written
      • stopExecution

        public void stopExecution()
        Stops the reading (might not be immediate, depending on reader).
        Specified by:
        stopExecution in interface Stoppable
      • isStopped

        public boolean isStopped()
        Returns whether the reading was stopped.
        Specified by:
        isStopped in interface StoppableWithFeedback
        Returns:
        true if stopped
      • getWriters

        public static String[] getWriters()
        Returns a list with classnames of writers.
        Returns:
        the writer classnames