Package javax.xml.bind

Examples of javax.xml.bind.Unmarshaller


         throw new RuntimeException(e);
      }
      JAXBElement<?> result;
      try
      {
         Unmarshaller unmarshaller = jaxb.createUnmarshaller();
         JAXBElement<?> e = unmarshaller.unmarshal(new StreamSource(entityStream), (Class<?>) typeArg);
         result = e;
      }
      catch (JAXBException e)
      {
         throw new ExceptionAdapter(e);
View Full Code Here


                     InputStream entityStream) throws IOException
   {
      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

   public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException
   {
      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

                                               InputStream entityStream,
                                               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

  private JaxbHibernateConfiguration unmarshal(XMLStreamReader staxReader, final Origin origin) {
    final Object target;
    final ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
    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

      return "Error transforming to xml: " + e.toString();
    }
  }

  public static Object unmarshal(JAXBContext jaxbContext, XMLStreamReader xmlStreamReader) throws JAXBException {
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    return unmarshaller.unmarshal(xmlStreamReader);
  }
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

            final InputStream in = getConfigurationStream(getConfig());
            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

TOP

Related Classes of javax.xml.bind.Unmarshaller

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.