Class TextFileWriter

  • All Implemented Interfaces:
    Destroyable, GlobalInfoSupporter, EncodingSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, SizeOfHandler, Serializable
    Direct Known Subclasses:
    TextFileWithLineNumbersWriter

    public class TextFileWriter
    extends AbstractTextWriterWithFilenameGenerator
    Writes the content to a text file.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -enabled <boolean> (property: enabled)
        Whether the writer is enabled.
        default: true
     
    -encoding <adams.core.base.BaseCharset> (property: encoding)
        The type of encoding to use.
        default: Default
     
    -filename-generator <adams.core.io.AbstractFilenameGenerator> (property: filenameGenerator)
        The filename generator to use.
        default: adams.core.io.SimpleFilenameGenerator
     
    -ignore-name <boolean> (property: ignoreName)
        If set to true, then the name of the content is ignored for generating the 
        filename (useful when prefix or suffix is based on variables).
        default: false
     
    -append <boolean> (property: append)
        If enabled, the content gets appended rather than rewriting the file.
        default: false
     
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Append

        protected boolean m_Append
        whether to append the file.
    • Constructor Detail

      • TextFileWriter

        public TextFileWriter()
    • Method Detail

      • setAppend

        public void setAppend​(boolean value)
        Sets whether to append the file rather than rewriting it.
        Parameters:
        value - if true then append the content
      • getAppend

        public boolean getAppend()
        Returns whether to append the file rather than rewriting it.
        Returns:
        true if to append the content
      • appendTipText

        public String appendTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • doWrite

        protected String doWrite​(String content,
                                 String name)
        Writes the given content under the specified name.
        Specified by:
        doWrite in class AbstractTextWriter
        Parameters:
        content - the content to write
        name - the name under which to save the content
        Returns:
        if a file was generated, the filename the content was written as, otherwise null