org.apache.ws.jaxme.impl

Class JMUnmarshallerHandlerImpl

Implemented Interfaces:
ContentHandler, JMUnmarshallerHandler, UnmarshallerHandler

public class JMUnmarshallerHandlerImpl
extends java.lang.Object
implements JMUnmarshallerHandler

Implementation of a JMUnmarshallerHandler; the UnmarshallerHandler receives SAX events which he silently discards, as long as the first startElement event is seen. Depending on namespace URI and local name, the Unmarshallerhandler creates a new instance of JMHandler and from now on forwards all SAX events to the JMHandler.

Constructor Summary

JMUnmarshallerHandlerImpl(JMUnmarshaller pUnmarshaller)
Creates a new instance, controlled by the given JMUnmarshaller.

Method Summary

void
addElementParser(JMSAXElementParser pParser)
Adds a parser for an nested element to the stack of parsers.
void
addSimpleAtomicState()
Indicates, that the handler is parsing a simple, atomic element.
void
characters(char[] pChars, int pOffset, int pLen)
void
endDocument()
void
endElement(String pNamespaceURI, String pLocalName, String pQName)
void
endPrefixMapping(String pPrefix)
DatatypeConverterInterface
getDatatypeConverter()
Returns an instance of DatatypeConverterInterface.
Locator
getDocumentLocator()
Returns an instance of Locator, if it has been set, or null.
JMUnmarshaller
getJMUnmarshaller()
Returns the JMUnmarshaller, which created this handler.
int
getLevel()
Returns the current level of nested elements.
NamespaceSupport
getNamespaceSupport()
Returns an instance of NamespaceSupport.
Observer
getObserver()
Returns the observer, which will be notified, when the element has been parsed.
Object
getResult()
Returns the unmarshalled object.
void
ignorableWhitespace(char[] pChars, int pStart, int pLen)
void
parseConversionEvent(String pMsg, Exception pException)
Posts a ParseConversionEvent.
void
processingInstruction(String pTarget, String pData)
void
setDocumentLocator(Locator pLocator)
void
setObserver(Observer pObserver)
Sets an observer, which will be notified, when the element has been parsed.
void
skippedEntity(String pName)
void
startDocument()
void
startElement(String pNamespaceURI, String pLocalName, String pQName, Attributes pAttrs)
void
startPrefixMapping(String pPrefix, String pURI)
boolean
testGroupParser(JMSAXGroupParser pParser, String pNamespaceURI, String pLocalName, String pQName, Attributes pAttrs)
Tests, whether the group parser accepts the element.
void
validationEvent(int pSeverity, String pMsg, String pErrorCode, Exception pException)
Posts a ValidationEvent.

Constructor Details

JMUnmarshallerHandlerImpl

public JMUnmarshallerHandlerImpl(JMUnmarshaller pUnmarshaller)
Creates a new instance, controlled by the given JMUnmarshaller.

Method Details

addElementParser

public void addElementParser(JMSAXElementParser pParser)
Adds a parser for an nested element to the stack of parsers.

addSimpleAtomicState

public void addSimpleAtomicState()
Indicates, that the handler is parsing a simple, atomic element.

characters

public void characters(char[] pChars,
                       int pOffset,
                       int pLen)
            throws SAXException

endDocument

public void endDocument()
            throws SAXException

endElement

public void endElement(String pNamespaceURI,
                       String pLocalName,
                       String pQName)
            throws SAXException

endPrefixMapping

public void endPrefixMapping(String pPrefix)
            throws SAXException

getDatatypeConverter

public DatatypeConverterInterface getDatatypeConverter()
Returns an instance of DatatypeConverterInterface.
Specified by:
getDatatypeConverter in interface JMUnmarshallerHandler

getDocumentLocator

public Locator getDocumentLocator()
Returns an instance of Locator, if it has been set, or null.
Specified by:
getDocumentLocator in interface JMUnmarshallerHandler
See Also:
org.xml.sax.ContentHandler.setDocumentLocator(org.xml.sax.Locator)

getJMUnmarshaller

public JMUnmarshaller getJMUnmarshaller()
Returns the JMUnmarshaller, which created this handler.
Specified by:
getJMUnmarshaller in interface JMUnmarshallerHandler

getLevel

public int getLevel()
Returns the current level of nested elements.
Specified by:
getLevel in interface JMUnmarshallerHandler

getNamespaceSupport

public NamespaceSupport getNamespaceSupport()
Returns an instance of NamespaceSupport.
Specified by:
getNamespaceSupport in interface JMUnmarshallerHandler

getObserver

public Observer getObserver()
Returns the observer, which will be notified, when the element has been parsed.
Specified by:
getObserver in interface JMUnmarshallerHandler

getResult

public Object getResult()
            throws JAXBException,
                   IllegalStateException
Returns the unmarshalled object. This method may be invoked after an endDocument() event only. An IllegalStateException is thrown otherwise.
Specified by:
getResult in interface UnmarshallerHandler
Returns:
The unmarshalled object, never null. (An IllegalStateException is thrown, if no data is available.
Throws:
JAXBException - An error occurred. Note, that the UnmarshallerHandler throws a org.xml.sax.SAXException if an error occurs while unmarshalling the object. In such cases the JAXBException is typically nested within the org.xml.sax.SAXException.

ignorableWhitespace

public void ignorableWhitespace(char[] pChars,
                                int pStart,
                                int pLen)
            throws SAXException

parseConversionEvent

public void parseConversionEvent(String pMsg,
                                 Exception pException)
            throws SAXException

processingInstruction

public void processingInstruction(String pTarget,
                                  String pData)
            throws SAXException

setDocumentLocator

public void setDocumentLocator(Locator pLocator)

setObserver

public void setObserver(Observer pObserver)
Sets an observer, which will be notified, when the element has been parsed.
Specified by:
setObserver in interface JMUnmarshallerHandler

skippedEntity

public void skippedEntity(String pName)
            throws SAXException

startDocument

public void startDocument()
            throws SAXException

startElement

public void startElement(String pNamespaceURI,
                         String pLocalName,
                         String pQName,
                         Attributes pAttrs)
            throws SAXException

startPrefixMapping

public void startPrefixMapping(String pPrefix,
                               String pURI)
            throws SAXException

testGroupParser

public boolean testGroupParser(JMSAXGroupParser pParser,
                               String pNamespaceURI,
                               String pLocalName,
                               String pQName,
                               Attributes pAttrs)
            throws SAXException
Tests, whether the group parser accepts the element. If so, adds the group parser to the stack.

validationEvent

public void validationEvent(int pSeverity,
                            String pMsg,
                            String pErrorCode,
                            Exception pException)
            throws SAXException