W
- the type of writer to write the data to (usually Writer
or XMLStreamWriter
)public class BasicEventReceiver<P extends WriterStreamDataProvider<? extends AbstractEventWriter<P>>> extends java.lang.Object implements JPhyloIOEventReceiver
Constructor and Description |
---|
BasicEventReceiver(P streamDataProvider,
ReadWriteParameterMap parameterMap)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(JPhyloIOEvent event)
Adds a new event to the sequence written to this receiver.
|
protected void |
addIgnoredComments(long addend) |
protected void |
addIgnoredLiteralMetadata(long addend) |
protected void |
addIgnoredResourceMetadata(long addend) |
void |
addIgnoreLogMessage(ApplicationLogger logger,
java.lang.String objectName,
java.lang.String formatName) |
boolean |
didIgnoreComments() |
boolean |
didIgnoreLiteralMetadata() |
boolean |
didIgnoreMetadata() |
boolean |
didIgnoreResourceMetadata() |
protected boolean |
doAdd(JPhyloIOEvent event)
This method is called internally by
add(JPhyloIOEvent) to process events that do not model metadata or
comments. |
long |
getIgnoredComments() |
long |
getIgnoredLiteralMetadata() |
long |
getIgnoredMetadata() |
long |
getIgnoredResourceMetadata() |
ApplicationLogger |
getLogger() |
ReadWriteParameterMap |
getParameterMap() |
JPhyloIOEvent |
getParentEvent() |
java.util.Stack<JPhyloIOEvent> |
getParentEvents() |
P |
getStreamDataProvider() |
protected void |
handleComment(CommentEvent event) |
protected void |
handleLiteralContentMeta(LiteralMetadataContentEvent event) |
protected void |
handleLiteralMetaStart(LiteralMetadataEvent event) |
protected void |
handleMetaEndEvent(JPhyloIOEvent event) |
protected void |
handleResourceMetaStart(ResourceMetadataEvent event) |
boolean |
isInComment()
Determines whether the last event was a continued comment event and the next event is expected to be the continuing comment event.
|
public BasicEventReceiver(P streamDataProvider, ReadWriteParameterMap parameterMap)
writer
- the writer to write data to (e.g. an instance of Writer
or XMLStreamWriter
)parameterMap
- the parameter map of the event writer that will be using this receiver instancepublic ReadWriteParameterMap getParameterMap()
public P getStreamDataProvider()
public ApplicationLogger getLogger()
public java.util.Stack<JPhyloIOEvent> getParentEvents()
public JPhyloIOEvent getParentEvent()
public boolean isInComment()
handleComment(CommentEvent)
was called.true
if the last event was a continued comment event, false
otherwisepublic long getIgnoredComments()
public boolean didIgnoreComments()
protected void addIgnoredComments(long addend)
public long getIgnoredLiteralMetadata()
public boolean didIgnoreLiteralMetadata()
protected void addIgnoredLiteralMetadata(long addend)
public long getIgnoredResourceMetadata()
public boolean didIgnoreResourceMetadata()
public boolean didIgnoreMetadata()
public long getIgnoredMetadata()
protected void addIgnoredResourceMetadata(long addend)
protected void handleLiteralMetaStart(LiteralMetadataEvent event) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected void handleLiteralContentMeta(LiteralMetadataContentEvent event) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected void handleResourceMetaStart(ResourceMetadataEvent event) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected void handleComment(CommentEvent event) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected void handleMetaEndEvent(JPhyloIOEvent event) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected boolean doAdd(JPhyloIOEvent event) throws java.io.IOException, javax.xml.stream.XMLStreamException
add(JPhyloIOEvent)
to process events that do not model metadata or
comments. (Such events are treated by the according special methods of this class).
This default implementation just throws an IllegalEventException
. Inherited classes that need to support other
events then these modeling metadata or comments, must overwrite this method.
event
- the event to be processedtrue
if more events can be written to this acceptor or false
if writing should
be abortedIllegalEventException
- if the specified event is illegal in this acceptor in general or at
the current position in the sequencejava.lang.ClassCastException
- if an event object was specified that is not an instance of a class associated
with its type as document in EventContentType
java.io.IOException
- if an I/O error occurs when writing to the underlying streamjavax.xml.stream.XMLStreamException
- if an XML stream error occurs when writing to the underlying streampublic boolean add(JPhyloIOEvent event) throws java.io.IOException
JPhyloIOEventReceiver
Note that this acceptor indicates whether writing events shall be aborted by its return value.
This maybe the case, if the writer providing this acceptor was seeking for a specific piece of
information and is (currently) not interested in the remaining events. Data adapter implemented
by applications should consider the return value to allow saving runtime. If event writing goes
on after false
was returned, subsequent events will be ignored but no exception will be
thrown.
Conversely, a return value of true
does not necessarily mean that more events are expected
in order to complete the expected information.
Exceptions thrown by this instance should not be caught within any of the write*()
methods
in application implementations of any data adapter (e.g.
MatrixDataAdapter.writeSequencePartContentData(ReadWriteParameterMap, JPhyloIOEventReceiver, String, long, long)
.
They will be forwarded by the calling writer and can be handled by the application when
JPhyloIOEventWriter.writeDocument(DocumentDataAdapter, Writer, ReadWriteParameterMap)
(or one of the other overloaded versions) are called.
add
in interface JPhyloIOEventReceiver
event
- the event to be addtrue
if more events can be written to this acceptor or false
if writing should
be abortedjava.io.IOException
- if an I/O error occurs when writing to the underlying streampublic void addIgnoreLogMessage(ApplicationLogger logger, java.lang.String objectName, java.lang.String formatName)