public abstract class BaseDatasetOutput extends java.lang.Object implements Options
To best user this class, call the appropriate writeDataset(magpie.data.Dataset, java.lang.String) command for your desired output method (e.g., generic stream, file). This will automatically write the entire file. Alternatively, you can call the commands to print the header, entries, and end separately. This might be a be a preferred route if you are, for example, reading entries from a stream and do not want to hold the entire dataset in memory at the same time. But, it is otherwise recommended to use the basic interface.
Developer's Notes: This class is designed around the idea that data files are composed of two segments: a header describing data format, the body containing the data, and some text marking the end of a file. Consequently, any implementation of these class must fulfill 3 operations:
Constructor and Description |
---|
BaseDatasetOutput() |
Modifier and Type | Method and Description |
---|---|
abstract void |
printEnd(java.io.OutputStream output)
Print the end to a data file
|
abstract void |
printEntries(java.util.Collection<BaseEntry> entries,
java.io.OutputStream output)
Write out entries to file.
|
abstract void |
printHeader(Dataset data,
java.io.OutputStream output)
Write header to output.
|
void |
writeDataset(Dataset data,
java.io.File file)
Write dataset to disk
|
void |
writeDataset(Dataset data,
java.io.OutputStream output)
Write a dataset to a output stream.
|
void |
writeDataset(Dataset data,
java.lang.String filename)
Write a dataset to disk
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
printUsage, setOptions
public void writeDataset(Dataset data, java.lang.String filename) throws java.io.IOException
data
- Dataset to be outputfilename
- Path to output filejava.io.IOException
public void writeDataset(Dataset data, java.io.File file) throws java.io.IOException
data
- Dataset to be outputfile
- Output filejava.io.IOException
public void writeDataset(Dataset data, java.io.OutputStream output) throws java.io.IOException
data
- Dataset to be outputoutput
- Output stream for datajava.io.IOException
public abstract void printHeader(Dataset data, java.io.OutputStream output)
data
- Dataset to be writtenoutput
- Output streampublic abstract void printEntries(java.util.Collection<BaseEntry> entries, java.io.OutputStream output)
entries
- Entries to be writtenoutput
- Output streampublic abstract void printEnd(java.io.OutputStream output)
output
- Output stream