Top Description Fields Constructors Methods
org.springframework.util.xml

pack-priv Class StaxStreamHandler

extends AbstractStaxHandler
Class Inheritance
Imports
java.util.Map, javax.xml.XMLConstants, javax.xml.namespace.QName, javax.xml.stream.XMLStreamException, .XMLStreamWriter, org.xml.sax.Attributes, .Locator, .SAXException, org.xml.sax.ext.LexicalHandler

SAX org.xml.sax.ContentHandler and LexicalHandler that writes to an XMLStreamWriter.
Author
Arjen Poutsma
Since
4.0.3

Field Summary

Modifier and TypeField and Description
private final XMLStreamWriter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
protected void
protected void
protected void
protected void
public void
endEntity(String
The name of the entity that is ending.
name
)

Overrides org.springframework.util.xml.AbstractStaxHandler.endEntity.

Implements org.xml.sax.ext.LexicalHandler.endEntity.

Report the end of an entity.

protected void
protected void
public void
setDocumentLocator(Locator
an object that can return the location of any SAX document event
locator
)

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Receive an object for locating the origin of SAX document events.

protected void
protected void
protected void
public void
startEntity(String
The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]".
name
)

Overrides org.springframework.util.xml.AbstractStaxHandler.startEntity.

Implements org.xml.sax.ext.LexicalHandler.startEntity.

Report the beginning of some internal and external XML entities.

Inherited from org.springframework.util.xml.AbstractStaxHandler:
characterscommentendCDATAendDocumentendDTDendElementendPrefixMappingignorableWhitespaceisNamespaceDeclarationprocessingInstructionskippedEntitystartCDATAstartDocumentstartDTDstartElementstartPrefixMappingtoQName

Field Detail

streamWriterback to summary
private final XMLStreamWriter streamWriter

Constructor Detail

StaxStreamHandlerback to summary
public StaxStreamHandler(XMLStreamWriter streamWriter)

Method Detail

cDataInternalback to summary
protected void cDataInternal(String data) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.cDataInternal.

Annotations
@Override
charactersInternalback to summary
protected void charactersInternal(String data) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.charactersInternal.

Annotations
@Override
commentInternalback to summary
protected void commentInternal(String comment) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.commentInternal.

Annotations
@Override
dtdInternalback to summary
protected void dtdInternal(String dtd) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.dtdInternal.

Annotations
@Override
endDocumentInternalback to summary
protected void endDocumentInternal() throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.endDocumentInternal.

Annotations
@Override
endElementInternalback to summary
protected void endElementInternal(QName name, Map<String, String> namespaceMapping) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.endElementInternal.

Annotations
@Override
endEntityback to summary
public void endEntity(String name) throws SAXException

Overrides org.springframework.util.xml.AbstractStaxHandler.endEntity.

Implements org.xml.sax.ext.LexicalHandler.endEntity.

Doc from org.xml.sax.ext.LexicalHandler.endEntity.

Report the end of an entity.

Parameters
name:String

The name of the entity that is ending.

Annotations
@Override
Exceptions
SAXException:
The application may raise an exception.
ignorableWhitespaceInternalback to summary
protected void ignorableWhitespaceInternal(String data) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.ignorableWhitespaceInternal.

Annotations
@Override
processingInstructionInternalback to summary
protected void processingInstructionInternal(String target, String data) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.processingInstructionInternal.

Annotations
@Override
setDocumentLocatorback to summary
public void setDocumentLocator(Locator locator)

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Doc from org.xml.sax.ContentHandler.setDocumentLocator.

Receive an object for locating the origin of SAX document events.

SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the ContentHandler interface.

The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine.

Note that the locator will return correct information only during the invocation SAX event callbacks after startDocument returns and before endDocument is called. The application should not attempt to use it at any other time.

Parameters
locator:Locator

an object that can return the location of any SAX document event

Annotations
@Override
skippedEntityInternalback to summary
protected void skippedEntityInternal(String name) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.skippedEntityInternal.

Annotations
@Override
startDocumentInternalback to summary
protected void startDocumentInternal() throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.startDocumentInternal.

Annotations
@Override
startElementInternalback to summary
protected void startElementInternal(QName name, Attributes attributes, Map<String, String> namespaceMapping) throws XMLStreamException

Implements abstract org.springframework.util.xml.AbstractStaxHandler.startElementInternal.

Annotations
@Override
startEntityback to summary
public void startEntity(String name) throws SAXException

Overrides org.springframework.util.xml.AbstractStaxHandler.startEntity.

Implements org.xml.sax.ext.LexicalHandler.startEntity.

Doc from org.xml.sax.ext.LexicalHandler.startEntity.

Report the beginning of some internal and external XML entities.

The reporting of parameter entities (including the external DTD subset) is optional, and SAX2 drivers that report LexicalHandler events may not implement it; you can use the http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control the reporting of parameter entities.

General entities are reported with their regular names, parameter entities have '%' prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]".

When a SAX2 driver is providing these events, all other events must be properly nested within start/end entity events. There is no additional requirement that events from DeclHandler or DTDHandler be properly ordered.

Note that skipped entities will be reported through the skippedEntity event, which is part of the ContentHandler interface.

Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under any circumstances:

  • general entities within attribute values
  • parameter entities within declarations

These will be silently expanded, with no indication of where the original entity boundaries were.

Note also that the boundaries of character references (which are not really entities anyway) are not reported.

All start/endEntity events must be properly nested.

Parameters
name:String

The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]".

Annotations
@Override
Exceptions
SAXException:
The application may raise an exception.