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

pack-priv abstract Class AbstractStaxXMLReader

extends AbstractXMLReader
Class Inheritance
Known Direct Subclasses
org.springframework.util.xml.StaxEventXMLReader, org.springframework.util.xml.StaxStreamXMLReader
Imports
java.util.LinkedHashMap, .Map, javax.xml.namespace.QName, javax.xml.stream.Location, .XMLStreamException, org.xml.sax.InputSource, .Locator, .SAXException, .SAXNotRecognizedException, .SAXNotSupportedException, .SAXParseException, org.springframework.lang.Nullable, org.springframework.util.StringUtils

Abstract base class for SAX XMLReader implementations that use StAX as a basis.
Authors
Arjen Poutsma, Juergen Hoeller
Since
3.0
See Also
setContentHandler(org.xml.sax.ContentHandler), setDTDHandler(org.xml.sax.DTDHandler), setEntityResolver(org.xml.sax.EntityResolver), setErrorHandler(org.xml.sax.ErrorHandler)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AbstractStaxXMLReader.StaxLocator

Implementation of the Locator interface based on a given StAX Location.

Field Summary

Modifier and TypeField and Description
private static final String
private Boolean
private static final String
private boolean
private final Map<String, String>
private static final String
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
endPrefixMapping(String prefix)

End the prefix mapping for the given prefix.

public boolean
getFeature(String
The feature name, which is a fully-qualified URI.
name
)

Overrides org.springframework.util.xml.AbstractXMLReader.getFeature.

Implements org.xml.sax.XMLReader.getFeature.

This implementation throws a SAXNotRecognizedException exception for any feature outside the "http://xml.org/sax/features/" namespace and returns false for any feature within.
protected boolean
hasNamespacePrefixesFeature()

Indicates whether the SAX feature http://xml.org/sax/features/namespaces-prefixes is turned on.

protected boolean
hasNamespacesFeature()

Indicates whether the SAX feature http://xml.org/sax/features/namespaces is turned on.

public final void
parse(InputSource
is ignored
ignored
)

Implements org.xml.sax.XMLReader.parse.

Parse the StAX XML reader passed at construction-time.
public final void
parse(String
is ignored
ignored
)

Implements org.xml.sax.XMLReader.parse.

Parse the StAX XML reader passed at construction-time.
private void
protected abstract void
parseInternal()

Template method that parses the StAX reader passed at construction-time.

public void
setFeature(String
The feature name, which is a fully-qualified URI.
name
,
boolean
The requested value of the feature (true or false).
value
)

Overrides org.springframework.util.xml.AbstractXMLReader.setFeature.

Implements org.xml.sax.XMLReader.setFeature.

This implementation throws a SAXNotRecognizedException exception for any feature outside the "http://xml.org/sax/features/" namespace and accepts a false value for any feature within.
protected void
setStandalone(boolean standalone)

protected void
startPrefixMapping(String prefix, String namespace)

Start the prefix mapping for the given prefix.

protected String

Returns:

the qualified name
toQualifiedName
(QName
the QName
qName
)

Convert a QName to a qualified name, as used by DOM and SAX.

Inherited from org.springframework.util.xml.AbstractXMLReader:
getContentHandlergetDTDHandlergetEntityResolvergetErrorHandlergetLexicalHandlergetPropertysetContentHandlersetDTDHandlersetEntityResolversetErrorHandlersetProperty

Field Detail

IS_STANDALONE_FEATURE_NAMEback to summary
private static final String IS_STANDALONE_FEATURE_NAME
isStandaloneback to summary
private Boolean isStandalone
Annotations
@Nullable
NAMESPACE_PREFIXES_FEATURE_NAMEback to summary
private static final String NAMESPACE_PREFIXES_FEATURE_NAME
namespacePrefixesFeatureback to summary
private boolean namespacePrefixesFeature
namespacesback to summary
private final Map<String, String> namespaces
NAMESPACES_FEATURE_NAMEback to summary
private static final String NAMESPACES_FEATURE_NAME
namespacesFeatureback to summary
private boolean namespacesFeature

