Examples of Marshaller


Examples of javax.xml.bind.Marshaller

   public String getBooksBadgerText() throws Exception
   {
      BookListing listing = getListing();
      BadgerContext context = new BadgerContext(BookListing.class);
      StringWriter writer = new StringWriter();
      Marshaller marshaller = context.createMarshaller();
      marshaller.marshal(listing, writer);
      return writer.toString();
   }
View Full Code Here

Examples of javax.xml.bind.Marshaller

   public String getBooksMappedText() throws Exception
   {
      BookListing listing = getListing();
      JettisonMappedContext context = new JettisonMappedContext(BookListing.class);
      StringWriter writer = new StringWriter();
      Marshaller marshaller = context.createMarshaller();
      marshaller.marshal(listing, writer);
      return writer.toString();
   }
View Full Code Here

Examples of javax.xml.bind.Marshaller

      mediaTypeParameters.put("type", "text/xml");

      MediaType xopRootMediaType = new MediaType("application",
          "xop+xml", mediaTypeParameters);

      Marshaller marshaller = getMarshaller(type, annotations,
          xopRootMediaType);
      marshaller.setAttachmentMarshaller(new XopAttachmentMarshaller(
          xopPackage));
      ByteArrayOutputStream xml = new ByteArrayOutputStream();
      marshaller.marshal(t, xml);

      OutputPart outputPart = xopPackage.addPart(xml.toByteArray(),
          xopRootMediaType, ContentIDUtils.generateContentID(), null);
      List<OutputPart> outputParts = xopPackage.getParts();
      outputParts.remove(outputPart);
View Full Code Here

Examples of javax.xml.bind.Marshaller

      item.setProductName("My Thing");
      item.setQuantity(6);
      item.setUSPrice(new BigDecimal(13.99));
      items.getItem().add(item);
      po.setItems(items);
      Marshaller marshaller = ctx.createMarshaller();
      XmlSchema xmlSchema = PurchaseOrderType.class.getPackage().getAnnotation(XmlSchema.class);
      XmlNamespacePrefixMapper mapper = new XmlNamespacePrefixMapper(xmlSchema.xmlns());
      try
      {
         marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
      }
      catch (PropertyException e)
      {
         logger.warn(e.getMessage(), e);
      }
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
      ObjectFactory factory = new ObjectFactory();
      marshaller.marshal(factory.createPurchaseOrder(po), System.out);
   }
View Full Code Here

Examples of javax.xml.bind.Marshaller

    * @throws JAXBException
    * @see javax.xml.bind.JAXBContext#createMarshaller()
    */
   public Marshaller createMarshaller() throws JAXBException
   {
      Marshaller marshaller = wrappedContext.createMarshaller();
      if (mapper != null)
      {
         try
         {
            marshaller.setProperty(NAMESPACE_PREFIX_MAPPER, mapper);
         }
         catch (PropertyException e)
         {
            logger.warn(e.getMessage());
         }
View Full Code Here

Examples of javax.xml.bind.Marshaller

                       MultivaluedMap<String, Object> httpHeaders,
                       OutputStream outputStream) throws IOException
   {
      try
      {
         Marshaller marshaller = getMarshaller(type, annotations, mediaType);
         marshaller = decorateMarshaller(type, annotations, mediaType, marshaller);
         marshaller.marshal(t, outputStream);
      }
      catch (JAXBException e)
      {
         throw new JAXBMarshalException(e);
      }
View Full Code Here

Examples of javax.xml.bind.Marshaller

                                      MediaType mediaType)
   {
      try
      {
         JAXBContext jaxb = findJAXBContext(type, annotations, mediaType, false);
         Marshaller marshaller = jaxb.createMarshaller();
         setCharset(mediaType, marshaller);
         // Pretty Print the XML response.
         Object formatted = mediaType.getParameters().get("formatted");
         if (formatted != null)
         {
            Boolean value = TypeConverter.getBooleanValue(formatted.toString());
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, value);
         }
         return marshaller;
      }
      catch (JAXBException e)
      {
View Full Code Here

Examples of javax.xml.bind.Marshaller

    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

Examples of javax.xml.bind.Marshaller

  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

Examples of javax.xml.bind.Marshaller

  }

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