Package com.compomics.util.io.export
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 Summary
Fields Modifier and Type Field Description protected ExportFormat
exportFormat
The format of the export.static String
LAST_FOLDER_KEY
Key to store the last export folder. -
Constructor Summary
Constructors Constructor Description ExportWriter()
Empty default constructor. -
Method Summary
Modifier and Type Method Description void
addSeparator()
Adds a separator.abstract void
addSeparator(WorkbookStyle textStyle)
Adds a separator.abstract void
close()
Writes the content in cache and closes the connection to the file.abstract void
decreseDepth()
Notifies the writer that data of a lower hierarchical depth will be written, e.g.ExportFormat
getExportFormat()
Returns the export of the format.static ExportWriter
getExportWriter(ExportFormat exportFormat, File destinationFile, String separator, int nSeparationLines, boolean gzip)
Returns an export writer for the desired format.abstract void
increaseDepth()
Notifies the writer that data of a higher hierarchical depth will be written, e.g.abstract void
newLine()
Adds a separator.void
startNewSection()
Starts a new section.void
startNewSection(String sectionTitle)
Starts a new section.abstract void
startNewSection(String sectionTitle, WorkbookStyle textStyle)
Starts a new section.void
write(String text)
Writes text to the export.abstract void
write(String text, WorkbookStyle textStyle)
Writes text to the export.void
writeHeaderText(String text)
Writes header text to the export.abstract void
writeHeaderText(String text, WorkbookStyle textStyle)
Writes header text to the export.void
writeMainTitle(String text)
Writes the main title.abstract void
writeMainTitle(String text, WorkbookStyle textStyle)
Writes the main title.
-
Field Details
-
LAST_FOLDER_KEY
Key to store the last export folder.- See Also:
- Constant Field Values
-
exportFormat
The format of the export.
-
-
Constructor Details
-
ExportWriter
public ExportWriter()Empty default constructor.
-
-
Method Details
-
getExportFormat
Returns the export of the format.- Returns:
- the export of the format
-
write
Writes text to the export.- Parameters:
text
- the text to write- Throws:
IOException
- if an IOException occurs
-
write
Writes text to the export.- Parameters:
text
- the text to writetextStyle
- the style to use, overwrites any previous/default- Throws:
IOException
- if an IOException occurs
-
writeMainTitle
Writes the main title.- Parameters:
text
- the text to write- Throws:
IOException
- if an IOException occurs
-
writeMainTitle
Writes the main title.- Parameters:
text
- the text to writetextStyle
- the style to use, overwrites any previous/default- Throws:
IOException
- if an IOException occurs
-
startNewSection
Starts a new section.- Throws:
IOException
- if an IOException occurs
-
startNewSection
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 IOExceptionStarts a new section.- Parameters:
sectionTitle
- the text to writetextStyle
- the style to use, overwrites any previous/default- Throws:
IOException
- if an IOException occurs
-
writeHeaderText
Writes header text to the export.- Parameters:
text
- the text to write- Throws:
IOException
- if an IOException occurs
-
writeHeaderText
Writes header text to the export.- Parameters:
text
- the text to writetextStyle
- the style to use, overwrites any previous/default- Throws:
IOException
- if an IOException occurs
-
addSeparator
Adds a separator.- Throws:
IOException
- if an IOException occurs
-
addSeparator
Adds a separator.- Parameters:
textStyle
- the style to use, overwrites any previous/default- Throws:
IOException
- if an IOException occurs
-
newLine
Adds a separator.- Throws:
IOException
- if an IOException occurs
-
close
Writes the content in cache and closes the connection to the file.- Throws:
IOException
- if an IOException occursFileNotFoundException
- 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 IOExceptionReturns an export writer for the desired format.- Parameters:
exportFormat
- the export formatdestinationFile
- the file where to write the exportseparator
- the separator for a text exportnSeparationLines
- the number of separation lines between two sections for a text exportgzip
- if true export test as gzipped file- Returns:
- an export writer for the desired format
- Throws:
IOException
- if an IOException occurs
-