Top Description Constructors Methods
org.codehaus.stax2.ri

public abstract Class Stax2WriterImpl

extends Object
implements XMLStreamWriter2, XMLStreamConstants
Class Inheritance
All Implemented Interfaces
javax.xml.stream.XMLStreamConstants, org.codehaus.stax2.XMLStreamWriter2, org.codehaus.stax2.validation.Validatable, org.codehaus.stax2.typed.TypedXMLStreamWriter, javax.xml.stream.XMLStreamWriter
Imports
javax.xml.stream.*, org.codehaus.stax2.*, org.codehaus.stax2.validation.*

This is a partial base implementation of XMLStreamWriter2, the extended stream writer that is part of Stax2.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
copyEventFromReader(XMLStreamReader2
Reader to use for accessing event to copy
sr
,
boolean
If true, writer is not allowed to change the state of the reader (so that all the data associated with the current event has to be preserved); if false, writer is allowed to use methods that may cause some data to be discarded. Setting this to false may improve the performance, since it may allow full no-copy streaming of data, especially textual contents.
preserveEventData
)

Implements org.codehaus.stax2.XMLStreamWriter2.copyEventFromReader.

Method that essentially copies event that the specified reader has just read.
protected void
copyStartElement(XMLStreamReader sr)

Basic implementation of copy operation.

public abstract String
getEncoding()

Redeclares org.codehaus.stax2.XMLStreamWriter2.getEncoding.

Method that can be called to get information about encoding that this writer is using (or at least claims is using).
public abstract XMLStreamLocation2
getLocation()

Redeclares org.codehaus.stax2.XMLStreamWriter2.getLocation.

Method that should return current output location, if the writer keeps track of it; null if it does not.
public boolean
isPropertySupported(String name)

Implements org.codehaus.stax2.XMLStreamWriter2.isPropertySupported.

Method similar to javax.xml.stream.XMLOutputFactory#isPropertySupported, used to determine whether a property is supported by the Writer instance.
public boolean
setProperty(String
Name of the property to set
name
,
Object
Value to set property to.
value
)

Implements org.codehaus.stax2.XMLStreamWriter2.setProperty.

Method that can be used to set per-writer properties; a subset of properties one can set via matching org.codehaus.stax2.XMLOutputFactory2 instance.
public ValidationProblemHandler
setValidationProblemHandler(ValidationProblemHandler
Handler to install, if non null; if null, indicates that the default (implementation-specific) handling should be used
h
)

Implements org.codehaus.stax2.validation.Validatable.setValidationProblemHandler.

Method that application can call to define a custom handler for validation problems encountered during validation process.
public XMLValidator
stopValidatingAgainst(XMLValidationSchema schema)

Implements org.codehaus.stax2.validation.Validatable.stopValidatingAgainst.

Method that can be called by application to stop validating output against a schema, for which validateAgainst was called earlier.
public XMLValidator
stopValidatingAgainst(XMLValidator validator)

Implements org.codehaus.stax2.validation.Validatable.stopValidatingAgainst.

Method that can be called by application to stop validating output using specified validator.
public XMLValidator
validateAgainst(XMLValidationSchema schema)

Implements org.codehaus.stax2.validation.Validatable.validateAgainst.

Method that will construct a XMLValidator instance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call to stopValidatingAgainst.
public void
writeCData(char[] text, int start, int len)

Implements org.codehaus.stax2.XMLStreamWriter2.writeCData.

public void
writeDTD(String rootName, String systemId, String publicId, String internalSubset)

Implements org.codehaus.stax2.XMLStreamWriter2.writeDTD.

public void
writeFullEndElement()

Implements org.codehaus.stax2.XMLStreamWriter2.writeFullEndElement.

Method similar to writeEndElement, but that will always write the full end element, instead of empty element.
public void
writeRaw(String text)

Implements org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Method that writes specified content as is, without encoding or deciphering it in any way.
public abstract void
writeRaw(String text, int offset, int len)

Redeclares org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Method that writes specified content as is, without encoding or deciphering it in any way.
public abstract void
writeRaw(char[] text, int offset, int length)

Redeclares org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Method that writes specified content as is, without encoding or deciphering it in any way.
public void
writeSpace(String text)

Implements org.codehaus.stax2.XMLStreamWriter2.writeSpace.

Method that can be called to write whitespace-only content.
public void
writeSpace(char[] text, int offset, int length)

Implements org.codehaus.stax2.XMLStreamWriter2.writeSpace.

Method that can be called to write whitespace-only content.
public abstract void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Stax2WriterImplback to summary
protected Stax2WriterImpl()

