Top Description Fields Constructors Methods
org.codehaus.stax2.ri

public Class Stax2EventWriterImpl

extends Object
implements XMLEventWriter, XMLStreamConstants
Class Inheritance
All Implemented Interfaces
javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLEventWriter, javax.xml.stream.util.XMLEventConsumer
Imports
java.util.Iterator, javax.xml.namespace.NamespaceContext, .QName, javax.xml.stream.*, javax.xml.stream.events.*, org.codehaus.stax2.*, org.codehaus.stax2.evt.XMLEvent2

Simple implementation of XMLEventWriter.

Field Summary

Modifier and TypeField and Description
protected final XMLStreamWriter2

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(XMLEvent
the event to be added
event
)

Implements javax.xml.stream.XMLEventWriter.add.

Basic implementation of the method which will use event implementations available as part of the reference implementation.
public void
add(XMLEventReader
the event stream to add to the output
reader
)

Implements javax.xml.stream.XMLEventWriter.add.

Adds an entire stream to an output stream, calls next() on the inputStream argument until hasNext() returns false This should be treated as a convenience method that will perform the following loop over all the events in an event reader and call add on each event.
public void
close()

Implements javax.xml.stream.XMLEventWriter.close.

Frees any resources associated with this stream
public void
flush()

Implements javax.xml.stream.XMLEventWriter.flush.

Writes any cached events to the underlying output mechanism
public NamespaceContext
getNamespaceContext()

Implements javax.xml.stream.XMLEventWriter.getNamespaceContext.

Returns the current namespace context.
public String
getPrefix(String
the uri to look up
uri
)

Implements javax.xml.stream.XMLEventWriter.getPrefix.

Gets the prefix the uri is bound to
public void
setDefaultNamespace(String
the uri to bind to the default namespace
uri
)

Implements javax.xml.stream.XMLEventWriter.setDefaultNamespace.

Binds a URI to the default namespace This URI is bound in the scope of the current START_ELEMENT / END_ELEMENT pair.
public void
setNamespaceContext(NamespaceContext
the namespace context to use for this writer
ctxt
)

Implements javax.xml.stream.XMLEventWriter.setNamespaceContext.

Sets the current namespace context for prefix and uri bindings.
public void
setPrefix(String
the prefix to bind to the uri
prefix
,
String
the uri to bind to the prefix
uri
)

Implements javax.xml.stream.XMLEventWriter.setPrefix.

Sets the prefix the uri is bound to.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_writerback to summary
protected final XMLStreamWriter2 _writer

Constructor Detail

Stax2EventWriterImplback to summary
public Stax2EventWriterImpl(XMLStreamWriter2 sw)

Method Detail

addback to summary
public void add(XMLEvent event) throws XMLStreamException

Implements javax.xml.stream.XMLEventWriter.add.

Basic implementation of the method which will use event implementations available as part of the reference implementation.

Note

ALL events (except for custom ones ref. impl. itself doesn't produce, and thus may not always be able to deal with) are routed through stream writer. This because it may want to do different kinds of validation

Parameters
event:XMLEvent

Doc from javax.xml.stream.XMLEventWriter.add.

the event to be added

Annotations
@Override
Exceptions
XMLStreamException:

Doc from javax.xml.stream.XMLEventWriter.add.

if an error occurs

addback to summary
public void add(XMLEventReader reader) throws XMLStreamException

Implements javax.xml.stream.XMLEventWriter.add.

Doc from javax.xml.stream.XMLEventWriter.add.

Adds an entire stream to an output stream, calls next() on the inputStream argument until hasNext() returns false This should be treated as a convenience method that will perform the following loop over all the events in an event reader and call add on each event.

Parameters
reader:XMLEventReader

the event stream to add to the output

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
closeback to summary
public void close() throws XMLStreamException

Implements javax.xml.stream.XMLEventWriter.close.

Doc from javax.xml.stream.XMLEventWriter.close.

Frees any resources associated with this stream

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
flushback to summary
public void flush() throws XMLStreamException

Implements javax.xml.stream.XMLEventWriter.flush.

Doc from javax.xml.stream.XMLEventWriter.flush.

Writes any cached events to the underlying output mechanism

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
getNamespaceContextback to summary
public NamespaceContext getNamespaceContext()

Implements javax.xml.stream.XMLEventWriter.getNamespaceContext.

Doc from javax.xml.stream.XMLEventWriter.getNamespaceContext.

Returns the current namespace context.

Returns:NamespaceContext

the current namespace context

Annotations
@Override
getPrefixback to summary
public String getPrefix(String uri) throws XMLStreamException

Implements javax.xml.stream.XMLEventWriter.getPrefix.

Doc from javax.xml.stream.XMLEventWriter.getPrefix.

Gets the prefix the uri is bound to

Parameters
uri:String

the uri to look up

Returns:String

the prefix

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
setDefaultNamespaceback to summary
public void setDefaultNamespace(String uri) throws XMLStreamException

Implements javax.xml.stream.XMLEventWriter.setDefaultNamespace.

Doc from javax.xml.stream.XMLEventWriter.setDefaultNamespace.

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.

Parameters
uri:String

the uri to bind to the default namespace

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
setNamespaceContextback to summary
public void setNamespaceContext(NamespaceContext ctxt) throws XMLStreamException

Implements javax.xml.stream.XMLEventWriter.setNamespaceContext.

Doc from javax.xml.stream.XMLEventWriter.setNamespaceContext.

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.

Parameters
ctxt:NamespaceContext

the namespace context to use for this writer

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
setPrefixback to summary
public void setPrefix(String prefix, String uri) throws XMLStreamException

Implements javax.xml.stream.XMLEventWriter.setPrefix.

Doc from javax.xml.stream.XMLEventWriter.setPrefix.

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.

Parameters
prefix:String

the prefix to bind to the uri

uri:String

the uri to bind to the prefix

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs