org.openhealthexchange.openpixpdq.ihe.audit.jaxb.impl.runtime
Class SAXUnmarshallerHandlerImpl

java.lang.Object
  extended by org.openhealthexchange.openpixpdq.ihe.audit.jaxb.impl.runtime.SAXUnmarshallerHandlerImpl
All Implemented Interfaces:
javax.xml.bind.UnmarshallerHandler, javax.xml.namespace.NamespaceContext, SAXUnmarshallerHandler, UnmarshallingContext, org.xml.sax.ContentHandler

public class SAXUnmarshallerHandlerImpl
extends java.lang.Object
implements SAXUnmarshallerHandler, UnmarshallingContext

Implementation of UnmarshallerHandler. This object converts SAX events into unmarshaller events and cooridnates the entire unmarshalling process.

Author:
Kohsuke KAWAGUCHI

Constructor Summary
SAXUnmarshallerHandlerImpl(UnmarshallerImpl _parent, GrammarInfo _gi)
           
 
Method Summary
 void addPatcher(java.lang.Runnable job)
          Adds a job that will be executed at the last of the unmarshalling.
 java.lang.String addToIdTable(java.lang.String id)
          Adds the object which is currently being unmarshalled to the ID table.
 void characters(char[] buf, int start, int len)
           
 void consumeAttribute(int idx)
          Fires an attribute event for the specified attribute, and marks the attribute as "used".
protected  void consumeText(java.lang.String str, boolean ignorable)
           
 java.lang.String eatAttribute(int idx)
          Marks the attribute as "used" and return the value of the attribute.
 void endDocument()
           
 void endElement(java.lang.String uri, java.lang.String local, java.lang.String qname)
           
 void endPrefixMapping(java.lang.String prefix)
           
 java.lang.String[] getAllDeclaredPrefixes()
          Returns a list of all in-scope prefixes.
 int getAttribute(java.lang.String uri, java.lang.String local)
          Gets the index of the attribute with the specified name.
 java.lang.String getBaseUri()
           
 UnmarshallingEventHandler getCurrentHandler()
          Gets the current handler.
 GrammarInfo getGrammarInfo()
          Obtains a reference to the current grammar info.
 org.xml.sax.Locator getLocator()
          Gets the current source location information.
 java.lang.String getNamespaceURI(java.lang.String prefix)
           
 java.lang.String[] getNewlyDeclaredPrefixes()
          Returns a list of prefixes newly declared on this element.
 java.lang.Object getObjectFromId(java.lang.String id)
          Looks up the ID table and gets associated object.
 java.lang.String getPrefix(java.lang.String uri)
           
 java.util.Iterator getPrefixes(java.lang.String uri)
           
 java.lang.Object getResult()
           
 com.sun.xml.bind.unmarshaller.Tracer getTracer()
          Gets a tracer object.
 org.xml.sax.Attributes getUnconsumedAttributes()
          Gets all the unconsumed attributes.
 void handleEvent(javax.xml.bind.ValidationEvent event, boolean canRecover)
          Reports an error to the user, and asks if s/he wants to recover.
 void ignorableWhitespace(char[] buf, int start, int len)
           
 boolean isNotation(java.lang.String s)
           
 boolean isUnparsedEntity(java.lang.String s)
           
 void popAttributes()
          Discards the previously stored attribute set.
 void popContentHandler()
          Pops a content handler from the stack and registers it as the current content handler.
 void processingInstruction(java.lang.String target, java.lang.String data)
           
 void pushAttributes(org.xml.sax.Attributes atts, boolean collectTextFlag)
          Stores a new attribute set.
 void pushContentHandler(UnmarshallingEventHandler handler, int memento)
          Pushes the current content handler into the stack and registers the newly specified content handler so that it can receive SAX events.
 java.lang.String resolveNamespacePrefix(java.lang.String prefix)
           
 void setDocumentLocator(org.xml.sax.Locator loc)
           
 void setTracer(com.sun.xml.bind.unmarshaller.Tracer t)
           
 void skippedEntity(java.lang.String name)
           
 void startDocument()
           
 void startElement(java.lang.String uri, java.lang.String local, java.lang.String qname, org.xml.sax.Attributes atts)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXUnmarshallerHandlerImpl

public SAXUnmarshallerHandlerImpl(UnmarshallerImpl _parent,
                                  GrammarInfo _gi)
Method Detail

getGrammarInfo

public GrammarInfo getGrammarInfo()
Description copied from interface: UnmarshallingContext
Obtains a reference to the current grammar info.

Specified by:
getGrammarInfo in interface UnmarshallingContext

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String uri,
                         java.lang.String local,
                         java.lang.String qname,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endElement

public final void endElement(java.lang.String uri,
                             java.lang.String local,
                             java.lang.String qname)
                      throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

getResult

public java.lang.Object getResult()
                           throws javax.xml.bind.UnmarshalException
Specified by:
getResult in interface javax.xml.bind.UnmarshallerHandler
Throws:
javax.xml.bind.UnmarshalException

pushContentHandler

public void pushContentHandler(UnmarshallingEventHandler handler,
                               int memento)
Description copied from interface: UnmarshallingContext
Pushes the current content handler into the stack and registers the newly specified content handler so that it can receive SAX events.

Specified by:
pushContentHandler in interface UnmarshallingContext
memento - When this newly specified handler will be removed from the stack, the leaveChild event will be fired to the parent handler with this memento.

popContentHandler

public void popContentHandler()
                       throws org.xml.sax.SAXException
Description copied from interface: UnmarshallingContext
Pops a content handler from the stack and registers it as the current content handler.

This method will also fire the leaveChild event with the associated memento.

Specified by:
popContentHandler in interface UnmarshallingContext
Throws:
org.xml.sax.SAXException

getCurrentHandler

public UnmarshallingEventHandler getCurrentHandler()
Description copied from interface: UnmarshallingContext
Gets the current handler.

Specified by:
getCurrentHandler in interface UnmarshallingContext

consumeText

protected void consumeText(java.lang.String str,
                           boolean ignorable)
                    throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

characters

public final void characters(char[] buf,
                             int start,
                             int len)
Specified by:
characters in interface org.xml.sax.ContentHandler

ignorableWhitespace

public final void ignorableWhitespace(char[] buf,
                                      int start,
                                      int len)
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler

resolveNamespacePrefix

public java.lang.String resolveNamespacePrefix(java.lang.String prefix)
Specified by:
resolveNamespacePrefix in interface UnmarshallingContext

getNewlyDeclaredPrefixes

public java.lang.String[] getNewlyDeclaredPrefixes()
Description copied from interface: UnmarshallingContext
Returns a list of prefixes newly declared on this element. This method has to be called after the UnmarshallingContext.pushAttributes(org.xml.sax.Attributes, boolean) method is called.

Specified by:
getNewlyDeclaredPrefixes in interface UnmarshallingContext
Returns:
A possible zero-length array of prefixes. The default prefix is represented by the empty string.

getAllDeclaredPrefixes

public java.lang.String[] getAllDeclaredPrefixes()
Description copied from interface: UnmarshallingContext
Returns a list of all in-scope prefixes.

Specified by:
getAllDeclaredPrefixes in interface UnmarshallingContext
Returns:
A possible zero-length array of prefixes. The default prefix is represented by the empty string.

getPrefixes

public java.util.Iterator getPrefixes(java.lang.String uri)
Specified by:
getPrefixes in interface javax.xml.namespace.NamespaceContext

getPrefix

public java.lang.String getPrefix(java.lang.String uri)
Specified by:
getPrefix in interface javax.xml.namespace.NamespaceContext

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Specified by:
getNamespaceURI in interface javax.xml.namespace.NamespaceContext

pushAttributes

public void pushAttributes(org.xml.sax.Attributes atts,
                           boolean collectTextFlag)
Description copied from interface: UnmarshallingContext
Stores a new attribute set. This method should be called by the generated code when it "eats" an enterElement event.

Specified by:
pushAttributes in interface UnmarshallingContext
collectTextFlag - false if the context doesn't need to fire text events for texts inside this element. True otherwise.

popAttributes

public void popAttributes()
Description copied from interface: UnmarshallingContext
Discards the previously stored attribute set. This method should be called by the generated code when it "eats" a leaveElement event.

