Top Description Inners Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.runtime.output

public Class XMLStreamWriterOutput

extends XmlOutputAbstractImpl
Class Inheritance
Known Direct Subclasses
org.glassfish.jaxb.runtime.v2.runtime.output.FastInfosetStreamWriterOutput, org.glassfish.jaxb.runtime.v2.runtime.output.StAXExStreamWriterOutput
Imports
org.glassfish.jaxb.core.marshaller.CharacterEscapeHandler, .NoEscapeHandler, org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl, .XMLSerializer, org.xml.sax.SAXException, javax.xml.stream.XMLStreamException, .XMLStreamWriter, java.io.IOException, .Writer, java.lang.reflect.Constructor

XmlOutput that writes to StAX XMLStreamWriter.

Todo

Finding the optimized FI implementations is a bit hacky and not very extensible. Can we use the service provider mechanism in general for concrete implementations of XmlOutputAbstractImpl.

Author
Kohsuke Kawaguchi

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
protected final char[]
private final CharacterEscapeHandler
private static final Constructor<? extends XmlOutput>
private static final Class<T>
FI_STAX_WRITER_CLASS

Reference to FI's XMLStreamWriter class, if FI can be loaded.

private final XMLStreamWriter
private static final Constructor<? extends XmlOutput>
private static final Class<T>
private final XMLStreamWriterOutput.XmlStreamOutWriterAdapter
Inherited from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl:
nsContextnsUriIndex2prefixIndexserializer

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
public void
public static XmlOutput
create(XMLStreamWriter out, JAXBContextImpl context, CharacterEscapeHandler escapeHandler)

Creates a new XmlOutput from a XMLStreamWriter.

public void
public void
public void
private static Constructor<? extends XmlOutput>
private static Class<T>
private static Constructor<? extends XmlOutput>
private static Class<T>
public void
public void
text(String value, boolean needsSeparatingWhitespace)

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Writes XML text with character escaping, if necessary.

public void
text(Pcdata value, boolean needsSeparatingWhitespace)

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Writes XML text with character escaping, if necessary.

Inherited from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl:
attributebeginStartTagendTag

Field Detail

bufback to summary
protected final char[] buf
escapeHandlerback to summary
private final CharacterEscapeHandler escapeHandler
FI_OUTPUT_CTORback to summary
private static final Constructor<? extends XmlOutput> FI_OUTPUT_CTOR
FI_STAX_WRITER_CLASSback to summary
private static final Class<T> FI_STAX_WRITER_CLASS

Reference to FI's XMLStreamWriter class, if FI can be loaded.

outback to summary
private final XMLStreamWriter out
STAXEX_OUTPUT_CTORback to summary
private static final Constructor<? extends XmlOutput> STAXEX_OUTPUT_CTOR
STAXEX_WRITER_CLASSback to summary
private static final Class<T> STAXEX_WRITER_CLASS
writerWrapperback to summary
private final XMLStreamWriterOutput.XmlStreamOutWriterAdapter writerWrapper

Constructor Detail

XMLStreamWriterOutputback to summary
protected XMLStreamWriterOutput(XMLStreamWriter out, CharacterEscapeHandler escapeHandler)

Method Detail

attributeback to summary
public void attribute(int prefix, String localName, String value) throws IOException, XMLStreamException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.attribute.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.attribute.

Annotations
@Override
beginStartTagback to summary
public void beginStartTag(int prefix, String localName) throws IOException, XMLStreamException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.beginStartTag.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.beginStartTag.

Annotations
@Override
createback to summary
public static XmlOutput create(XMLStreamWriter out, JAXBContextImpl context, CharacterEscapeHandler escapeHandler)

Creates a new XmlOutput from a XMLStreamWriter. This method recognizes an FI StAX writer.

endDocumentback to summary
public void endDocument(boolean fragment) throws IOException, SAXException, XMLStreamException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endDocument.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.endDocument.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endDocument.

Called at the very end.

Annotations
@Override
endStartTagback to summary
public void endStartTag() throws IOException, SAXException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endStartTag.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.endStartTag.

Annotations
@Override
endTagback to summary
public void endTag(int prefix, String localName) throws IOException, SAXException, XMLStreamException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.endTag.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.endTag.

Annotations
@Override
initFastInfosetOutputClassback to summary
private static Constructor<? extends XmlOutput> initFastInfosetOutputClass()
initFIStAXWriterClassback to summary
private static Class<T> initFIStAXWriterClass()
initStAXExOutputClassback to summary
private static Constructor<? extends XmlOutput> initStAXExOutputClass()
initStAXExWriterClassback to summary
private static Class<T> initStAXExWriterClass()
startDocumentback to summary
public void startDocument(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext) throws IOException, SAXException, XMLStreamException

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.startDocument.

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.startDocument.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutputAbstractImpl.startDocument.

Called at the very beginning.

Annotations
@Override
textback to summary
public void text(String value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Writes XML text with character escaping, if necessary.

Annotations
@Override
textback to summary
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException

Implements org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.XmlOutput.text.

Writes XML text with character escaping, if necessary.

Annotations
@Override
org.glassfish.jaxb.runtime.v2.runtime.output back to summary

private final Class XMLStreamWriterOutput.XmlStreamOutWriterAdapter

extends Writer
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final XMLStreamWriter
Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closes the stream, flushing it first.

public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushes the stream.

public void
write(char[] cbuf, int off, int len)

Implements abstract java.io.Writer.write.

Writes a portion of an array of characters.

public void
writeEntityRef(String entityReference)

Inherited from java.io.Writer:
appendappendappendnullWriterwritewritewritewrite

Field Detail

writerback to summary
private final XMLStreamWriter writer

Constructor Detail

XmlStreamOutWriterAdapterback to summary
private XmlStreamOutWriterAdapter(XMLStreamWriter writer)

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Doc from java.io.Writer.close.

Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
flushback to summary
public void flush() throws IOException

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Doc from java.io.Writer.flush.

Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(char[] cbuf, int off, int len) throws IOException

Implements abstract java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of an array of characters.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeEntityRefback to summary
public void writeEntityRef(String entityReference) throws XMLStreamException