Package eu.bandm.tools.util.xml
Class SaxLocatorMapper
java.lang.Object
eu.bandm.tools.util.xml.ContentProxy
eu.bandm.tools.util.xml.SaxLocatorMapper
- All Implemented Interfaces:
ContentHandler
Replaces all
setDocumentLocator(Locator)
SAX calls by an intercepting Locator
,
which re-maps location info according to the LocationMap
,
In SAX, normally a parser invokes this method on the consumer to tell it where to get the location info by active inquiry. This consumer intercepts this call and substitutes a new Locator which prepends the mapping of the locations.
-
Field Summary
Modifier and TypeFieldDescription(package private) @Opt Location<XMLDocumentIdentifier>
Cache for the location of the very last SAX event.Set by the intercepted "setDocumentLocator" call.(package private) final LocationMap<XMLDocumentIdentifier,
XMLDocumentIdentifier> The mapping to apply to the SAX location info.protected final Locator
The visible locator which will be inquired by the SAX consumer for the mapped location info.static final int
Evidentstatic final String
Evidentstatic final String
Evident(package private) final boolean
If failed attempt to map returns a "value unknown" data instead of an Exception.Fields inherited from class eu.bandm.tools.util.xml.ContentProxy
out
-
Constructor Summary
ConstructorDescriptionSaxLocatorMapper
(LocationMap<XMLDocumentIdentifier, XMLDocumentIdentifier> map, boolean robust, ContentHandler out) Only constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int end) void
void
endElement
(String uri, String localName, String qName) void
endPrefixMapping
(String prefix) void
ignorableWhitespace
(char[] ch, int start, int end) protected void
Internally called with every SAX event which changes the location info.void
processingInstruction
(String target, String data) void
Intercept the call of the SAX supplier, which declares the target of all location inquiry method invocations, and stores it locally.void
skippedEntity
(String name) void
void
startElement
(String uri, String localName, String qName, Attributes attrs) void
startPrefixMapping
(String prefix, String uri) protected void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
map
The mapping to apply to the SAX location info. -
robust
final boolean robustIf failed attempt to map returns a "value unknown" data instead of an Exception. -
incomingLocs
Set by the intercepted "setDocumentLocator" call. -
cache
Cache for the location of the very last SAX event. -
NO_NUMBER_AVAILABLE
public static final int NO_NUMBER_AVAILABLEEvident- See Also:
-
NO_SYS_ID_AVAILABLE
Evident- See Also:
-
NO_PUB_ID_AVAILABLE
Evident -
newlocs
The visible locator which will be inquired by the SAX consumer for the mapped location info.
-
-
Constructor Details
-
SaxLocatorMapper
public SaxLocatorMapper(LocationMap<XMLDocumentIdentifier, XMLDocumentIdentifier> map, boolean robust, ContentHandler out) Only constructor. Calls tosetDocumentLocator(Locator)
are intercepted and the info inquired from this locator is mapped according tomap
whenever the locator proxy (as passed toContentProxy.out
) is asked for a position.- Parameters:
robust
- whether the failure of a mapping attempt simply returns "no info" instead of throwing an IllegalArgumentException.
-
-
Method Details
-
invalidate
protected void invalidate()Internally called with every SAX event which changes the location info. -
updateCache
protected void updateCache() -
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classContentProxy
- Throws:
SAXException
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classContentProxy
- Throws:
SAXException
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classContentProxy
- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classContentProxy
- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classContentProxy
- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classContentProxy
- Throws:
SAXException
-
setDocumentLocator
Intercept the call of the SAX supplier, which declares the target of all location inquiry method invocations, and stores it locally. It is asked whenever the visible Locator is asked for a re-mapped location.- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classContentProxy
-
skippedEntity
- Specified by:
skippedEntity
in interfaceContentHandler
- Overrides:
skippedEntity
in classContentProxy
- Throws:
SAXException
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classContentProxy
- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classContentProxy
- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classContentProxy
- Throws:
SAXException
-