Package org.exolab.castor.xml
Class BaseSax2EventFromStaxProducer
java.lang.Object
org.exolab.castor.xml.BaseSax2EventFromStaxProducer
- All Implemented Interfaces:
SAX2EventAndErrorProducer
,SAX2EventProducer
- Direct Known Subclasses:
Sax2EventFromStaxEventProducer
,Sax2EventFromStaxStreamProducer
public abstract class BaseSax2EventFromStaxProducer
extends Object
implements SAX2EventAndErrorProducer
This provides shared code for
Sax2EventFromStaxEventProducer
and
Sax2EventFromStaxStreamProducer
. It consumes StAX events and
produces SAX2 events.- Author:
- Philipp Erlacher
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SAX2EventAndErrorProducer
createSax2EventFromStax
(XMLEventReader eventReader) static SAX2EventAndErrorProducer
createSax2EventFromStax
(XMLStreamReader streamReader) (package private) abstract void
(package private) abstract void
For every declared namespace in the current event {@link getContentHandler().startPrefixMapping()} gets invoked.(package private) abstract Attributes
(package private) abstract char[]
(package private) abstract Location
(package private) String
getNonEmpty
(String string) If string equals null this returns an empty string, otherwise it returns the string(package private) abstract QName
getQName()
(package private) String
protected Locator
getSAXLocator
(Location location) (package private) void
Handles a character event.(package private) void
Handles a end document event.(package private) void
Handles an end element event.(package private) int
handleEventType
(int eventType, int depth) This method takes an eventType and invokes a method to handle that event.(package private) void
Handles a space event.(package private) void
InvokehandleDocumentLocator()
and {@link getContentHandler().startDocument()};(package private) void
Handles a start element event.(package private) boolean
isIgnorableWhitespace
(char[] chars, int start, int length) If a chars without leading and trailing whitespaces would be empty, this method returns true, otherwise false,void
setContentHandler
(ContentHandler contentHandler) Sets the SAX2 ContentHandler to send SAX 2 events tovoid
setErrorHandler
(ErrorHandler errorHandler) Sets the SAX2 ErrorHandler to send SAX 2 errors toMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.exolab.castor.xml.SAX2EventProducer
start
-
Constructor Details
-
BaseSax2EventFromStaxProducer
public BaseSax2EventFromStaxProducer()
-
-
Method Details
-
createSax2EventFromStax
-
createSax2EventFromStax
-
setContentHandler
Description copied from interface:SAX2EventProducer
Sets the SAX2 ContentHandler to send SAX 2 events to- Specified by:
setContentHandler
in interfaceSAX2EventProducer
-
setErrorHandler
Description copied from interface:SAX2EventAndErrorProducer
Sets the SAX2 ErrorHandler to send SAX 2 errors to- Specified by:
setErrorHandler
in interfaceSAX2EventAndErrorProducer
-
getPrefixes
-
getContentHandler
-
getErrorHandler
-
handleEventType
This method takes an eventType and invokes a method to handle that event.It also takes information about the depth of the read element. Maybe depth changes due to handling that event.
- Parameters:
eventType
- The event typedepth
- The current depth of the element- Returns:
- depth The updated depth
- Throws:
SAXException
-
handleStartDocument
InvokehandleDocumentLocator()
and {@link getContentHandler().startDocument()};- Throws:
SAXException
-
handleEndDocument
Handles a end document event.Invoke {@link getContentHandler().endDocument()};
- Throws:
SAXException
-
handleStartElement
Handles a start element event.Invoke
doStartPrefixMapping()
and {@link getContentHandler().startElement()};- Throws:
SAXException
-
handleEndElement
Handles an end element event.Invoke {@link getContentHandler().endElement()} and
doEndPrefixMapping()
;- Throws:
SAXException
-
handleSpace
Handles a space event.- Throws:
SAXException
-
handleCharacters
Handles a character event.If chars is ignorable whitespace {@link getContentHandler().ignorableWhitespace will be called. Otherwise {@link getContentHandler().characters()} will be called with characters(char[], 0, length)
- Throws:
SAXException
-
getQName
- Parameters:
prefix
-localPart
-- Returns:
- qName. If prefix length >=1 then it's like prefix:localPart, otherwise it's just the localPart
-
isIgnorableWhitespace
boolean isIgnorableWhitespace(char[] chars, int start, int length) If a chars without leading and trailing whitespaces would be empty, this method returns true, otherwise false,- Parameters:
chars
-start
- the offsetlength
-- Returns:
-
getNonEmpty
If string equals null this returns an empty string, otherwise it returns the string- Parameters:
string
- the string to check- Returns:
- a string. If string equals null this returns an empty string, otherwise it returns the string
-
getLocation
- Returns:
- a Location
-
getCharacters
abstract char[] getCharacters()- Returns:
- characters of the current event.
-
doStartPrefixMapping
For every declared namespace in the current event {@link getContentHandler().startPrefixMapping()} gets invoked.- Throws:
SAXException
-
doEndPrefixMapping
- Throws:
SAXException
-
getAttributes
- Returns:
- attributes of the current event
-
getQName
- Returns:
- QName of the current event
-
getSAXLocator
-