public abstract class AbstractEventWriter<P extends WriterStreamDataProvider<? extends AbstractEventWriter<P>>> extends java.lang.Object implements JPhyloIOEventWriter
Modifier and Type | Class and Description |
---|---|
static class |
AbstractEventWriter.NoEditUniqueLabelHandler |
static interface |
AbstractEventWriter.UniqueLabelHandler |
Modifier and Type | Field and Description |
---|---|
static java.lang.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 java.lang.String |
createUniqueLabel(ReadWriteParameterMap parameters,
AbstractEventWriter.UniqueLabelHandler handler,
LabeledIDEvent event) |
static java.lang.String |
createUniqueLabel(ReadWriteParameterMap parameters,
AbstractEventWriter.UniqueLabelHandler handler,
java.lang.String label1,
java.lang.String id1,
java.lang.String label2,
java.lang.String id2) |
static java.lang.String |
createUniqueLabel(ReadWriteParameterMap parameters,
LabeledIDEvent event) |
static java.lang.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,
java.io.Writer writer,
ReadWriteParameterMap parameters) |
protected void |
extendSequence(MatrixDataAdapter matrix,
ReadWriteParameterMap parameters,
java.lang.String sequenceID,
long targetLength,
java.lang.String extensionToken,
JPhyloIOEventReceiver receiver) |
protected java.lang.String |
getFileStartInfo(ReadWriteParameterMap parameters) |
protected java.lang.String |
getIndention() |
static java.lang.String |
getLabeledIDName(LabeledIDEvent event)
Returns a name for the specified event.
|
static java.lang.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 java.lang.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,
java.lang.String formatName,
java.lang.String labeledElements)
Outputs a warning message, if the specified document data adapter provides one or more OTU lists.
|
void |
writeDocument(DocumentDataAdapter document,
java.io.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,
java.io.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,
java.io.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(java.io.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(java.io.Writer writer,
java.lang.String text) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFormatID
public static final java.lang.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(java.io.Writer writer, ReadWriteParameterMap parameters) throws java.io.IOException
writer
- the writer to write the line break toparameters
- the parameter map possibly containing a line separator definitionjava.io.IOException
- if an I/O error occurs while writing to the specified writerpublic static void logIngnoredOTULists(DocumentDataAdapter document, ApplicationLogger logger, ReadWriteParameterMap parameters, java.lang.String formatName, java.lang.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 java.lang.String getLabeledIDName(LabeledIDEvent event)
event
- the event to get the name ofpublic static java.lang.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 java.lang.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 OTUjava.lang.IllegalArgumentException
- 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 java.lang.String getIndention()
protected void writeLineStart(java.io.Writer writer, java.lang.String text) throws java.io.IOException
java.io.IOException
protected void increaseIndention()
protected void decreaseIndention()
public static java.lang.String createUniqueLabel(ReadWriteParameterMap parameters, AbstractEventWriter.UniqueLabelHandler handler, java.lang.String label1, java.lang.String id1, java.lang.String label2, java.lang.String id2)
public static java.lang.String createUniqueLabel(ReadWriteParameterMap parameters, AbstractEventWriter.UniqueLabelHandler handler, LabeledIDEvent event)
public static java.lang.String createUniqueLabel(ReadWriteParameterMap parameters, LabeledIDEvent event)
public static java.lang.String createUniqueLinkedOTULabel(ReadWriteParameterMap parameters, AbstractEventWriter.UniqueLabelHandler handler, LinkedLabeledIDEvent event, OTUListDataAdapter otuList, boolean otuFirst)
protected void extendSequence(MatrixDataAdapter matrix, ReadWriteParameterMap parameters, java.lang.String sequenceID, long targetLength, java.lang.String extensionToken, JPhyloIOEventReceiver receiver) throws java.io.IOException
java.io.IOException
protected java.lang.String getFileStartInfo(ReadWriteParameterMap parameters)
public void writeDocument(DocumentDataAdapter document, java.io.File file, ReadWriteParameterMap parameters) throws java.io.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.)java.io.IOException
public void writeDocument(DocumentDataAdapter document, java.io.OutputStream stream, ReadWriteParameterMap parameters) throws java.io.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.)java.io.IOException
public void writeDocument(DocumentDataAdapter document, java.io.Writer writer, ReadWriteParameterMap parameters) throws java.io.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.)java.io.IOException
protected abstract void doWriteDocument(DocumentDataAdapter document, java.io.Writer writer, ReadWriteParameterMap parameters) throws java.io.IOException
java.io.IOException