Method Detail

copyEventFromReaderback to summary
public void copyEventFromReader(XMLStreamReader2 sr, boolean preserveEventData) throws XMLStreamException

Implements org.codehaus.stax2.XMLStreamWriter2.copyEventFromReader.

Doc from org.codehaus.stax2.XMLStreamWriter2.copyEventFromReader.

Method that essentially copies event that the specified reader has just read. This can be both more convenient (no need to worry about details) and more efficient than separately calling access methods of the reader and write methods of the writer, since writer may know more about reader than the application (and may be able to use non-public methods)

Parameters
sr:XMLStreamReader2

Reader to use for accessing event to copy

preserveEventData:boolean

If true, writer is not allowed to change the state of the reader (so that all the data associated with the current event has to be preserved); if false, writer is allowed to use methods that may cause some data to be discarded. Setting this to false may improve the performance, since it may allow full no-copy streaming of data, especially textual contents.

Annotations
@Override
copyStartElementback to summary
protected void copyStartElement(XMLStreamReader sr) throws XMLStreamException

Basic implementation of copy operation. It is likely that sub-classes can implement more efficient copy operations: if so, they should do so.

getEncodingback to summary
public abstract String getEncoding()

Redeclares org.codehaus.stax2.XMLStreamWriter2.getEncoding.

Doc from org.codehaus.stax2.XMLStreamWriter2.getEncoding.

Method that can be called to get information about encoding that this writer is using (or at least claims is using). That is, it returns name of encoding specified when (in order of priority):

  • Passed to one of factory methods of javax.xml.stream.XMLOutputFactory
  • Passed to writeStartDocument method (explicitly or implicity; latter in cases where defaults are imposed by Stax specification)
Annotations
@Override
getLocationback to summary
public abstract XMLStreamLocation2 getLocation()

Redeclares org.codehaus.stax2.XMLStreamWriter2.getLocation.

Doc from org.codehaus.stax2.XMLStreamWriter2.getLocation.

Method that should return current output location, if the writer keeps track of it; null if it does not.

Annotations
@Override
isPropertySupportedback to summary
public boolean isPropertySupported(String name)

Implements org.codehaus.stax2.XMLStreamWriter2.isPropertySupported.

Doc from org.codehaus.stax2.XMLStreamWriter2.isPropertySupported.

Method similar to javax.xml.stream.XMLOutputFactory#isPropertySupported, used to determine whether a property is supported by the Writer instance. This means that this method may return false for some properties that the output factory does support: specifically, it should only return true if the value is mutable on per-instance basis. False means that either the property is not recognized, or is not mutable via writer instance.

Annotations
@Override
setPropertyback to summary
public boolean setProperty(String name, Object value)

Implements org.codehaus.stax2.XMLStreamWriter2.setProperty.

Doc from org.codehaus.stax2.XMLStreamWriter2.setProperty.

Method that can be used to set per-writer properties; a subset of properties one can set via matching org.codehaus.stax2.XMLOutputFactory2 instance. Exactly which methods are mutable is implementation specific.

Parameters
name:String

Name of the property to set

value:Object

Value to set property to.

Returns:boolean

True, if the specified property was succesfully set to specified value; false if its value was not changed

Annotations
@Override
setValidationProblemHandlerback to summary
public ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)

Implements org.codehaus.stax2.validation.Validatable.setValidationProblemHandler.

Doc from org.codehaus.stax2.validation.Validatable.setValidationProblemHandler.

Method that application can call to define a custom handler for validation problems encountered during validation process.

Parameters
h:ValidationProblemHandler

Handler to install, if non null; if null, indicates that the default (implementation-specific) handling should be used

Returns:ValidationProblemHandler

Previously set validation problem handler, if any; null if none was set

Annotations
@Override
stopValidatingAgainstback to summary
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws XMLStreamException

Implements org.codehaus.stax2.validation.Validatable.stopValidatingAgainst.

Doc from org.codehaus.stax2.validation.Validatable.stopValidatingAgainst.

Method that can be called by application to stop validating output against a schema, for which validateAgainst was called earlier.

Returns:XMLValidator

Validator instance created from the schema that was removed, if one was in use; null if no such schema in use.

Annotations
@Override
stopValidatingAgainstback to summary
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws XMLStreamException

Implements org.codehaus.stax2.validation.Validatable.stopValidatingAgainst.

Doc from org.codehaus.stax2.validation.Validatable.stopValidatingAgainst.

