Package javax.xml.bind

Examples of javax.xml.bind.UnmarshalException


      for (int i = 0; i < in.getAttributeCount(); i++) {
        QName attributeName = in.getAttributeName(i);
        XmlMapping mapping = attributed.getAttributeMapping(attributeName);

        if (mapping == null)
          throw new UnmarshalException(L.l("Attribute {0} not found in {1}",
                                           attributeName,
                                           attributed.getType()));

        mapping.readAttribute(in, i, parent);
      }
View Full Code Here


  {
    if ("".equals(in)) {
      if (_isNullable)
        return null;
      else
        throw new UnmarshalException("Primitives may not be null");
    }

    return Long.valueOf(DatatypeConverter.parseLong(in));
  }
View Full Code Here

  {
    try {
      return new URI(in);
    }
    catch (URISyntaxException e) {
      throw new UnmarshalException(e);
    }
  }
View Full Code Here

        for (int i = 0; i < in.getAttributeCount(); i++) {
          QName attributeName = in.getAttributeName(i);
          XmlMapping mapping = getAttributeMapping(attributeName);

          if (mapping == null)
            throw new UnmarshalException(L.l("Attribute {0} not found in {1}",
                                             attributeName, getType()));

          mapping.readAttribute(in, i, ret);
        }

        int i = 0;
        in.nextTag();

        while (in.getEventType() == in.START_ELEMENT) {
          XmlMapping mapping = getElementMapping(in.getName());

          if (mapping == null) {
            throw new UnmarshalException(L.l("Child <{0}> not found in {1}",
                                             in.getName(), getType()));
          }

          if (! mapping.getAccessor().checkOrder(i++, u.getEventHandler())) {
            throw new UnmarshalException(L.l("Child <{0}> misordered in {1}",
                                             in.getName(), getType()));
          }

          mapping.read(u, in, ret);
        }

        // essentially a nextTag() that handles end of document gracefully
        while (in.hasNext()) {
          in.next();

          if (in.getEventType() == in.START_ELEMENT ||
              in.getEventType() == in.END_ELEMENT)
            break;
        }
      }

      if (_afterUnmarshal != null)
        _afterUnmarshal.invoke(ret, u, null);

      if (u.getListener() != null)
        u.getListener().afterUnmarshal(ret, null);

      return ret;
    }
    catch (InvocationTargetException e) {
      if (e.getTargetException() != null)
        throw new UnmarshalException(e.getTargetException());

      throw new UnmarshalException(e);
    }
    catch (IllegalAccessException e) {
      throw new UnmarshalException(e);
    }
  }
View Full Code Here

          QName name = JAXBUtil.qnameFromNode(child);

          XmlMapping mapping = getElementMapping(name);

          if (mapping == null)
            throw new UnmarshalException(L.l("Child <{0}> not found", name));

          if (! mapping.getAccessor().checkOrder(i++, binder.getEventHandler()))
            throw new UnmarshalException(L.l("Child <{0}> misordered", name));

          mapping.bindFrom(binder, node, ret);
        }

        child = node.nextSibling();
View Full Code Here

    QName name = JAXBUtil.qnameFromNode(root);

    ClassSkeleton skeleton = _context.getRootElement(name);

    if (skeleton == null)
      throw new UnmarshalException(L.l("Root element {0} is unknown to this context",
                                       name));

    try {
      return skeleton.bindFrom(this, null, new NodeIterator(root));
    }
View Full Code Here

    }

    ClassSkeleton skeleton = _context.findSkeletonForClass(declaredType);

    if (skeleton == null)
      throw new UnmarshalException(L.l("Type {0} is unknown to this context",
                                       declaredType));

    try {
      T value = (T) skeleton.bindFrom(this, null, new NodeIterator(root));
View Full Code Here

      jaxbObject = new JAXBElement(qname, jaxbObject.getClass(), jaxbObject);

      skeleton = _context.findSkeletonForObject(jaxbObject);

      if (skeleton == null)
        throw new UnmarshalException(L.l("Type {0} is unknown to this context",
                                         jaxbObject.getClass()));
    }

    try {
      return skeleton.bindFrom(this, jaxbObject, new NodeIterator(root));
View Full Code Here

            throw new IllegalStateException();
       
        if(!aborted)       return result;
       
        // there was an error.
        throw new UnmarshalException((String)null);
    }
View Full Code Here

        // if the handler says "abort", we will not return the object
        // from the unmarshaller.getResult()
        if(!recover)    aborted = true;
       
        if( !canRecover || !recover )
            throw new SAXException( new UnmarshalException(
                event.getMessage(),
                event.getLinkedException() ) );
    }
View Full Code Here

TOP

Related Classes of javax.xml.bind.UnmarshalException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.