Package javax.xml.bind

Examples of javax.xml.bind.JAXBContext.createUnmarshaller()


        throws IOException {
       
        try {
            Class<?> theType = getActualType(type, genericType);
            JAXBContext context = getJAXBContext(theType, genericType);
            Unmarshaller unmarshaller = context.createUnmarshaller();
           
            MappedXMLInputFactory factory = new MappedXMLInputFactory(namespaceMap);
            XMLStreamReader xsw = factory.createXMLStreamReader(is);
            Object response = null;
            if (JAXBElement.class.isAssignableFrom(type)) {
View Full Code Here


                jaxbbean.addConstructorArg(context);
                jaxbbean.addConstructorArg(writer.toString());
                jaxbbean.addConstructorArg(c);
                bean.addPropertyValue(propertyName, jaxbbean.getBeanDefinition());
            } catch (Exception ex) {
                Unmarshaller u = context.createUnmarshaller();
                Object obj;
                if (c != null) {
                    obj = u.unmarshal(data, c);
                } else {
                    obj = u.unmarshal(data);
View Full Code Here

    }
   
    protected Unmarshaller createUnmarshaller(Class<?> cls, Type genericType)
        throws JAXBException {
        JAXBContext context = getJAXBContext(cls, genericType);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        if (schema != null) {
            unmarshaller.setSchema(schema);
        }
        return unmarshaller;       
    }
View Full Code Here

            // All the classes we need should be part of this package
            JAXBContext jc = JAXBContext
                    .newInstance("org.apache.axis2.jaxws.description.xml.handler",
                                 EndpointDescriptionImpl.class.getClassLoader());

            Unmarshaller u = jc.createUnmarshaller();

            JAXBElement<?> o = (JAXBElement<?>)u.unmarshal(is);
            return (HandlerChainsType)o.getValue();

        } catch (Exception e) {
View Full Code Here

        orgEnvelope.serialize(out);
        assertFalse(element.isExpanded());
       
        SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(
                new ByteArrayInputStream(out.toByteArray()), null).getSOAPEnvelope();
        DocumentBean object = (DocumentBean)context.createUnmarshaller().unmarshal(
                envelope.getBody().getFirstElement().getXMLStreamReader(false));
        assertEquals("some content", IOUtils.toString(object.getContent().getInputStream(), "utf-8"));
    }
   
    /**
 
View Full Code Here

        JAXBOMDataSource ds = new JAXBOMDataSource(context, orgBean);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(out);
        ds.serialize(writer);
        writer.close();
        MyBean bean = (MyBean)context.createUnmarshaller().unmarshal(
                new ByteArrayInputStream(out.toByteArray()));
        assertEquals(orgBean.getA(), bean.getA());
        assertEquals(orgBean.getB(), bean.getB());
    }
   
View Full Code Here

    InputStream is = PHBulkDensityDaoTest.class.getResourceAsStream("/fixtures/soil/ph/test-nerc-topsoil-ph-1.xml");

    // Build JAXB the long way to get better error messages
    JAXBContext context = JAXBContext.newInstance(FeatureInfoResponse.class);

    FeatureInfoResponse fir = (FeatureInfoResponse) context.createUnmarshaller().unmarshal(is);

    assertThat(fir.getFields().size()).isEqualTo(1);

    PHBulkDensityFields fields = fir.getFields().get(0);
View Full Code Here

    JAXBContext context = JAXBContext.newInstance("org.springframework.data.domain.jaxb");

    marshaller = context.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

    unmarshaller = context.createUnmarshaller();
  }

  @Test
  public void usesCustomTypeAdapterForPageRequests() throws Exception {
View Full Code Here

    ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
    try {
      staxEventReader = new JpaNamespaceTransformingEventReader( staxEventReader );
      JAXBContext jaxbContext = JAXBContext.newInstance( ObjectFactory.class );
      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
      unmarshaller.setSchema( schema );
      unmarshaller.setEventHandler( handler );
      return clazz.cast( unmarshaller.unmarshal( staxEventReader ) );
    }
    catch ( JAXBException e ) {
View Full Code Here

            ClassLoader ccl = Thread.currentThread().getContextClassLoader();
            URL resource = ccl.getResource("org/richfaces/demo/tree/CDCatalog.xml");
            JAXBContext context;
            try {
                context = JAXBContext.newInstance(CDsHolder.class);
                CDsHolder cdsHolder = (CDsHolder) context.createUnmarshaller().unmarshal(resource);
                cdsList = cdsHolder.getCds();
            } catch (JAXBException e) {
                throw new FacesException(e.getMessage(), e);
            }
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.