Package javax.xml.bind

Examples of javax.xml.bind.JAXBContext


           + "</privatkunde>";

   @Test
   public void testSeeAlso() throws Exception
   {
      JAXBContext ctx = new JAXBContextWrapper(null, Kunde.class);
      Kunde kunde = (Kunde) ctx.createUnmarshaller().unmarshal(
              new ByteArrayInputStream(kundeXml.getBytes()));
      System.out.println("HERE KUNDE!!!!" + kunde.getNachname());

   }
View Full Code Here


    if (url==null) {
      logger.error("Could not find resource: " + fileName);
    } else {
      InputStream resourceStream =url.openStream();
 
      JAXBContext jc = JAXBContext.newInstance(thePackage);
      Unmarshaller unmarshaller = jc.createUnmarshaller();
      obj = ((JAXBElement)unmarshaller.unmarshal(resourceStream)).getValue();
    }
    return obj;
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public static Object buildFromString(String source, String thePackage) throws JAXBException, IOException {
    Object obj = null;
    JAXBContext jc = JAXBContext.newInstance(thePackage);
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    obj = ((JAXBElement)unmarshaller.unmarshal(new StringReader(source)));
    return obj;
  }
View Full Code Here

    obj = ((JAXBElement)unmarshaller.unmarshal(new StringReader(source)));
    return obj;
  }
   
  public static void outputEntity(Object obj, String thePackage) throws JAXBException {
    JAXBContext jc = JAXBContext.newInstance(thePackage);
    Marshaller marshaller = jc.createMarshaller();
    marshaller.marshal( new JAXBElement<Object>(new javax.xml.namespace.QName("uri","local"), Object.class, obj), System.out);
   
  }
View Full Code Here

 
  @SuppressWarnings("unchecked")
  public static Object unmarshallFromInputStream(InputStream inputStream, String thePackage) throws JAXBException {
    Object obj = null;
    if (inputStream != null) {
      JAXBContext jc = JAXBContexts.get(thePackage);
      Unmarshaller unmarshaller = jc.createUnmarshaller();
      obj = ((JAXBElement)unmarshaller.unmarshal(inputStream)).getValue();
    }
    else
      logger.error("A null input stream was provided");
View Full Code Here

  }

  public static String marshallToString(Object object, String thePackage) throws JAXBException {
    String rawObject = null;

    JAXBContext jc = JAXBContexts.get(thePackage);
    Marshaller marshaller = jc.createMarshaller();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    marshaller.marshal(object, baos);
    rawObject = baos.toString();
   
    return rawObject;
View Full Code Here

    return rawObject;
  }

  public static Element marshallToElement(Object object, String thePackage, Element element) throws JAXBException {
   
    JAXBContext jc = JAXBContexts.get(thePackage);
    Marshaller marshaller = jc.createMarshaller();
    marshaller.marshal(object, element)
    return element;
  }
View Full Code Here

    return element;
  }
 
  @SuppressWarnings("unchecked")
  public static Object unmarshallFromElement(Element element, String thePackage) throws JAXBException {
    JAXBContext jc = JAXBContexts.get(thePackage);
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    Object obj = ((JAXBElement) unmarshaller.unmarshal(element)).getValue();
    return obj;
  }
View Full Code Here

      juddiUsers.getUser().add(new User("anou_mana","password"));
      juddiUsers.getUser().add(new User("bozo","clown"));
      juddiUsers.getUser().add(new User("sviens","password"));
     
      StringWriter writer = new StringWriter();
      JAXBContext context = JAXBContext.newInstance(juddiUsers.getClass());
      Marshaller marshaller = context.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      marshaller.marshal(juddiUsers, writer);
      logger.info("\n" +  writer.toString());
    } catch (Exception e) {
      logger.error(e.getMessage(),e);
View Full Code Here

      juddiUsers.getUser().add(new User("anou_mana",cryptor.encrypt("password")));
      juddiUsers.getUser().add(new User("bozo",cryptor.encrypt("clown")));
      juddiUsers.getUser().add(new User("sviens",cryptor.encrypt("password")));
     
      StringWriter writer = new StringWriter();
      JAXBContext context = JAXBContext.newInstance(juddiUsers.getClass());
      Marshaller marshaller = context.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      marshaller.marshal(juddiUsers, writer);
      logger.info("\n" +  writer.toString());
    } catch (Exception e) {
      logger.error(e.getMessage(),e);
View Full Code Here

TOP

Related Classes of javax.xml.bind.JAXBContext

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.