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();
    }
  }
 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;
   }
 }
Beispiel #3
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);
   }
 }
  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;
    }
  }
Beispiel #5
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);
     }
   }
 }
Beispiel #6
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;
   /*     */ }
Beispiel #7
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);
 }