public void leaveElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    State s = (State) state.target;
    UnmarshallingContext context = state.getContext();

    try {
      s.handler.endElement(ea.uri, ea.local, ea.getQname());
      s.undeclarePrefixes(context.getNewlyDeclaredPrefixes());
    } catch (SAXException e) {
      context.handleError(e);
      throw e;
    }

    if ((--s.depth) == 0) {
      // emulate the end of the document
      try {
        s.undeclarePrefixes(context.getAllDeclaredPrefixes());
        s.handler.endDocument();
      } catch (SAXException e) {
        context.handleError(e);
        throw e;
      }

      // we are done
      state.target = s.getElement();
    }
  }
  @Override
  public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    // install the default value, but don't override the one given by the parent loader
    if (state.getElementDefaultValue() == null) state.setElementDefaultValue(defaultValue);

    state.setLoader(l);
    l.startElement(state, ea);
  }
  public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
    UnmarshallingContext context = state.getContext();
    if (state.target == null) state.target = new State(context);

    State s = (State) state.target;
    try {
      s.declarePrefixes(context, context.getNewlyDeclaredPrefixes());
      s.handler.startElement(ea.uri, ea.local, ea.getQname(), ea.atts);
    } catch (SAXException e) {
      context.handleError(e);
      throw e;
    }
  }
 public void text(UnmarshallingContext.State state, CharSequence text) throws SAXException {
   if (text.length() == 0) return; // there's no point in creating an empty Text node in DOM.
   try {
     State s = (State) state.target;
     s.handler.characters(text.toString().toCharArray(), 0, text.length());
   } catch (SAXException e) {
     state.getContext().handleError(e);
     throw e;
   }
 }
Example #5
0
 /*     */ public void startElement(UnmarshallingContext.State state, TagName ea)
     throws SAXException {
   /*  59 */ JaxBeanInfo beanInfo = parseXsiType(state, ea, this.defaultBeanInfo);
   /*  60 */ if (beanInfo == null) {
     /*  61 */ beanInfo = this.defaultBeanInfo;
     /*     */ }
   /*  63 */ Loader loader = beanInfo.getLoader(null, false);
   /*  64 */ state.setLoader(loader);
   /*  65 */ loader.startElement(state, ea);
   /*     */ }
Example #6
0
 /**
  * Fires the afterUnmarshal event if necessary.
  *
  * @param state state of the parent object
  */
 protected final void fireAfterUnmarshal(
     JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
   // fire the event callback
   if (beanInfo.lookForLifecycleMethods()) {
     UnmarshallingContext context = state.getContext();
     Unmarshaller.Listener listener = context.parent.getListener();
     if (beanInfo.hasAfterUnmarshalMethod()) {
       beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.target);
     }
     if (listener != null) listener.afterUnmarshal(child, state.target);
   }
 }
Example #7
0
 /**
  * Fires the beforeUnmarshal event if necessary.
  *
  * @param state state of the newly create child object.
  */
 protected final void fireBeforeUnmarshal(
     JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
   if (beanInfo.lookForLifecycleMethods()) {
     UnmarshallingContext context = state.getContext();
     Unmarshaller.Listener listener = context.parent.getListener();
     if (beanInfo.hasBeforeUnmarshalMethod()) {
       beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.prev.target);
     }
     if (listener != null) {
       listener.beforeUnmarshal(child, state.prev.target);
     }
   }
 }
Example #8
0
 /*     */ static JaxBeanInfo parseXsiType(
     UnmarshallingContext.State state, TagName ea, @Nullable JaxBeanInfo defaultBeanInfo)
     throws SAXException {
   /*  69 */ UnmarshallingContext context = state.getContext();
   /*  70 */ JaxBeanInfo beanInfo = null;
   /*     */
   /*  73 */ Attributes atts = ea.atts;
   /*  74 */ int idx = atts.getIndex("http://www.w3.org/2001/XMLSchema-instance", "type");
   /*     */
   /*  76 */ if (idx >= 0)
   /*     */ {
     /*  79 */ String value = atts.getValue(idx);
     /*     */
     /*  81 */ QName type = DatatypeConverterImpl._parseQName(value, context);
     /*  82 */ if (type == null) {
       /*  83 */ reportError(Messages.NOT_A_QNAME.format(new Object[] {value}), true);
       /*     */ } else {
       /*  85 */ if ((defaultBeanInfo != null) && (defaultBeanInfo.getTypeNames().contains(type)))
       /*     */ {
         /*  92 */ return defaultBeanInfo;
         /*     */ }
       /*  94 */ beanInfo = context.getJAXBContext().getGlobalType(type);
       /*  95 */ if (beanInfo == null) {
         /*  96 */ String nearest = context.getJAXBContext().getNearestTypeName(type);
         /*  97 */ if (nearest != null)
           /*  98 */ reportError(
               Messages.UNRECOGNIZED_TYPE_NAME_MAYBE.format(new Object[] {type, nearest}), true);
         /*     */ else {
           /* 100 */ reportError(
               Messages.UNRECOGNIZED_TYPE_NAME.format(new Object[] {type}), true);
           /*     */ }
         /*     */
         /*     */ }
       /*     */
       /*     */ }
     /*     */
     /*     */ }
   /*     */
   /* 112 */ return beanInfo;
   /*     */ }
 public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
   state.loader = this;
   State s = (State) state.prev.target;
   s.depth++;
   state.target = s;
 }
Example #10
0
 /**
  * Called when this loaderis an active loaderand we see a new child start tag.
  *
  * <p>The callee is expected to designate another loaderas a loaderthat processes this element,
  * then it should also register a {@link Receiver}. The designated loaderwill become an active
  * loader.
  *
  * <p>The default implementation reports an error saying an element is unexpected.
  */
 public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
   // notify the error, then recover by ignoring the whole element.
   reportUnexpectedChildElement(ea, true);
   state.loader = Discarder.INSTANCE;
   state.receiver = null;
 }
Example #11
0
 /**
  * This method is called by the generated derived class when a datatype parse method throws an
  * exception.
  */
 protected static void handleParseConversionException(
     UnmarshallingContext.State state, Exception e) throws SAXException {
   // wrap it into a ParseConversionEvent and report it
   state.getContext().handleError(e);
 }