Package javax.xml.bind

Examples of javax.xml.bind.UnmarshallerHandler


   * @throws A ProtocolException if the input source does not comply with
   * the Google Checkout schema
   */
  public final JAXBElement parseToJAXB(InputSource inputSource)
      throws ProtocolException {
    UnmarshallerHandler unmarshallerHandler
      = _xmlUnMarshaller.getUnmarshallerHandler();
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    try {
      XMLReader xmlReader = factory.newSAXParser().getXMLReader();
      xmlReader.setContentHandler(unmarshallerHandler);
      xmlReader.parse(inputSource);
      return (JAXBElement)unmarshallerHandler.getResult();
    } catch (SAXException saxEx) {
      throw new ProtocolException(saxEx);
    } catch (ParserConfigurationException configEx) {
      throw new ProtocolException(configEx);
    } catch (JAXBException jaxbEx) {
View Full Code Here


  public Object unmarshal(Reader pReader) throws JAXBException {
    return unmarshal(new InputSource(pReader));
  }

  public Object unmarshal(InputSource pSource) throws JAXBException {
    UnmarshallerHandler uh = getUnmarshallerHandler();
    try {
      SAXParser sp = spf.newSAXParser();
      XMLReader xr = sp.getXMLReader();
      xr.setContentHandler(uh);
      xr.parse(pSource);
    } catch (SAXException e) {
      if (e.getException() != null) {
        throw new UnmarshalException(e.getException());
      } else {
        throw new UnmarshalException(e);
      }
    } catch (IOException e) {
      throw new UnmarshalException(e);
    } catch (ParserConfigurationException e) {
      throw new UnmarshalException(e);
    }
    return uh.getResult();
  }
View Full Code Here

    }
    return uh.getResult();
  }

  public Object unmarshal(Node pNode) throws JAXBException {
    UnmarshallerHandler uh = getUnmarshallerHandler();
    DOMSerializer ds = new DOMSerializer();
    try {
      ds.serialize(pNode, uh);
    } catch (SAXException e) {
      if (e.getException() != null) {
        throw new UnmarshalException(e.getException());
      } else {
        throw new UnmarshalException(e);
      }
    }
    return uh.getResult();
  }
View Full Code Here

      }
      XMLReader xr = ss.getXMLReader();
      if (xr == null) {
        return unmarshal(is);
      } else {
        UnmarshallerHandler uh = getUnmarshallerHandler();
        xr.setContentHandler(uh);
        try {
          xr.parse(is);
        } catch (IOException e) {
          throw new JAXBException(e);
        } catch (SAXException e) {
          if (e.getException() != null) {
            throw new JAXBException(e.getException());
          } else {
            throw new JAXBException(e);
          }
        }
        return uh.getResult();
      }
    } else if (pSource instanceof StreamSource) {
      StreamSource ss = (StreamSource) pSource;
      InputSource iSource = new InputSource();
      iSource.setPublicId(ss.getPublicId());
View Full Code Here

   * @throws A ProtocolException if the input source does not comply with
   * the Google Checkout schema
   */
  public final Object parseToJAXB(InputSource inputSource)
      throws ProtocolException {
    UnmarshallerHandler unmarshallerHandler
      = _xmlUnMarshaller.getUnmarshallerHandler();
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    try {
      XMLReader xmlReader = factory.newSAXParser().getXMLReader();
      xmlReader.setContentHandler(unmarshallerHandler);
      xmlReader.parse(inputSource);
      return unmarshallerHandler.getResult();
    } catch (SAXException saxEx) {
      throw new ProtocolException(saxEx);
    } catch (ParserConfigurationException configEx) {
      throw new ProtocolException(configEx);
    } catch (JAXBException jaxbEx) {
View Full Code Here

    }
   
    public final Object unmarshal( Node node ) throws JAXBException {
        try {
            DOMScanner scanner = new DOMScanner();
            UnmarshallerHandler handler = new InterningUnmarshallerHandler(
                createUnmarshallerHandler(new DOMLocator(scanner)));
           
            if(node instanceof Element)
                scanner.parse((Element)node,handler);
            else
            if(node instanceof Document)
                scanner.parse(((Document)node).getDocumentElement(),handler);
            else
                // no other type of input is supported
                throw new IllegalArgumentException();
           
            return handler.getResult();
        } catch( SAXException e ) {
            throw createUnmarshalException(e);
        }
    }
View Full Code Here

    }
   
    public final Object unmarshal( Node node ) throws JAXBException {
        try {
            DOMScanner scanner = new DOMScanner();
            UnmarshallerHandler handler = createUnmarshallerHandler(new DOMLocator(scanner));
           
            if(node instanceof Element)
                scanner.parse((Element)node,handler);
            else
            if(node instanceof Document)
                scanner.parse(((Document)node).getDocumentElement(),handler);
            else
                // no other type of input is supported
                throw new IllegalArgumentException();
           
            return handler.getResult();
        } catch( SAXException e ) {
            throw createUnmarshalException(e);
        }
    }
View Full Code Here

            persistenceDescriptor = url.openStream();

            JAXBContext jc = JAXBContext.newInstance(Persistence.class);
            Unmarshaller u = jc.createUnmarshaller();
            UnmarshallerHandler uh = u.getUnmarshallerHandler();

            // create a new XML parser
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(true);
View Full Code Here

    }
   
    public final Object unmarshal( Node node ) throws JAXBException {
        try {
            DOMScanner scanner = new DOMScanner();
            UnmarshallerHandler handler = new InterningUnmarshallerHandler(
                createUnmarshallerHandler(new DOMLocator(scanner)));
           
            if(node instanceof Element)
                scanner.parse((Element)node,handler);
            else
            if(node instanceof Document)
                scanner.parse(((Document)node).getDocumentElement(),handler);
            else
                // no other type of input is supported
                throw new IllegalArgumentException();
           
            return handler.getResult();
        } catch( SAXException e ) {
            throw createUnmarshalException(e);
        }
    }
View Full Code Here

            persistenceDescriptor = url.openStream();

            JAXBContext jc = JAXBContextFactory.newInstance(Persistence.class);
            Unmarshaller u = jc.createUnmarshaller();
            UnmarshallerHandler uh = u.getUnmarshallerHandler();

            // create a new XML parser
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(true);
View Full Code Here

TOP

Related Classes of javax.xml.bind.UnmarshallerHandler

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.