Constructor Detail

AbstractStaxXMLReaderback to summary
pack-priv AbstractStaxXMLReader()

Method Detail

endPrefixMappingback to summary
protected void endPrefixMapping(String prefix) throws SAXException

End the prefix mapping for the given prefix.

See Also
org.xml.sax.ContentHandler#endPrefixMapping(String)
getFeatureback to summary
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException

Overrides org.springframework.util.xml.AbstractXMLReader.getFeature.

Implements org.xml.sax.XMLReader.getFeature.

Doc from org.springframework.util.xml.AbstractXMLReader.getFeature.

This implementation throws a SAXNotRecognizedException exception for any feature outside the "http://xml.org/sax/features/" namespace and returns false for any feature within.

Parameters
name:String

Doc from org.xml.sax.XMLReader.getFeature.

The feature name, which is a fully-qualified URI.

Returns:boolean

Doc from org.xml.sax.XMLReader.getFeature.

The current value of the feature (true or false).

Annotations
@Override
Exceptions
SAXNotRecognizedException:

Doc from org.xml.sax.XMLReader.getFeature.

If the feature value can't be assigned or retrieved.

SAXNotSupportedException:

Doc from org.xml.sax.XMLReader.getFeature.

When the XMLReader recognizes the feature name but cannot determine its value at this time.

hasNamespacePrefixesFeatureback to summary
protected boolean hasNamespacePrefixesFeature()

Indicates whether the SAX feature http://xml.org/sax/features/namespaces-prefixes is turned on.

hasNamespacesFeatureback to summary
protected boolean hasNamespacesFeature()

Indicates whether the SAX feature http://xml.org/sax/features/namespaces is turned on.

parseback to summary
public final void parse(InputSource ignored) throws SAXException

Implements org.xml.sax.XMLReader.parse.

Parse the StAX XML reader passed at construction-time.

Note

The given InputSource is not read, but ignored.

Parameters
ignored:InputSource

is ignored

Annotations
@Override
Exceptions
SAXException:
a SAX exception, possibly wrapping a XMLStreamException
parseback to summary
public final void parse(String ignored) throws SAXException

Implements org.xml.sax.XMLReader.parse.

Parse the StAX XML reader passed at construction-time.

Note

The given system identifier is not read, but ignored.

Parameters
ignored:String

is ignored

Annotations
@Override
Exceptions
SAXException:
a SAX exception, possibly wrapping a XMLStreamException
parseback to summary
private void parse() throws SAXException
parseInternalback to summary
protected abstract void parseInternal() throws SAXException, XMLStreamException

Template method that parses the StAX reader passed at construction-time.

setFeatureback to summary
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException

Overrides org.springframework.util.xml.AbstractXMLReader.setFeature.

Implements org.xml.sax.XMLReader.setFeature.

Doc from org.springframework.util.xml.AbstractXMLReader.setFeature.

This implementation throws a SAXNotRecognizedException exception for any feature outside the "http://xml.org/sax/features/" namespace and accepts a false value for any feature within.

Parameters
name:String

Doc from org.xml.sax.XMLReader.setFeature.

The feature name, which is a fully-qualified URI.

value:boolean

Doc from org.xml.sax.XMLReader.setFeature.

The requested value of the feature (true or false).

Annotations
@Override
Exceptions
SAXNotRecognizedException:

Doc from org.xml.sax.XMLReader.setFeature.

If the feature value can't be assigned or retrieved.

SAXNotSupportedException:

Doc from org.xml.sax.XMLReader.setFeature.

When the XMLReader recognizes the feature name but cannot set the requested value.

setStandaloneback to summary
protected void setStandalone(boolean standalone)
startPrefixMappingback to summary
protected void startPrefixMapping(String prefix, String namespace) throws SAXException

Start the prefix mapping for the given prefix.

