Package ubic.gemma.core.analysis.service
Class AbstractFileService<T>
- java.lang.Object
-
- ubic.gemma.core.analysis.service.AbstractFileService<T>
-
- All Implemented Interfaces:
FileService<T>,JsonFileService<T>,TsvFileService<T>
- Direct Known Subclasses:
DifferentialExpressionAnalysisResultListFileServiceImpl,ExpressionAnalysisResultSetFileServiceImpl,ExpressionDataFileServiceImpl,MatrixWriter
public abstract class AbstractFileService<T> extends Object implements TsvFileService<T>, JsonFileService<T>
Provide base implementation for all sorts of file services that serialize data in tabular format.
-
-
Constructor Summary
Constructors Constructor Description AbstractFileService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringescapeTsv(String s)protected Stringformat(Double d)Format aDoublefor TSV.protected StringgetSubDelimiter()Get the delimiter used within column.protected org.apache.commons.csv.CSVFormat.BuildergetTsvFormatBuilder(String... extraHeaderComments)Preconfigure aCSVFormat.Builderwith desirable defaults.voidwrite(T entity, File file, String contentType)voidwrite(T entity, Writer writer, String contentType)Write a given entity to an appendable with a given content type.voidwriteJson(T entity, Writer writer)Write a given entity to JSON.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ubic.gemma.core.analysis.service.TsvFileService
writeTsv
-
-
-
-
Method Detail
-
getTsvFormatBuilder
protected org.apache.commons.csv.CSVFormat.Builder getTsvFormatBuilder(String... extraHeaderComments)
Preconfigure aCSVFormat.Builderwith desirable defaults.- Parameters:
extraHeaderComments- additional header comments that will be included at the top of the TSV file.
-
getSubDelimiter
protected String getSubDelimiter()
Get the delimiter used within column.
-
format
protected String format(@Nullable Double d)
Format aDoublefor TSV.- Parameters:
d- a double to format- Returns:
- a formatted double, an empty string if d is null or NaN or inf/-inf if infinite
-
writeJson
public void writeJson(T entity, Writer writer) throws IOException
Description copied from interface:JsonFileServiceWrite a given entity to JSON.- Specified by:
writeJsonin interfaceJsonFileService<T>- Throws:
IOException
-
write
public void write(T entity, Writer writer, String contentType) throws IOException
Description copied from interface:FileServiceWrite a given entity to an appendable with a given content type.- Specified by:
writein interfaceFileService<T>- Throws:
IOException
-
write
public void write(T entity, File file, String contentType) throws IOException
- Specified by:
writein interfaceFileService<T>- Throws:
IOException
-
-