Specified by:
popAttributes in interface UnmarshallingContext

getUnconsumedAttributes

public org.xml.sax.Attributes getUnconsumedAttributes()
Description copied from interface: UnmarshallingContext
Gets all the unconsumed attributes. If you need to find attributes based on more complex filter, you need to use this method.

Specified by:
getUnconsumedAttributes in interface UnmarshallingContext

getAttribute

public int getAttribute(java.lang.String uri,
                        java.lang.String local)
Description copied from interface: UnmarshallingContext
Gets the index of the attribute with the specified name. This is usually faster when you only need to test with a simple name.

Specified by:
getAttribute in interface UnmarshallingContext
Parameters:
uri,local - has to be interned.
Returns:
-1 if not found.

consumeAttribute

public void consumeAttribute(int idx)
                      throws org.xml.sax.SAXException
Description copied from interface: UnmarshallingContext
Fires an attribute event for the specified attribute, and marks the attribute as "used".

Specified by:
consumeAttribute in interface UnmarshallingContext
Throws:
org.xml.sax.SAXException

eatAttribute

public java.lang.String eatAttribute(int idx)
                              throws org.xml.sax.SAXException
Description copied from interface: UnmarshallingContext
Marks the attribute as "used" and return the value of the attribute.

Specified by:
eatAttribute in interface UnmarshallingContext
Throws:
org.xml.sax.SAXException

addPatcher

public void addPatcher(java.lang.Runnable job)
Description copied from interface: UnmarshallingContext
Adds a job that will be executed at the last of the unmarshalling. This method is used to support ID/IDREF feature, but it can be used for other purposes as well.

Specified by:
addPatcher in interface UnmarshallingContext
Parameters:
job - The run method of this object is called.

addToIdTable

public java.lang.String addToIdTable(java.lang.String id)
Description copied from interface: UnmarshallingContext
Adds the object which is currently being unmarshalled to the ID table.

Specified by:
addToIdTable in interface UnmarshallingContext
Returns:
Returns the value passed as the parameter. This is a hack, but this makes it easier for ID transducer to do its job.

getObjectFromId

public java.lang.Object getObjectFromId(java.lang.String id)
Description copied from interface: UnmarshallingContext
Looks up the ID table and gets associated object.

Specified by:
getObjectFromId in interface UnmarshallingContext
Returns:
If there is no object associated with the given id, this method returns null.

skippedEntity

public void skippedEntity(java.lang.String name)
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator loc)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

getLocator

public org.xml.sax.Locator getLocator()
Description copied from interface: UnmarshallingContext
Gets the current source location information.

Specified by:
getLocator in interface UnmarshallingContext

handleEvent

public void handleEvent(javax.xml.bind.ValidationEvent event,
                        boolean canRecover)
                 throws org.xml.sax.SAXException
Description copied from interface: SAXUnmarshallerHandler
Reports an error to the user, and asks if s/he wants to recover. If the canRecover flag is false, regardless of the client instruction, an exception will be thrown. Only if the flag is true and the user wants to recover from an error, the method returns normally. The thrown exception will be catched by the unmarshaller.

Specified by:
handleEvent in interface SAXUnmarshallerHandler
Specified by:
handleEvent in interface UnmarshallingContext
Throws:
org.xml.sax.SAXException

getBaseUri

public java.lang.String getBaseUri()
Specified by:
getBaseUri in interface UnmarshallingContext

isUnparsedEntity

public boolean isUnparsedEntity(java.lang.String s)
Specified by:
isUnparsedEntity in interface UnmarshallingContext

isNotation

public boolean isNotation(java.lang.String s)
Specified by:
isNotation in interface UnmarshallingContext

setTracer

public void setTracer(com.sun.xml.bind.unmarshaller.Tracer t)

getTracer

public com.sun.xml.bind.unmarshaller.Tracer getTracer()
Description copied from interface: UnmarshallingContext
Gets a tracer object. Tracer can be used to trace the unmarshalling behavior. Note that to debug the unmarshalling process, you have to configure XJC so that it will emit trace codes in the unmarshaller.

Specified by:
getTracer in interface UnmarshallingContext