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 String
escapeTsv(String s)
protected String
format(Double d)
Format aDouble
for TSV.protected String
getSubDelimiter()
Get the delimiter used within column.protected org.apache.commons.csv.CSVFormat.Builder
getTsvFormatBuilder(String... extraHeaderComments)
Preconfigure aCSVFormat.Builder
with desirable defaults.void
write(T entity, File file, String contentType)
void
write(T entity, Writer writer, String contentType)
Write a given entity to an appendable with a given content type.void
writeJson(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.Builder
with 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 aDouble
for 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:JsonFileService
Write a given entity to JSON.- Specified by:
writeJson
in interfaceJsonFileService<T>
- Throws:
IOException
-
write
public void write(T entity, Writer writer, String contentType) throws IOException
Description copied from interface:FileService
Write a given entity to an appendable with a given content type.- Specified by:
write
in interfaceFileService<T>
- Throws:
IOException
-
write
public void write(T entity, File file, String contentType) throws IOException
- Specified by:
write
in interfaceFileService<T>
- Throws:
IOException
-
-