5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk//
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.6-b27-fcs
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// Any modifications to this file will be lost upon recompilation of the source schema.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// Generated on: 2012.06.11 at 10:34:07 AM PDT
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk//
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkpackage com.sun.identity.saml2.jaxb.assertion.impl.runtime;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport javax.xml.bind.ValidationEvent;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport javax.xml.bind.helpers.ValidationEventImpl;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport javax.xml.bind.helpers.ValidationEventLocatorImpl;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport org.xml.sax.Attributes;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport org.xml.sax.ContentHandler;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenkimport org.xml.sax.SAXException;
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/**
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Redirects events to another SAX ContentHandler.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * <p>
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Note that the SAXException returned by the ContentHandler is
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * unreported. So we have to catch them and report it, then rethrow
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * it if necessary.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk *
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @author
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkpublic class UnmarshallingEventHandlerAdaptor implements UnmarshallingEventHandler {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk protected final UnmarshallingContext context;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** This handler will receive SAX events. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk protected final ContentHandler handler;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public UnmarshallingEventHandlerAdaptor(UnmarshallingContext _ctxt,ContentHandler _handler) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.context = _ctxt;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk this.handler = _handler;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // emulate the start of documents
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk try {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk handler.setDocumentLocator(context.getLocator());
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk handler.startDocument();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk declarePrefixes( context.getAllDeclaredPrefixes() );
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk } catch( SAXException e ) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk error(e);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public Object owner() {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk return null;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // nest level of elements.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk private int depth = 0;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public void enterAttribute(String uri, String local, String qname) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public void enterElement(String uri, String local, String qname, Attributes atts) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk depth++;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk context.pushAttributes(atts,true);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk try {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk declarePrefixes(context.getNewlyDeclaredPrefixes());
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk handler.startElement(uri,local,qname,atts);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk } catch( SAXException e ) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk error(e);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public void leaveAttribute(String uri, String local, String qname) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public void leaveElement(String uri, String local, String qname) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk try {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk handler.endElement(uri,local,qname);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk undeclarePrefixes(context.getNewlyDeclaredPrefixes());
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk } catch( SAXException e ) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk error(e);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk context.popAttributes();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk depth--;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if(depth==0) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // emulate the end of the document
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk try {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk undeclarePrefixes(context.getAllDeclaredPrefixes());
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk handler.endDocument();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk } catch( SAXException e ) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk error(e);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk context.popContentHandler();
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk private void declarePrefixes( String[] prefixes ) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk for( int i=prefixes.length-1; i>=0; i-- )
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk handler.startPrefixMapping(
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk prefixes[i],
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk context.getNamespaceURI(prefixes[i]) );
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk private void undeclarePrefixes( String[] prefixes ) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk for( int i=prefixes.length-1; i>=0; i-- )
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk handler.endPrefixMapping( prefixes[i] );
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public void text(String s) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk try {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk handler.characters(s.toCharArray(),0,s.length());
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk } catch( SAXException e ) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk error(e);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk private void error( SAXException e ) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk context.handleEvent(new ValidationEventImpl(
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk ValidationEvent.ERROR,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk e.getMessage(),
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk new ValidationEventLocatorImpl(context.getLocator()),
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk e
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk ), false);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk public void leaveChild(int nextState) throws SAXException {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk }
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk}