Package javax.xml.bind

Examples of javax.xml.bind.UnmarshallerHandler


    }
   
    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 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

    public static final String PERSISTENCE_SCHEMA = "http://java.sun.com/xml/ns/persistence";

    public static <T> T getPersistence(Class<T> clazz, InputStream persistenceDescriptor) throws Exception {
        JAXBContext jc = JAXBContextFactory.newInstance(clazz);
        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 = 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

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.