Javolution 6.0.0 java
javolution.xml.stream.XMLStreamWriter Interface Reference
Inheritance diagram for javolution.xml.stream.XMLStreamWriter:
[legend]

Public Member Functions

void writeStartElement (CharSequence localName) throws XMLStreamException
 
void writeStartElement (CharSequence namespaceURI, CharSequence localName) throws XMLStreamException
 
void writeStartElement (CharSequence prefix, CharSequence localName, CharSequence namespaceURI) throws XMLStreamException
 
void writeEmptyElement (CharSequence namespaceURI, CharSequence localName) throws XMLStreamException
 
void writeEmptyElement (CharSequence prefix, CharSequence localName, CharSequence namespaceURI) throws XMLStreamException
 
void writeEmptyElement (CharSequence localName) throws XMLStreamException
 
void writeEndElement () throws XMLStreamException
 
void writeEndDocument () throws XMLStreamException
 
void close () throws XMLStreamException
 
void flush () throws XMLStreamException
 
void writeAttribute (CharSequence localName, CharSequence value) throws XMLStreamException
 
void writeAttribute (CharSequence prefix, CharSequence namespaceURI, CharSequence localName, CharSequence value) throws XMLStreamException
 
void writeAttribute (CharSequence namespaceURI, CharSequence localName, CharSequence value) throws XMLStreamException
 
void writeNamespace (CharSequence prefix, CharSequence namespaceURI) throws XMLStreamException
 
void writeDefaultNamespace (CharSequence namespaceURI) throws XMLStreamException
 
void writeComment (CharSequence data) throws XMLStreamException
 
void writeProcessingInstruction (CharSequence target) throws XMLStreamException
 
void writeProcessingInstruction (CharSequence target, CharSequence data) throws XMLStreamException
 
void writeCData (CharSequence data) throws XMLStreamException
 
void writeDTD (CharSequence dtd) throws XMLStreamException
 
void writeEntityRef (CharSequence name) throws XMLStreamException
 
void writeStartDocument () throws XMLStreamException
 
void writeStartDocument (CharSequence version) throws XMLStreamException
 
void writeStartDocument (CharSequence encoding, CharSequence version) throws XMLStreamException
 
void writeCharacters (CharSequence text) throws XMLStreamException
 
void writeCharacters (char[] text, int start, int length) throws XMLStreamException
 
CharSequence getPrefix (CharSequence uri) throws XMLStreamException
 
void setPrefix (CharSequence prefix, CharSequence uri) throws XMLStreamException
 
void setDefaultNamespace (CharSequence uri) throws XMLStreamException
 
Object getProperty (String name) throws IllegalArgumentException
 

Detailed Description

This interface is similar to javax.xml.stream.XMLStreamWriter; but it does not forces dynamic allocation when formatting (any CharSequence can be used instead of String).

Except for the speed (faster) and the added flexibility, the usage/behavior is about the same as its StAX counterpart.

This writer does not require creating new String objects during XML formatting. Attributes values can be held by a single/reusable TextBuilder
(or StringBuilder) instance to avoid adverse effects on memory footprint (heap), garbage collection and performance. [code] // Creates a new writer (potentially recycled). XMLOutputFactory factory = OSGiServices.getXMLOutputFactory(); XMLStreamWriter writer = factory.createXMLStreamWriter(outputStream);

TextBuilder tmp = new TextBuilder(); // To avoid creating new String instances. writer.writeStartDocument(); writer.writeStartElement("Time"); writer.writeAttribute("hour", tmp.clear().append(time.hour); writer.writeAttribute("minute", tmp.clear().append(time.minute); writer.writeAttribute("second", tmp.clear().append(time.second); writer.writeEndElement(); writer.writeStartDocument();

writer.close(); // Closes the writer (does not close underlying output stream). [/code]

Author
Jean-Marie Dautelle
Version
6.0 December 12, 2012

Definition at line 47 of file XMLStreamWriter.java.

Member Function Documentation

◆ close()

void javolution.xml.stream.XMLStreamWriter.close ( ) throws XMLStreamException

Close this writer and free any resources associated with the writer. This must not close the underlying output stream.

Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ flush()

void javolution.xml.stream.XMLStreamWriter.flush ( ) throws XMLStreamException

Write any cached data to the underlying output mechanism.

Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ getPrefix()

CharSequence javolution.xml.stream.XMLStreamWriter.getPrefix ( CharSequence  uri) throws XMLStreamException

Gets the prefix the specified uri is bound to.

@param uri namespace URI
Returns
the prefix for the URI or null
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ getProperty()

Object javolution.xml.stream.XMLStreamWriter.getProperty ( String  name) throws IllegalArgumentException

Gets the value of a feature/property from the underlying implementation.

