public class MetaXMLEventWriter extends AbstractMetaXMLWriter implements XMLEventWriter
JPhyloIOEventWriter
. Instances of this class should not (and cannot) be created directly in application code, but
JPhyloIOXMLEventWriter.createMetaXMLEventWriter(JPhyloIOEventReceiver)
should be used instead.
Attributes of a start document event are not processed, since it is not possible to write them at this position of the document.
This writer does not have the necessary information (e.g. predicate) to be able to write literal meta start and end events, therefore this has to be done by the application itself.
This writer does not manage namespaces of custom XML elements. The application needs to ensure that all used prefixes
(either in any elements, attributes or character data) are properly declared within the custom XML
(e.g. by adding Namespace
events). Any methods of this writer changing the namespace mapping or obtaining information
about it refer to the underlying writer. Note that if the default namespace is changed (either by setting a new default namespace or a completely
new namespace context object) while this reader is on the top level of custom XML, it is possible that the literal meta
end tag is written with the wrong default namespace (it would be written with a prefix then).
Constructor and Description |
---|
MetaXMLEventWriter(JPhyloIOEventReceiver receiver,
XMLStreamWriter underlyingXMLWriter)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
add(XMLEvent event) |
void |
add(XMLEventReader xmlReader) |
void |
close()
This method has no effect in this writer.
|
void |
flush()
This method has no effect in this writer, since the underlying
JPhyloIOEventWriter
does not implement a flush() method. |
NamespaceContext |
getNamespaceContext()
Returns the current namespace context of the underlying XML event writer, if
|
String |
getPrefix(String uri) |
void |
setDefaultNamespace(String uri) |
void |
setNamespaceContext(NamespaceContext context) |
void |
setPrefix(String prefix,
String uri) |
getReceiver, getUnderlyingXMLWriter
public MetaXMLEventWriter(JPhyloIOEventReceiver receiver, XMLStreamWriter underlyingXMLWriter)
receiver
- the event receiver to write the JPhyloIO events created by this writer topublic void add(XMLEvent event) throws XMLStreamException
add
in interface XMLEventConsumer
add
in interface XMLEventWriter
XMLStreamException
public void add(XMLEventReader xmlReader) throws XMLStreamException
add
in interface XMLEventWriter
XMLStreamException
public void close() throws XMLStreamException
close
in interface XMLEventWriter
XMLStreamException
public void flush() throws XMLStreamException
JPhyloIOEventWriter
does not implement a flush() method.flush
in interface XMLEventWriter
XMLStreamException
public NamespaceContext getNamespaceContext()
getNamespaceContext
in interface XMLEventWriter
XMLEventWriter.getNamespaceContext()
public String getPrefix(String uri) throws XMLStreamException
getPrefix
in interface XMLEventWriter
XMLStreamException
public void setDefaultNamespace(String uri) throws XMLStreamException
setDefaultNamespace
in interface XMLEventWriter
XMLStreamException
public void setNamespaceContext(NamespaceContext context) throws XMLStreamException
setNamespaceContext
in interface XMLEventWriter
XMLStreamException
public void setPrefix(String prefix, String uri) throws XMLStreamException
setPrefix
in interface XMLEventWriter
XMLStreamException