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 java.lang.Object implements SAX2EventAndErrorProducer
This provides shared code forSax2EventFromStaxEventProducerandSax2EventFromStaxStreamProducer. It consumes StAX events and produces SAX2 events.- Author:
- Philipp Erlacher
-
-
Constructor Summary
Constructors Constructor Description BaseSax2EventFromStaxProducer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static SAX2EventAndErrorProducercreateSax2EventFromStax(javax.xml.stream.XMLEventReader eventReader)static SAX2EventAndErrorProducercreateSax2EventFromStax(javax.xml.stream.XMLStreamReader streamReader)(package private) abstract voiddoEndPrefixMapping()(package private) abstract voiddoStartPrefixMapping()For every declared namespace in the current event {@link getContentHandler().startPrefixMapping()} gets invoked.(package private) abstract org.xml.sax.AttributesgetAttributes()(package private) abstract char[]getCharacters()org.xml.sax.ContentHandlergetContentHandler()org.xml.sax.ErrorHandlergetErrorHandler()(package private) abstract javax.xml.stream.LocationgetLocation()(package private) java.lang.StringgetNonEmpty(java.lang.String string)If string equals null this returns an empty string, otherwise it returns the stringjava.util.Stack<java.util.List<java.lang.String>>getPrefixes()(package private) abstract javax.xml.namespace.QNamegetQName()(package private) java.lang.StringgetQName(java.lang.String prefix, java.lang.String localPart)protected org.xml.sax.LocatorgetSAXLocator(javax.xml.stream.Location location)Gets aLocatorto a givenLocation.(package private) voidhandleCharacters()Handles a character event.(package private) voidhandleEndDocument()Handles a end document event.(package private) voidhandleEndElement()Handles an end element event.(package private) inthandleEventType(int eventType, int depth)This method takes an eventType and invokes a method to handle that event.(package private) voidhandleSpace()Handles a space event.(package private) voidhandleStartDocument()InvokehandleDocumentLocator()and {@link getContentHandler().startDocument()};(package private) voidhandleStartElement()Handles a start element event.(package private) booleanisIgnorableWhitespace(char[] chars, int start, int length)If a chars without leading and trailing whitespaces would be empty, this method returns true, otherwise false,voidsetContentHandler(org.xml.sax.ContentHandler contentHandler)Sets the SAX2 ContentHandler to send SAX 2 events tovoidsetErrorHandler(org.xml.sax.ErrorHandler errorHandler)Sets the SAX2 ErrorHandler to send SAX 2 errors to-
Methods 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
-
-
-
-
Method Detail
-
createSax2EventFromStax
public static SAX2EventAndErrorProducer createSax2EventFromStax(javax.xml.stream.XMLStreamReader streamReader)
-
createSax2EventFromStax
public static SAX2EventAndErrorProducer createSax2EventFromStax(javax.xml.stream.XMLEventReader eventReader)
-
setContentHandler
public void setContentHandler(org.xml.sax.ContentHandler contentHandler)
Description copied from interface:SAX2EventProducerSets the SAX2 ContentHandler to send SAX 2 events to- Specified by:
setContentHandlerin interfaceSAX2EventProducer
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Description copied from interface:SAX2EventAndErrorProducerSets the SAX2 ErrorHandler to send SAX 2 errors to- Specified by:
setErrorHandlerin interfaceSAX2EventAndErrorProducer
-
getPrefixes
public java.util.Stack<java.util.List<java.lang.String>> getPrefixes()
-
getContentHandler
public org.xml.sax.ContentHandler getContentHandler()
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
-
handleEventType
int handleEventType(int eventType, int depth) throws org.xml.sax.SAXExceptionThis 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:
org.xml.sax.SAXException
-
handleStartDocument
void handleStartDocument() throws org.xml.sax.SAXExceptionInvokehandleDocumentLocator()and {@link getContentHandler().startDocument()};- Throws:
org.xml.sax.SAXException
-
handleEndDocument
void handleEndDocument() throws org.xml.sax.SAXExceptionHandles a end document event.Invoke {@link getContentHandler().endDocument()};
- Throws:
org.xml.sax.SAXException
-
handleStartElement
void handleStartElement() throws org.xml.sax.SAXExceptionHandles a start element event.Invoke
doStartPrefixMapping()and {@link getContentHandler().startElement()};- Throws:
org.xml.sax.SAXException
-
handleEndElement
void handleEndElement() throws org.xml.sax.SAXExceptionHandles an end element event.Invoke {@link getContentHandler().endElement()} and
doEndPrefixMapping();- Throws:
org.xml.sax.SAXException
-
handleSpace
void handleSpace() throws org.xml.sax.SAXExceptionHandles a space event.- Throws:
org.xml.sax.SAXException
-
handleCharacters
void handleCharacters() throws org.xml.sax.SAXExceptionHandles 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:
org.xml.sax.SAXException
-
getQName
java.lang.String getQName(java.lang.String prefix, java.lang.String localPart)- 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
java.lang.String getNonEmpty(java.lang.String string)
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
abstract javax.xml.stream.Location getLocation()
- Returns:
- a Location
-
getCharacters
abstract char[] getCharacters()
- Returns:
- characters of the current event.
-
doStartPrefixMapping
abstract void doStartPrefixMapping() throws org.xml.sax.SAXExceptionFor every declared namespace in the current event {@link getContentHandler().startPrefixMapping()} gets invoked.- Throws:
org.xml.sax.SAXException
-
doEndPrefixMapping
abstract void doEndPrefixMapping() throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
getAttributes
abstract org.xml.sax.Attributes getAttributes()
- Returns:
- attributes of the current event
-
getQName
abstract javax.xml.namespace.QName getQName()
- Returns:
- QName of the current event
-
getSAXLocator
protected org.xml.sax.Locator getSAXLocator(javax.xml.stream.Location location)
Gets aLocatorto a givenLocation.- Parameters:
location- ALocation- Returns:
- A
Locator
-
-