Parameters
namethe name of the property.
Returns
the value of the property.
Exceptions
IllegalArgumentExceptionif the property is not supported.

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ setDefaultNamespace()

void javolution.xml.stream.XMLStreamWriter.setDefaultNamespace ( CharSequence  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.

Parameters
urithe uri to bind to the default namespace or null.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ setPrefix()

void javolution.xml.stream.XMLStreamWriter.setPrefix ( CharSequence  prefix,
CharSequence  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.

Parameters
prefixthe prefix to bind to the uri.
urithe uri to bind to the prefix or null
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

Referenced by javolution.xml.ws.WebServiceClient.invoke().

Here is the caller graph for this function:

◆ writeAttribute() [1/3]

void javolution.xml.stream.XMLStreamWriter.writeAttribute ( CharSequence  localName,
CharSequence  value 
) throws XMLStreamException

Writes an attribute to the output stream without a prefix.

Parameters
localNamethe local name of the attribute.
valuethe value of the attribute.
Exceptions
IllegalStateExceptionif the current state does not allow attribute writing.
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeAttribute() [2/3]

void javolution.xml.stream.XMLStreamWriter.writeAttribute ( CharSequence  namespaceURI,
CharSequence  localName,
CharSequence  value 
) throws XMLStreamException

Writes an attribute to the output stream.

Parameters
namespaceURIthe uri of the prefix for this attribute.
localNamethe local name of the attribute.
valuethe value of the attribute.
Exceptions
IllegalStateExceptionif the current state does not allow attribute writing.
XMLStreamExceptionif the namespace URI has not been bound to a prefix and this writer does not repair namespaces.

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeAttribute() [3/3]

void javolution.xml.stream.XMLStreamWriter.writeAttribute ( CharSequence  prefix,
CharSequence  namespaceURI,
CharSequence  localName,
CharSequence  value 
) throws XMLStreamException

Writes an attribute to the output stream.

Parameters
prefixthe prefix for this attribute.
namespaceURIthe uri of the prefix for this attribute
localNamethe local name of the attribute.
valuethe value of the attribute.
Exceptions
IllegalStateExceptionif the current state does not allow attribute writing.
XMLStreamExceptionif the namespace URI has not been bound to a prefix and this writer does not repair namespaces.

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeCData()

void javolution.xml.stream.XMLStreamWriter.writeCData ( CharSequence  data) throws XMLStreamException

Writes a CData section.

Parameters
datathe data contained in the CData Section.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeCharacters() [1/2]

void javolution.xml.stream.XMLStreamWriter.writeCharacters ( char[]  text,
int  start,
int  length 
) throws XMLStreamException

Writes text to the output.

Parameters
textthe value to write
startthe starting position in the array.
lengththe number of characters to write.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeCharacters() [2/2]

void javolution.xml.stream.XMLStreamWriter.writeCharacters ( CharSequence  text) throws XMLStreamException

Writes text to the output.

Parameters
textthe value to write or null.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeComment()

void javolution.xml.stream.XMLStreamWriter.writeComment ( CharSequence  data) throws XMLStreamException

Writes an xml comment with the data enclosed.

Parameters
datathe data contained in the comment or null
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeDefaultNamespace()

void javolution.xml.stream.XMLStreamWriter.writeDefaultNamespace ( CharSequence  namespaceURI) throws XMLStreamException

Writes the default namespace to the stream.

Parameters
namespaceURIthe uri to bind the default namespace to or null (to map the prefix to "" URI)
Exceptions
IllegalStateExceptionif the current state does not allow namespace writing.
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeDTD()

void javolution.xml.stream.XMLStreamWriter.writeDTD ( CharSequence  dtd) throws XMLStreamException

Writes a DTD section (representing the entire doctypedecl production from the XML 1.0 specification).

Parameters
dtdthe DTD to be written.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeEmptyElement() [1/3]

void javolution.xml.stream.XMLStreamWriter.writeEmptyElement ( CharSequence  localName) throws XMLStreamException

Writes an empty element tag to the output.

Parameters
localNamelocal name of the tag.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeEmptyElement() [2/3]

void javolution.xml.stream.XMLStreamWriter.writeEmptyElement ( CharSequence  namespaceURI,
CharSequence  localName 
) throws XMLStreamException

Writes an empty element tag to the output.

Parameters
namespaceURIthe uri to bind the tag to.
localNamelocal name of the tag.
Exceptions
XMLStreamExceptionif the namespace URI has not been bound to a prefix and this writer does not repair namespaces.

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeEmptyElement() [3/3]

void javolution.xml.stream.XMLStreamWriter.writeEmptyElement ( CharSequence  prefix,
CharSequence  localName,
CharSequence  namespaceURI 
) throws XMLStreamException

Writes an empty element tag to the output.

Parameters
prefixthe prefix of the tag.
localNamelocal name of the tag.
namespaceURIthe uri to bind the tag to.
Exceptions
XMLStreamExceptionif the namespace URI has not been bound to a prefix and this writer does not repair namespaces.

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeEndDocument()

void javolution.xml.stream.XMLStreamWriter.writeEndDocument ( ) throws XMLStreamException

Closes any start tags and writes corresponding end tags.

Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeEndElement()

void javolution.xml.stream.XMLStreamWriter.writeEndElement ( ) throws XMLStreamException

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.

Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

Referenced by javolution.xml.ws.WebServiceClient.invoke().

Here is the caller graph for this function:

◆ writeEntityRef()

void javolution.xml.stream.XMLStreamWriter.writeEntityRef ( CharSequence  name) throws XMLStreamException

Writes an entity reference

Parameters
namethe name of the entity.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeNamespace()

void javolution.xml.stream.XMLStreamWriter.writeNamespace ( CharSequence  prefix,
CharSequence  namespaceURI 
) throws XMLStreamException

Writes a namespace to the output stream. If the prefix argument to this method is the empty string, "xmlns", or null this method will delegate to writeDefaultNamespace.

Parameters
prefixthe prefix to bind this namespace to or null
namespaceURIthe uri to bind the prefix.
Exceptions
IllegalStateExceptionif the current state does not allow namespace writing.
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

Referenced by javolution.xml.ws.WebServiceClient.invoke().

Here is the caller graph for this function:

◆ writeProcessingInstruction() [1/2]

void javolution.xml.stream.XMLStreamWriter.writeProcessingInstruction ( CharSequence  target) throws XMLStreamException

Writes a processing instruction.

Parameters
targetthe target of the processing instruction.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeProcessingInstruction() [2/2]

void javolution.xml.stream.XMLStreamWriter.writeProcessingInstruction ( CharSequence  target,
CharSequence  data 
) throws XMLStreamException

Writes a processing instruction

Parameters
targetthe target of the processing instruction.
datathe data contained in the processing instruction.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeStartDocument() [1/3]

void javolution.xml.stream.XMLStreamWriter.writeStartDocument ( ) throws XMLStreamException

Writes the XML Declaration. Defaults the XML version to 1.0 and the encoding (if any) to the one specified when the instance is created using XMLOutputFactory.

Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeStartDocument() [2/3]

void javolution.xml.stream.XMLStreamWriter.writeStartDocument ( CharSequence  encoding,
CharSequence  version 
) throws XMLStreamException

Writes the XML Declaration. Note that the encoding parameter does not set the actual encoding of the underlying output. That must be set when the instance when the instance is created using XMLOutputFactory.

Parameters
encodingthe encoding of the xml declaration or null.
versionthe version of the xml document or null.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeStartDocument() [3/3]

void javolution.xml.stream.XMLStreamWriter.writeStartDocument ( CharSequence  version) throws XMLStreamException

Writes the XML Declaration. Default the encoding (if any) to the one specified when the instance is created using XMLOutputFactory.

Parameters
versionthe version of the xml document or null.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeStartElement() [1/3]

void javolution.xml.stream.XMLStreamWriter.writeStartElement ( CharSequence  localName) throws XMLStreamException

Writes a start tag to the output. All writeStartElement methods open a new scope in the internal namespace context. Writing the corresponding EndElement causes the scope to be closed.

Parameters
localNamelocal name of the tag.
Exceptions
XMLStreamException

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

Referenced by javolution.xml.ws.WebServiceClient.invoke().

Here is the caller graph for this function:

◆ writeStartElement() [2/3]

void javolution.xml.stream.XMLStreamWriter.writeStartElement ( CharSequence  namespaceURI,
CharSequence  localName 
) throws XMLStreamException

Writes a start tag to the output.

Parameters
namespaceURIthe namespaceURI of the prefix to use.
localNamelocal name of the tag.
Exceptions
XMLStreamExceptionif the namespace URI has not been bound to a prefix and this writer does not repair namespaces.

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.

◆ writeStartElement() [3/3]

void javolution.xml.stream.XMLStreamWriter.writeStartElement ( CharSequence  prefix,
CharSequence  localName,
CharSequence  namespaceURI 
) throws XMLStreamException

Writes a start tag to the output.

Parameters
localNamelocal name of the tag.
prefixthe prefix of the tag.
namespaceURIthe uri to bind the prefix to.
Exceptions
XMLStreamExceptionif the namespace URI has not been bound to a prefix and this writer does not repair namespaces.

Implemented in javolution.xml.internal.stream.XMLStreamWriterImpl.


The documentation for this interface was generated from the following file: