b87033953be26b0dc7dead8febd499b666a54126Peter Major// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.6-b27-fcs
b87033953be26b0dc7dead8febd499b666a54126Peter Major// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
b87033953be26b0dc7dead8febd499b666a54126Peter Major// Any modifications to this file will be lost upon recompilation of the source schema.
b87033953be26b0dc7dead8febd499b666a54126Peter Major// Generated on: 2012.09.08 at 08:59:44 DU CEST
b87033953be26b0dc7dead8febd499b666a54126Peter Majorpackage com.sun.identity.diagnostic.base.core.jaxbgen.impl.runtime;
b87033953be26b0dc7dead8febd499b666a54126Peter Majorimport javax.xml.bind.helpers.ParseConversionEventImpl;
b87033953be26b0dc7dead8febd499b666a54126Peter Majorimport javax.xml.bind.helpers.ValidationEventImpl;
b87033953be26b0dc7dead8febd499b666a54126Peter Majorimport javax.xml.bind.helpers.ValidationEventLocatorImpl;
b87033953be26b0dc7dead8febd499b666a54126Peter Major * Convenient default implementation of
b87033953be26b0dc7dead8febd499b666a54126Peter Major * {@link UnmarshallingEventHandler}
b87033953be26b0dc7dead8febd499b666a54126Peter Major * to minimize code generation.
b87033953be26b0dc7dead8febd499b666a54126Peter Major * For historical reasons, sometimes this type is used where
b87033953be26b0dc7dead8febd499b666a54126Peter Major * {@link UnmarshallingEventHandler} should be used.
b87033953be26b0dc7dead8febd499b666a54126Peter Major * Once an exception is in the form of UnmarshalException, we consider
b87033953be26b0dc7dead8febd499b666a54126Peter Major * it to be already reported to the client app.
b87033953be26b0dc7dead8febd499b666a54126Peter Majorpublic abstract class AbstractUnmarshallingEventHandlerImpl implements UnmarshallingEventHandler
b87033953be26b0dc7dead8febd499b666a54126Peter Major public AbstractUnmarshallingEventHandlerImpl(UnmarshallingContext _ctxt,
b87033953be26b0dc7dead8febd499b666a54126Peter Major * Text type of states encoded into a string.
b87033953be26b0dc7dead8febd499b666a54126Peter Major * 'L' means a list state.
b87033953be26b0dc7dead8febd499b666a54126Peter Major// methods that will be provided by the generated code.
b87033953be26b0dc7dead8febd499b666a54126Peter Major // internal events
b87033953be26b0dc7dead8febd499b666a54126Peter Major public void enterElement(String uri, String local, String qname, Attributes atts) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major public void leaveElement(String uri, String local, String qname) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major public final void text(String text) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major // in list state, we don't need to care about whitespaces.
b87033953be26b0dc7dead8febd499b666a54126Peter Major // if the text is all whitespace, this won't generate a text event,
b87033953be26b0dc7dead8febd499b666a54126Peter Major // so it would be just fine.
b87033953be26b0dc7dead8febd499b666a54126Peter Major StringTokenizer tokens = new StringTokenizer(text);
b87033953be26b0dc7dead8febd499b666a54126Peter Major // the handler can be switched during the text processing,
b87033953be26b0dc7dead8febd499b666a54126Peter Major // so the current handler has to be obtained inside the loop
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.getCurrentHandler().text(tokens.nextToken());
b87033953be26b0dc7dead8febd499b666a54126Peter Major // otherwise process this token
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected void handleText(String s) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major public void enterAttribute(String uri, String local, String qname) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major public void leaveAttribute(String uri, String local, String qname) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major public void leaveChild(int nextState) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major * Checks if the current state is marked as a list state.
b87033953be26b0dc7dead8febd499b666a54126Peter Major /** Current state of this automaton. */
b87033953be26b0dc7dead8febd499b666a54126Peter Major// utility methods
b87033953be26b0dc7dead8febd499b666a54126Peter Major /** Called when a RuntimeException is thrown during unmarshalling a text. */
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected void handleUnexpectedTextException( String text, RuntimeException e ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major // report this as an error
b87033953be26b0dc7dead8febd499b666a54126Peter Major reportError( Messages.format(Messages.UNEXPECTED_TEXT,text), e, true );
b87033953be26b0dc7dead8febd499b666a54126Peter Major * Last resort when something goes terribly wrong within the unmarshaller.
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected void handleGenericException( Exception e ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major private void reportError( String msg, boolean canRecover ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major private void reportError( String msg, Exception nested, boolean canRecover ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major canRecover? ValidationEvent.ERROR : ValidationEvent.FATAL_ERROR,
b87033953be26b0dc7dead8febd499b666a54126Peter Major new ValidationEventLocatorImpl(context.getLocator()),
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void unexpectedEnterElement( String uri, String local, String qname, Attributes atts ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major // notify the error
b87033953be26b0dc7dead8febd499b666a54126Peter Major reportError( Messages.format(Messages.UNEXPECTED_ENTER_ELEMENT, uri, local ), true );
b87033953be26b0dc7dead8febd499b666a54126Peter Major // then recover by ignoring the whole element.
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.pushContentHandler(new Discarder(context),state);
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.getCurrentHandler().enterElement(uri,local,qname,atts);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void unexpectedLeaveElement( String uri, String local, String qname ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major reportError( Messages.format(Messages.UNEXPECTED_LEAVE_ELEMENT, uri, local ), false );
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void unexpectedEnterAttribute( String uri, String local, String qname ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major reportError( Messages.format(Messages.UNEXPECTED_ENTER_ATTRIBUTE, uri, local ), false );
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void unexpectedLeaveAttribute( String uri, String local, String qname ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major reportError( Messages.format(Messages.UNEXPECTED_LEAVE_ATTRIBUTE, uri, local ), false );
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void unexpectedText( String str ) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major // make str printable
b87033953be26b0dc7dead8febd499b666a54126Peter Major str = str.replace('\r',' ').replace('\n',' ').replace('\t',' ').trim();
b87033953be26b0dc7dead8febd499b666a54126Peter Major reportError( Messages.format(Messages.UNEXPECTED_TEXT, str ), true );
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void unexpectedLeaveChild() throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major // I believe this is really a bug of the compiler,
b87033953be26b0dc7dead8febd499b666a54126Peter Major // since when an object spawns a child object, it must be "prepared"
b87033953be26b0dc7dead8febd499b666a54126Peter Major // to receive this event.
b87033953be26b0dc7dead8febd499b666a54126Peter Major Messages.format( Messages.UNEXPECTED_LEAVE_CHILD ) );
b87033953be26b0dc7dead8febd499b666a54126Peter Major * This method is called by the generated derived class
b87033953be26b0dc7dead8febd499b666a54126Peter Major * when a datatype parse method throws an exception.
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected void handleParseConversionException(Exception e) throws SAXException {
b87033953be26b0dc7dead8febd499b666a54126Peter Major if( e instanceof RuntimeException )
b87033953be26b0dc7dead8febd499b666a54126Peter Major throw (RuntimeException)e; // don't catch the runtime exception. just let it go.
b87033953be26b0dc7dead8febd499b666a54126Peter Major // wrap it into a ParseConversionEvent and report it
b87033953be26b0dc7dead8febd499b666a54126Peter Major ParseConversionEvent pce = new ParseConversionEventImpl(
b87033953be26b0dc7dead8febd499b666a54126Peter Major new ValidationEventLocatorImpl(context.getLocator()), e );
b87033953be26b0dc7dead8febd499b666a54126Peter Major// spawn a new child object
b87033953be26b0dc7dead8febd499b666a54126Peter Major private UnmarshallingEventHandler spawnChild( Class clazz, int memento ) {
b87033953be26b0dc7dead8febd499b666a54126Peter Major child = (UnmarshallableObject)clazz.newInstance();
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler handler = child.createUnmarshaller(context);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final Object spawnChildFromEnterElement(Class clazz, int memento, String uri, String local, String qname, Attributes atts)
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler ueh = spawnChild(clazz,memento);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final Object spawnChildFromEnterAttribute(Class clazz, int memento, String uri, String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler ueh = spawnChild(clazz,memento);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final Object spawnChildFromText(Class clazz, int memento, String value)
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler ueh = spawnChild(clazz,memento);
b87033953be26b0dc7dead8febd499b666a54126Peter Major // these methods can be used if a child object can be nullable
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final Object spawnChildFromLeaveElement(Class clazz, int memento, String uri, String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler ueh = spawnChild(clazz,memento);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final Object spawnChildFromLeaveAttribute(Class clazz, int memento, String uri, String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler ueh = spawnChild(clazz,memento);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final Element spawnWildcard( int memento, String uri, String local, String qname, Attributes atts )
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler ueh = context.getGrammarInfo().createUnmarshaller(uri,local,context);
b87033953be26b0dc7dead8febd499b666a54126Peter Major // if no class is available to unmarshal this element, discard
b87033953be26b0dc7dead8febd499b666a54126Peter Major // the sub-tree by feeding events to discarder.
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.pushContentHandler( new Discarder(context), memento );
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.getCurrentHandler().enterElement(uri,local,qname,atts);
b87033953be26b0dc7dead8febd499b666a54126Peter Major return null; // return null so that the discarder will be ignored
b87033953be26b0dc7dead8febd499b666a54126Peter Major// spawn a new child handler.
b87033953be26b0dc7dead8febd499b666a54126Peter Major// used for super class and RELAXNG interleave handling.
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void spawnHandlerFromEnterElement(
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler unm, int memento, String uri, String local, String qname, Attributes atts )
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void spawnHandlerFromEnterAttribute(
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler unm, int memento, String uri, String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler unm, int memento, String value)
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void spawnHandlerFromLeaveElement(
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler unm, int memento, String uri, String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void spawnHandlerFromLeaveAttribute(
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler unm, int memento, String uri, String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major UnmarshallingEventHandler unm, int memento, String text )
b87033953be26b0dc7dead8febd499b666a54126Peter Major// revert to parent
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void revertToParentFromEnterElement(String uri,String local, String qname,Attributes atts)
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.getCurrentHandler().enterElement(uri,local,qname,atts);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void revertToParentFromLeaveElement(String uri,String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.getCurrentHandler().leaveElement(uri,local,qname);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void revertToParentFromEnterAttribute(String uri,String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.getCurrentHandler().enterAttribute(uri,local,qname);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void revertToParentFromLeaveAttribute(String uri,String local, String qname)
b87033953be26b0dc7dead8febd499b666a54126Peter Major context.getCurrentHandler().leaveAttribute(uri,local,qname);
b87033953be26b0dc7dead8febd499b666a54126Peter Major protected final void revertToParentFromText(String value)