Package javax.xml.bind

Examples of javax.xml.bind.Unmarshaller.unmarshal()


      try
      {
         JAXBContext jaxb = findJAXBContext(type, annotations, mediaType, true);
         Unmarshaller unmarshaller = jaxb.createUnmarshaller();
         unmarshaller = decorateUnmarshaller(type, annotations, mediaType, unmarshaller);
         return (T) unmarshaller.unmarshal(new StreamSource(entityStream));
      }
      catch (JAXBException e)
      {
         Response response = Response.serverError().build();
         throw new WebApplicationException(e, response);
View Full Code Here


   {
      try
      {
         JAXBContext jaxb = findJAXBContext(type, annotations, mediaType, true);
         Unmarshaller unmarshaller = jaxb.createUnmarshaller();
         Object obj = unmarshaller.unmarshal(entityStream);
         if (obj instanceof JAXBElement)
         {
            JAXBElement element = (JAXBElement) obj;
            return element.getValue();
View Full Code Here

                                               XMLStreamReader reader)
   {
      try
      {
         Unmarshaller unmarshaller = jaxb.createUnmarshaller();
         JAXBElement<T> e = unmarshaller.unmarshal(reader, type);
         return e;
      }
      catch (JAXBException e)
      {
         throw new ExceptionAdapter(e);
View Full Code Here

  private Action actionFromXml(String actionXml) throws RepositoryException {
    Object o;
    try {
      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
      o = unmarshaller.unmarshal(new StringReader(actionXml));
    } catch (JAXBException e) {
      throw new RepositoryException("Error deserializing action", e);
    }

    return Casts.checkedCast(o, Action.class);
View Full Code Here

    try {
      JAXBContext jaxbContext = JAXBContext.newInstance( JaxbHibernateConfiguration.class );
      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
      unmarshaller.setSchema( schema() );
      unmarshaller.setEventHandler( handler );
      target = unmarshaller.unmarshal( staxReader );
      return (JaxbHibernateConfiguration) target;
    }
    catch ( JAXBException e ) {
      StringBuilder builder = new StringBuilder();
      builder.append( "Unable to perform unmarshalling at line number " )
View Full Code Here

        byte[] response = (byte[]) template.requestBody( "direct:test-with-session",
                                                         xml.toString() );
        assertNotNull( response );
        System.out.println( "response:\n" + new String( response ) );
        Unmarshaller unmarshaller = getJaxbContext().createUnmarshaller();
        ExecutionResults res = (ExecutionResults) unmarshaller.unmarshal( new ByteArrayInputStream( response ) );
        WrappedList resp = (WrappedList) res.getValue( "list" );
        assertNotNull( resp );

        assertEquals( resp.size(),
                      2 );
View Full Code Here

    }
  }

  public static Object unmarshal(JAXBContext jaxbContext, XMLStreamReader xmlStreamReader) throws JAXBException {
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    return unmarshaller.unmarshal(xmlStreamReader);
  }

  public static void marshal(JAXBContext jaxbContext, Object item, XMLStreamWriter xmlWriter) throws JAXBException {
    Marshaller marshaller = jaxbContext.createMarshaller();
    marshaller.marshal(item, xmlWriter);
View Full Code Here

   @SuppressWarnings("unchecked")
   public static <T> T streamToObject(final Class<T> type, final ServletInputStream inputStream)
   {
      try {
         Unmarshaller unmarshaller = JAXBContext.newInstance(type).createUnmarshaller();
         T result = (T) unmarshaller.unmarshal(inputStream);
         return result;
      }
      catch (Exception e) {
         throw new RuntimeException(e);
      }
View Full Code Here

            if (in == null) {
                return;
            }
            final JAXBContext context = JAXBContext.newInstance(FeatureDescriptors.class);
            final Unmarshaller unmarshaller = context.createUnmarshaller();
            final FeatureDescriptors descriptors = (FeatureDescriptors) unmarshaller
                    .unmarshal(in);

            cache.clear();
            if (descriptors != null && descriptors.getFeatures() != null)
            {
View Full Code Here

                public boolean handleEvent(ValidationEvent event) {
                    log.warn("Unmarshal warning", event.getMessage());
                    return true;
                }
            });
            return (Configuration) unmarshaller.unmarshal(new StringReader(xml));
        }
        catch (Exception e) {
            throw new RuntimeException(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.