Method that can be called by application to stop validating output using specified validator. The validator passed should be an earlier return value for a call to validateAgainst.

Note

the specified validator is compared for identity with validators in use, not for equality.

Returns:XMLValidator

Validator instance found (ie. argument validator) if it was being used for validating current document; null if not.

Annotations
@Override
validateAgainstback to summary
public XMLValidator validateAgainst(XMLValidationSchema schema) throws XMLStreamException

Implements org.codehaus.stax2.validation.Validatable.validateAgainst.

Doc from org.codehaus.stax2.validation.Validatable.validateAgainst.

Method that will construct a XMLValidator instance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call to stopValidatingAgainst.

Note that while this method can be called at any point in output processing, validator instances are not required to be able to handle addition at other points than right before outputting the root element.

Returns:XMLValidator

Validator instance constructed, if validator was added, or null if a validator for the schema has already been constructed.

Annotations
@Override
writeCDataback to summary
public void writeCData(char[] text, int start, int len) throws XMLStreamException

Implements org.codehaus.stax2.XMLStreamWriter2.writeCData.

Annotations
@Override
writeDTDback to summary
public void writeDTD(String rootName, String systemId, String publicId, String internalSubset) throws XMLStreamException

Implements org.codehaus.stax2.XMLStreamWriter2.writeDTD.

Annotations
@Override
writeFullEndElementback to summary
public void writeFullEndElement() throws XMLStreamException

Implements org.codehaus.stax2.XMLStreamWriter2.writeFullEndElement.

Doc from org.codehaus.stax2.XMLStreamWriter2.writeFullEndElement.

Method similar to writeEndElement, but that will always write the full end element, instead of empty element. This only matters for cases where the element itself has no content, and if writer is allowed to write empty elements when it encounters such start/end element write pairs.

Annotations
@Override
writeRawback to summary
public void writeRaw(String text) throws XMLStreamException

Implements org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Doc from org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Method that writes specified content as is, without encoding or deciphering it in any way. It will not update state of the writer (except by possibly flushing output of previous writes, like finishing a start element), nor be validated in any way. As such, care must be taken, if this method is used.

Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.

Note

since text to be written may be anything, including markup, it can not be reliably validated. Because of this, validator(s) attached to the writer will NOT be informed about writes.

Annotations
@Override
writeRawback to summary
public abstract void writeRaw(String text, int offset, int len) throws XMLStreamException

Redeclares org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Doc from org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Method that writes specified content as is, without encoding or deciphering it in any way. It will not update state of the writer (except by possibly flushing output of previous writes, like finishing a start element), nor be validated in any way. As such, care must be taken, if this method is used.

Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.

Note

since text to be written may be anything, including markup, it can not be reliably validated. Because of this, validator(s) attached to the writer will NOT be informed about writes.

Annotations
@Override
writeRawback to summary
public abstract void writeRaw(char[] text, int offset, int length) throws XMLStreamException

Redeclares org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Doc from org.codehaus.stax2.XMLStreamWriter2.writeRaw.

Method that writes specified content as is, without encoding or deciphering it in any way. It will not update state of the writer (except by possibly flushing output of previous writes, like finishing a start element), nor be validated in any way. As such, care must be taken, if this method is used.

Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.

Note

since text to be written may be anything, including markup, it can not be reliably validated. Because of this, validator(s) attached to the writer will NOT be informed about writes.

Annotations
@Override
writeSpaceback to summary
public void writeSpace(String text) throws XMLStreamException

Implements org.codehaus.stax2.XMLStreamWriter2.writeSpace.

Doc from org.codehaus.stax2.XMLStreamWriter2.writeSpace.

Method that can be called to write whitespace-only content. If so, it is to be written as is (with no escaping), and does not contain non-whitespace characters (writer may validate this, and throw an exception if it does).

This method is useful for things like outputting indentation.

Annotations
@Override
writeSpaceback to summary
public void writeSpace(char[] text, int offset, int length) throws XMLStreamException

Implements org.codehaus.stax2.XMLStreamWriter2.writeSpace.

Doc from org.codehaus.stax2.XMLStreamWriter2.writeSpace.

Method that can be called to write whitespace-only content. If so, it is to be written as is (with no escaping), and does not contain non-whitespace characters (writer may validate this, and throw an exception if it does).

This method is useful for things like outputting indentation.

Annotations
@Override
writeStartDocumentback to summary
public abstract void writeStartDocument(String version, String encoding, boolean standAlone) throws XMLStreamException

Redeclares org.codehaus.stax2.XMLStreamWriter2.writeStartDocument.

Annotations
@Override