Class ExportWriter

java.lang.Object
com.compomics.util.io.export.ExportWriter
Direct Known Subclasses:
ExcelWriter, TextWriter

public abstract class ExportWriter
extends Object
The export writer will write the output in the desired export format.
Author:
Marc Vaudel
  • Field Details

  • Constructor Details

    • ExportWriter

      public ExportWriter()
      Empty default constructor.
  • Method Details

    • getExportFormat

      public ExportFormat getExportFormat()
      Returns the export of the format.
      Returns:
      the export of the format
    • write

      public void write​(String text) throws IOException
      Writes text to the export.
      Parameters:
      text - the text to write
      Throws:
      IOException - if an IOException occurs
    • write

      public abstract void write​(String text, WorkbookStyle textStyle) throws IOException
      Writes text to the export.
      Parameters:
      text - the text to write
      textStyle - the style to use, overwrites any previous/default
      Throws:
      IOException - if an IOException occurs
    • writeMainTitle

      public void writeMainTitle​(String text) throws IOException
      Writes the main title.
      Parameters:
      text - the text to write
      Throws:
      IOException - if an IOException occurs
    • writeMainTitle

      public abstract void writeMainTitle​(String text, WorkbookStyle textStyle) throws IOException
      Writes the main title.
      Parameters:
      text - the text to write
      textStyle - the style to use, overwrites any previous/default
      Throws:
      IOException - if an IOException occurs
    • startNewSection

      public void startNewSection() throws IOException
      Starts a new section.
      Throws:
      IOException - if an IOException occurs
    • startNewSection

      public void startNewSection​(String sectionTitle) throws IOException
      Starts a new section.
      Parameters:
      sectionTitle - the text to write
      Throws:
      IOException - if an IOException occurs
    • startNewSection

      public abstract void startNewSection​(String sectionTitle, WorkbookStyle textStyle) throws IOException
      Starts a new section.
      Parameters:
      sectionTitle - the text to write
      textStyle - the style to use, overwrites any previous/default
      Throws:
      IOException - if an IOException occurs
    • writeHeaderText

      public void writeHeaderText​(String text) throws IOException
      Writes header text to the export.
      Parameters:
      text - the text to write
      Throws:
      IOException - if an IOException occurs
    • writeHeaderText

      public abstract void writeHeaderText​(String text, WorkbookStyle textStyle) throws IOException
      Writes header text to the export.
      Parameters:
      text - the text to write
      textStyle - the style to use, overwrites any previous/default
      Throws:
      IOException - if an IOException occurs
    • addSeparator

      public void addSeparator() throws IOException
      Adds a separator.
      Throws:
      IOException - if an IOException occurs
    • addSeparator

      public abstract void addSeparator​(WorkbookStyle textStyle) throws IOException
      Adds a separator.
      Parameters:
      textStyle - the style to use, overwrites any previous/default
      Throws:
      IOException - if an IOException occurs
    • newLine

      public abstract void newLine() throws IOException
      Adds a separator.
      Throws:
      IOException - if an IOException occurs
    • close

      public abstract void close() throws IOException, FileNotFoundException
      Writes the content in cache and closes the connection to the file.
      Throws:
      IOException - if an IOException occurs
      FileNotFoundException - if a FileNotFoundException occurs
    • increaseDepth

      public abstract void increaseDepth()
      Notifies the writer that data of a higher hierarchical depth will be written, e.g. going from protein to peptide.
    • decreseDepth

      public abstract void decreseDepth()
      Notifies the writer that data of a lower hierarchical depth will be written, e.g. going from peptide to protein.
    • getExportWriter

      public static ExportWriter getExportWriter​(ExportFormat exportFormat, File destinationFile, String separator, int nSeparationLines, boolean gzip) throws IOException
      Returns an export writer for the desired format.
      Parameters:
      exportFormat - the export format
      destinationFile - the file where to write the export
      separator - the separator for a text export
      nSeparationLines - the number of separation lines between two sections for a text export
      gzip - if true export test as gzipped file
      Returns:
      an export writer for the desired format
      Throws:
      IOException - if an IOException occurs