Package org.simpleframework.xml.core

Examples of org.simpleframework.xml.core.Persister


        }

        // Send response, sets encoding of the response writer.
        response.setContentType(MIME_XML_UTF8);

        final Persister persister = new Persister(getPersisterFormat(requestModel));
        final PrintWriter writer = response.getWriter();
        if (RequestType.CARROT2.equals(requestModel.type) ||
            RequestType.CARROT2DOCUMENTS.equals(requestModel.type))
        {
            // Check for an empty processing result.
            if (processingException != null)
            {
                response.sendError(
                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Internal server error: " + processingException.getMessage());
                return;
            }

            persister.write(processingResult, writer);
        }
        else
        {
            response.setContentType(MIME_XML_UTF8);

            final PageModel pageModel = new PageModel(webappConfig, request, requestModel,
                jawrUrlGenerator, processingResult, processingException);

            persister.write(pageModel, writer);
        }
    }
View Full Code Here


     * Create a persister with an arbitrary session map and deserialization strategy.
     */
    private static Persister createPersister(
        Map<Object, Object> attributes, Strategy strategy)
    {
        return new Persister(new SessionInitStrategy(strategy, attributes));
    }
View Full Code Here

    /**
     * Populate {@link #documents}.
     */
    public static void readData() throws Exception
    {
        Persister p = new Persister();
        for (int i = 0; i < MAX_FILES; i++)
        {
            String fileName = String.format("response-%05d.xml", i);
            ResponseWrapper w = p.read(ResponseWrapper.class, new File(inputFilesDir,
                fileName));

            if (w.documents == null) continue;
            for (Document d : w.documents)
            {
View Full Code Here

        if (configResource == null) throw new IOException("Resource not found.");

        final InputStream stream = configResource.open();
        try
        {
            return new Persister().read(DcsConfig.class, stream);
        }
        finally
        {
            CloseableUtils.close(stream);
        }
View Full Code Here

    static IMemento toMemento(Object benchmarkSettings) throws IOException
    {
        try
        {
            final StringWriter w = new StringWriter();
            new Persister().write(benchmarkSettings, w);
            XMLMemento memento = XMLMemento
                .createReadRoot(new StringReader(w.toString()));
            return memento;
        }
        catch (Exception e)
View Full Code Here

        {
            final StringWriter sw = new StringWriter();
            final XMLMemento m = XMLMemento.createWriteRoot(memento.getType());
            m.putMemento(memento);
            m.save(sw);
            return new Persister().read(clazz, new StringReader(sw.toString()));
        }
        catch (Exception e)
        {
            throw ExceptionUtils.wrapAs(IOException.class, e);
        }
View Full Code Here

        checkObject(object);

        try
        {
            final StringWriter w = new StringWriter();
            new Persister().write(object, w);
            return w.toString();
        }
        catch (Exception e)
        {
            throw ExceptionUtils.wrapAs(IOException.class, e);
View Full Code Here

    public static <T> T fromString(Class<T> clazz, String xml) throws IOException
    {
        try
        {
            final StringReader r = new StringReader(xml);
            return new Persister().read(clazz, r);
        }
        catch (Exception e)
        {
            throw ExceptionUtils.wrapAs(IOException.class, e);
        }
View Full Code Here

     * Parse the response.
     */
    private SearchEngineResponse parseResponse(InputStream payloadAsStream)
        throws Exception
    {
        final AtomFeed response = new Persister().read(AtomFeed.class, payloadAsStream);

        final SearchEngineResponse ser = new SearchEngineResponse();
        final LanguageCode langCode = market != null ? market.toLanguageCode() : null;
       
        if (response.entries != null)
View Full Code Here

    /**
     * Serializes this statistics object as XML stream.
     */
    public void serialize(OutputStream stream) throws Exception
    {
        new Persister().write(this, stream);
    }
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.