Package org.simpleframework.xml.core

Examples of org.simpleframework.xml.core.Persister


     * @return a reconstituted GATKRunReport from reportAsXML
     * @throws Exception if parsing fails for any reason
     */
    @Ensures("result != null")
    protected static GATKRunReport deserializeReport(final InputStream stream) throws Exception {
        final Serializer serializer = new Persister();
        return serializer.read(GATKRunReport.class, stream);
    }
View Full Code Here


     *
     * @param stream an output stream to write the report to
     */
    @Requires("stream != null")
    protected boolean postReportToStream(final OutputStream stream) {
        final Serializer serializer = new Persister();
        try {
            serializer.write(this, stream);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
View Full Code Here

 
  public static Serializer createSerializer() {
    Style style = new HyphenStyle();
    Format format = new Format(style);
    AnnotationStrategy strategy = new AnnotationStrategy();
    Serializer serializer = new Persister(strategy, format);
    return serializer;
  }
View Full Code Here

    {
        FSDirectory unserializedDir = null;
        try
        {
            final File file = indexDir;
            final Persister persister = new Persister();

            final StringWriter writer = new StringWriter();
            persister.write(SimpleXmlWrappers.wrap(directory), writer);

            final SimpleXmlWrapperValue wrapper = persister.read(
                SimpleXmlWrapperValue.class, new StringReader(writer.toString()));
            assertThat(wrapper).describedAs("Wrapper for: " + writer.toString()).isNotNull();
            unserializedDir = SimpleXmlWrappers.unwrap(wrapper);

            assertThat(unserializedDir).isNotNull();
View Full Code Here

   
    @Test
    public void testSimpleXmlHandling() throws Exception
    {
        // From bytes.
        Persister p = new Persister();
        Example e = p.read(Example.class, new ByteArrayInputStream(utf8Xml));
        assertThat(e.text).isEqualTo(" \u0096 ");

        // round trip.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        p.write(e, baos);
        e = p.read(Example.class, new ByteArrayInputStream(utf8Xml));
        assertThat(e.text).isEqualTo(" \u0096 ");
    }
View Full Code Here

    {
        final InputStream inputStream = resource.open();
        final WebappConfig loaded;
        try
        {
            loaded = new Persister().read(WebappConfig.class, inputStream);
        }
        finally
        {
            CloseableUtils.close(inputStream);
        }
View Full Code Here

            Bing3WebDocumentSourceDescriptor.attributeBuilder(attributes)
                .appid(appid)
                .market((MarketOption) null);

            ProcessingResult result = controller.process(attributes, Bing3WebDocumentSource.class);
            Persister p = new Persister();
            p.write(result, new File("result.xml"));
        } finally {
            controller.dispose();
        }       
    }
View Full Code Here

            final ProcessingComponentDocs components = new ProcessingComponentDocs(suite);
   
            final Format format = new Format(2,
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
   
            new Persister(format).write(components,
                new FileOutputStream(new File(output)), "UTF-8");
        }
        catch (Exception e)
        {
            System.err.println(e);
View Full Code Here

        RequestModel requestModel) throws Exception
    {
        response.setContentType(MIME_XML_UTF8);
        final AjaxAttributesModel model = new AjaxAttributesModel(webappConfig, requestModel);

        final Persister persister = new Persister(getPersisterFormat(requestModel));
        persister.write(model, response.getWriter());
        setExpires(response, 60 * 24 * 7); // 1 week
    }
View Full Code Here

    {
        response.setContentType(MIME_XML_UTF8);
        final PageModel pageModel = new PageModel(webappConfig, request, requestModel,
            jawrUrlGenerator, null, null);

        final Persister persister = new Persister(
            getPersisterFormat(pageModel.requestModel));
        persister.write(pageModel, response.getWriter());
    }
View Full Code Here

TOP

Related Classes of org.simpleframework.xml.core.Persister

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.