public abstract class AbstractEventWriter<P extends WriterStreamDataProvider<? extends AbstractEventWriter<P>>> extends Object implements JPhyloIOEventWriter
Modifier and Type | Class and Description |
---|---|
static class |
AbstractEventWriter.NoEditUniqueLabelHandler |
static interface |
AbstractEventWriter.UniqueLabelHandler |
Modifier and Type | Field and Description |
---|---|
static String |
EDITED_LABEL_SEPARATOR |
Constructor and Description |
---|
AbstractEventWriter() |
Modifier and Type | Method and Description |
---|---|
protected P |
createStreamDataProvider()
This method is called in the constructor of
AbstractEventWriter to initialize the stream
data provider that will be returned by getStreamDataProvider() . |
static String |
createUniqueLabel(ReadWriteParameterMap parameters,
AbstractEventWriter.UniqueLabelHandler handler,
LabeledIDEvent event) |
static String |
createUniqueLabel(ReadWriteParameterMap parameters,
AbstractEventWriter.UniqueLabelHandler handler,
String label1,
String id1,
String label2,
String id2) |
static String |
createUniqueLabel(ReadWriteParameterMap parameters,
LabeledIDEvent event) |
static String |
createUniqueLinkedOTULabel(ReadWriteParameterMap parameters,
AbstractEventWriter.UniqueLabelHandler handler,
LinkedLabeledIDEvent event,
OTUListDataAdapter otuList,
boolean otuFirst) |
protected void |
decreaseIndention() |
static long |
determineMaxSequenceLength(MatrixDataAdapter matrix,
ReadWriteParameterMap parameters)
Calculates the maximum sequence length in matrix with unequal lengths.
|
protected abstract void |
doWriteDocument(DocumentDataAdapter document,
Writer writer,
ReadWriteParameterMap parameters) |
protected void |
extendSequence(MatrixDataAdapter matrix,
ReadWriteParameterMap parameters,
String sequenceID,
long targetLength,
String extensionToken,
JPhyloIOEventReceiver receiver) |
protected String |
getFileStartInfo(ReadWriteParameterMap parameters) |
protected String |
getIndention() |
static String |
getLabeledIDName(LabeledIDEvent event)
Returns a name for the specified event.
|
static String |
getLinkedOTUNameOTUFirst(LinkedLabeledIDEvent linkedOTUEvent,
OTUListDataAdapter otuList,
ReadWriteParameterMap parameters)
Determines the name (label) to be used for the specified event when writing its data to a file.
|
static String |
getLinkedOTUNameOwnFirst(LinkedLabeledIDEvent linkedOTUEvent,
OTUListDataAdapter otuList,
ReadWriteParameterMap parameters)
Determines the name (label) to be used for the specified event when writing its data to a file.
|
static OTUListDataAdapter |
getReferencedOTUList(DocumentDataAdapter document,
ElementDataAdapter<LinkedLabeledIDEvent> source,
ReadWriteParameterMap parameters)
Returns the OTU list found in
document which is referenced by the specified event. |
P |
getStreamDataProvider() |
protected void |
increaseIndention() |
static void |
logIngnoredOTULists(DocumentDataAdapter document,
ApplicationLogger logger,
ReadWriteParameterMap parameters,
String formatName,
String labeledElements)
Outputs a warning message, if the specified document data adapter provides one or more OTU lists.
|
void |
writeDocument(DocumentDataAdapter document,
File file,
ReadWriteParameterMap parameters)
Writes the data provided by the data adapter to a document in the according format of the implementing class.
|
void |
writeDocument(DocumentDataAdapter document,
OutputStream stream,
ReadWriteParameterMap parameters)
Writes the data provided by the data adapter to a document in the according format of the implementing class.
|
void |
writeDocument(DocumentDataAdapter document,
Writer writer,
ReadWriteParameterMap parameters)
Writes the data provided by the data adapter to a document in the according format of the implementing class.
|
static void |
writeLineBreak(Writer writer,
ReadWriteParameterMap parameters)
Writes the line separator, as it is specified in the parameter map or the line separator
of the current operating system, if the map contains no according entry.
|
protected void |
writeLineStart(Writer writer,
String text) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFormatID
public static final String EDITED_LABEL_SEPARATOR
public AbstractEventWriter()
protected P createStreamDataProvider()
AbstractEventWriter
to initialize the stream
data provider that will be returned by getStreamDataProvider()
. Inheriting classes that use
their own stream data provider implementation should overwrite this method.
This default implementation creates a new instance of WriterStreamDataProvider
.
public P getStreamDataProvider()
public static void writeLineBreak(Writer writer, ReadWriteParameterMap parameters) throws IOException
writer
- the writer to write the line break toparameters
- the parameter map possibly containing a line separator definitionIOException
- if an I/O error occurs while writing to the specified writerpublic static void logIngnoredOTULists(DocumentDataAdapter document, ApplicationLogger logger, ReadWriteParameterMap parameters, String formatName, String labeledElements)
document
- the document data adapter to be checked for OTU listslogger
- the logger to write the warning toformatName
- the name of the format to which OTU lists cannot be written (will be included in the message)labeledElements
- the name of data elements (e.g. sequences or nodes) that may reference the OTU lists
(The warning message will use this name for a hint that the OTU lists may still be used to label this
type of elements.)public static String getLabeledIDName(LabeledIDEvent event)
event
- the event to get the name ofpublic static String getLinkedOTUNameOwnFirst(LinkedLabeledIDEvent linkedOTUEvent, OTUListDataAdapter otuList, ReadWriteParameterMap parameters)
linkedOTUEvent
if presentlinkedOTUEvent
linkedOTUEvent
- the event defining the nameotuList
- the data adapter providing the OTU data#getLinkedOTUNameOTUFirst(LinkedLabeledIDEvent, OTUListDataAdapter)
public static String getLinkedOTUNameOTUFirst(LinkedLabeledIDEvent linkedOTUEvent, OTUListDataAdapter otuList, ReadWriteParameterMap parameters)
linkedOTUEvent
if presentlinkedOTUEvent
linkedOTUEvent
- the event defining the nameotuList
- the data adapter providing the OTU data#getLinkedOTUNameOwnFirst(LinkedLabeledIDEvent, OTUListDataAdapter)
public static OTUListDataAdapter getReferencedOTUList(DocumentDataAdapter document, ElementDataAdapter<LinkedLabeledIDEvent> source, ReadWriteParameterMap parameters)
document
which is referenced by the specified event.document
- the document data adapter providing the OTU lists.source
- the event referencing the OTU listnull
, if the specified event does not reference any OTUIllegalArgumentException
- if no OTU list with the specified ID is available in document
public static long determineMaxSequenceLength(MatrixDataAdapter matrix, ReadWriteParameterMap parameters)
MatrixDataAdapter.getColumnCount(ReadWriteParameterMap)
returns -1, otherwise it will directly return the specified column count.matrix
- the matrix data adapter containing the sequencesprotected String getIndention()
protected void writeLineStart(Writer writer, String text) throws IOException
IOException
protected void increaseIndention()
protected void decreaseIndention()
public static String createUniqueLabel(ReadWriteParameterMap parameters, AbstractEventWriter.UniqueLabelHandler handler, String label1, String id1, String label2, String id2)
public static String createUniqueLabel(ReadWriteParameterMap parameters, AbstractEventWriter.UniqueLabelHandler handler, LabeledIDEvent event)
public static String createUniqueLabel(ReadWriteParameterMap parameters, LabeledIDEvent event)
public static String createUniqueLinkedOTULabel(ReadWriteParameterMap parameters, AbstractEventWriter.UniqueLabelHandler handler, LinkedLabeledIDEvent event, OTUListDataAdapter otuList, boolean otuFirst)
protected void extendSequence(MatrixDataAdapter matrix, ReadWriteParameterMap parameters, String sequenceID, long targetLength, String extensionToken, JPhyloIOEventReceiver receiver) throws IOException
IOException
protected String getFileStartInfo(ReadWriteParameterMap parameters)
public void writeDocument(DocumentDataAdapter document, File file, ReadWriteParameterMap parameters) throws IOException
JPhyloIOEventWriter
writeDocument
in interface JPhyloIOEventWriter
document
- the adapter providing the data to be writtenfile
- the file to write the data toparameters
- a map of parameters to exchange information with the writer implementation (Care should be taken, if a
parameter map is reused for multiple calls, since the writer implementation may add or changes entries in the map.)IOException
public void writeDocument(DocumentDataAdapter document, OutputStream stream, ReadWriteParameterMap parameters) throws IOException
JPhyloIOEventWriter
writeDocument
in interface JPhyloIOEventWriter
document
- the adapter providing the data to be writtenstream
- the stream to write the data toparameters
- a map of parameters to exchange information with the writer implementation (Care should be taken, if a
parameter map is reused for multiple calls, since the writer implementation may add or changes entries in the map.)IOException
public void writeDocument(DocumentDataAdapter document, Writer writer, ReadWriteParameterMap parameters) throws IOException
JPhyloIOEventWriter
writeDocument
in interface JPhyloIOEventWriter
document
- the adapter providing the data to be writtenwriter
- the writer to write the data toparameters
- a map of parameters to exchange information with the writer implementation (Care should be taken, if a
parameter map is reused for multiple calls, since the writer implementation may add or changes entries in the map.)IOException
protected abstract void doWriteDocument(DocumentDataAdapter document, Writer writer, ReadWriteParameterMap parameters) throws IOException
IOException