See Also
org.xml.sax.ContentHandler#startPrefixMapping(String, String)
toQualifiedNameback to summary
protected String toQualifiedName(QName qName)

Convert a QName to a qualified name, as used by DOM and SAX. The returned string has a format of prefix:localName if the prefix is set, or just localName if not.

Parameters
qName:QName

the QName

Returns:String

the qualified name

org.springframework.util.xml back to summary

private Class AbstractStaxXMLReader.StaxLocator

extends Object
implements Locator
Class Inheritance
  • java.lang.Object
  • org.springframework.util.xml.AbstractStaxXMLReader.StaxLocator
All Implemented Interfaces
org.xml.sax.Locator

Implementation of the Locator interface based on a given StAX Location.
See Also
Locator, Location

Field Summary

Modifier and TypeField and Description
private final Location

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
getColumnNumber()

Implements org.xml.sax.Locator.getColumnNumber.

Return the column number where the current document event ends.
public int
getLineNumber()

Implements org.xml.sax.Locator.getLineNumber.

Return the line number where the current document event ends.
public String
getPublicId()

Implements org.xml.sax.Locator.getPublicId.

Return the public identifier for the current document event.
public String
getSystemId()

Implements org.xml.sax.Locator.getSystemId.

Return the system identifier for the current document event.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

locationback to summary
private final Location location

Constructor Detail

StaxLocatorback to summary
public StaxLocator(Location location)

Method Detail

getColumnNumberback to summary
public int getColumnNumber()

Implements org.xml.sax.Locator.getColumnNumber.

Doc from org.xml.sax.Locator.getColumnNumber.

Return the column number where the current document event ends. This is one-based number of Java char values since the last line end.

Warning

The return value from the method is intended only as an approximation for the sake of diagnostics; it is not intended to provide sufficient information to edit the character content of the original XML document. For example, when lines contain combining character sequences, wide characters, surrogate pairs, or bi-directional text, the value may not correspond to the column in a text editor's display.

The return value is an approximation of the column number in the document entity or external parsed entity where the markup triggering the event appears.

If possible, the SAX driver should provide the line position of the first character after the text associated with the document event. The first column in each line is column 1.

Returns:int

The column number, or -1 if none is available.

Annotations
@Override
getLineNumberback to summary
public int getLineNumber()

Implements org.xml.sax.Locator.getLineNumber.

Doc from org.xml.sax.Locator.getLineNumber.

Return the line number where the current document event ends. Lines are delimited by line ends, which are defined in the XML specification.

Warning

The return value from the method is intended only as an approximation for the sake of diagnostics; it is not intended to provide sufficient information to edit the character content of the original XML document. In some cases, these "line" numbers match what would be displayed as columns, and in others they may not match the source text due to internal entity expansion.

The return value is an approximation of the line number in the document entity or external parsed entity where the markup triggering the event appears.

If possible, the SAX driver should provide the line position of the first character after the text associated with the document event. The first line is line 1.

Returns:int

The line number, or -1 if none is available.

Annotations
@Override
getPublicIdback to summary
public String getPublicId()

Implements org.xml.sax.Locator.getPublicId.

Doc from org.xml.sax.Locator.getPublicId.

Return the public identifier for the current document event.

The return value is the public identifier of the document entity or of the external parsed entity in which the markup triggering the event appears.

Returns:String

A string containing the public identifier, or null if none is available.

Annotations
@Override
getSystemIdback to summary
public String getSystemId()

Implements org.xml.sax.Locator.getSystemId.

Doc from org.xml.sax.Locator.getSystemId.

Return the system identifier for the current document event.

The return value is the system identifier of the document entity or of the external parsed entity in which the markup triggering the event appears.

If the system identifier is a URL, the parser must resolve it fully before passing it to the application. For example, a file name must always be provided as a file:... URL, and other kinds of relative URI are also resolved against their bases.

Returns:String

A string containing the system identifier, or null if none is available.

Annotations
@Override