Class StAXEventWriter
- java.lang.Object
-
- com.sun.xml.fastinfoset.stax.events.StAXEventWriter
-
- All Implemented Interfaces:
XMLEventConsumer,XMLEventWriter
public class StAXEventWriter extends Object implements XMLEventWriter
-
-
Constructor Summary
Constructors Constructor Description StAXEventWriter(XMLStreamWriter streamWriter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(XMLEvent event)Add an event to the output stream Adding a START_ELEMENT will open a new namespace scope that will be closed when the corresponding END_ELEMENT is written.voidadd(XMLEventReader eventReader)voidclose()Frees any resources associated with this streamvoidflush()Writes any cached events to the underlying output mechanismNamespaceContextgetNamespaceContext()Returns the current namespace context.StringgetPrefix(String uri)Gets the prefix the uri is bound tovoidsetDefaultNamespace(String uri)Binds a URI to the default namespace This URI is bound in the scope of the current START_ELEMENT / END_ELEMENT pair.voidsetNamespaceContext(NamespaceContext namespaceContext)Sets the current namespace context for prefix and uri bindings.voidsetPrefix(String prefix, String uri)Sets the prefix the uri is bound to.
-
-
-
Constructor Detail
-
StAXEventWriter
public StAXEventWriter(XMLStreamWriter streamWriter)
- Parameters:
streamWriter-
-
-
Method Detail
-
flush
public void flush() throws XMLStreamExceptionWrites any cached events to the underlying output mechanism- Specified by:
flushin interfaceXMLEventWriter- Throws:
XMLStreamException
-
close
public void close() throws XMLStreamExceptionFrees any resources associated with this stream- Specified by:
closein interfaceXMLEventWriter- Throws:
XMLStreamException
-
add
public void add(XMLEventReader eventReader) throws XMLStreamException
- Specified by:
addin interfaceXMLEventWriter- Parameters:
eventReader-- Throws:
XMLStreamException
-
add
public void add(XMLEvent event) throws XMLStreamException
Add an event to the output stream Adding a START_ELEMENT will open a new namespace scope that will be closed when the corresponding END_ELEMENT is written.- Specified by:
addin interfaceXMLEventConsumer- Specified by:
addin interfaceXMLEventWriter- Parameters:
event-- Throws:
XMLStreamException
-
getPrefix
public String getPrefix(String uri) throws XMLStreamException
Gets the prefix the uri is bound to- Specified by:
getPrefixin interfaceXMLEventWriter- Parameters:
uri- the uri to look up- Throws:
XMLStreamException
-
getNamespaceContext
public NamespaceContext getNamespaceContext()
Returns the current namespace context.- Specified by:
getNamespaceContextin interfaceXMLEventWriter- Returns:
- the current namespace context
-
setDefaultNamespace
public void setDefaultNamespace(String uri) throws XMLStreamException
Binds a URI to the default namespace This URI is bound in the scope of the current START_ELEMENT / END_ELEMENT pair. If this method is called before a START_ELEMENT has been written the uri is bound in the root scope.- Specified by:
setDefaultNamespacein interfaceXMLEventWriter- Parameters:
uri- the uri to bind to the default namespace- Throws:
XMLStreamException
-
setNamespaceContext
public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException
Sets the current namespace context for prefix and uri bindings. This context becomes the root namespace context for writing and will replace the current root namespace context. Subsequent calls to setPrefix and setDefaultNamespace will bind namespaces using the context passed to the method as the root context for resolving namespaces.- Specified by:
setNamespaceContextin interfaceXMLEventWriter- Parameters:
namespaceContext- the namespace context to use for this writer- Throws:
XMLStreamException
-
setPrefix
public void setPrefix(String prefix, String uri) throws XMLStreamException
Sets the prefix the uri is bound to. This prefix is bound in the scope of the current START_ELEMENT / END_ELEMENT pair. If this method is called before a START_ELEMENT has been written the prefix is bound in the root scope.- Specified by:
setPrefixin interfaceXMLEventWriter- Parameters:
prefix- the prefix to bind to the uriuri- the uri to bind to the prefix- Throws:
XMLStreamException
-
-