Search in sources :

Example 36 with Persister

use of org.simpleframework.xml.core.Persister in project applause by applause.

the class CompanyDescriptionProvider method extractItem.

protected Company extractItem(Reader reader) throws Exception {
    Serializer serializer = new Persister();
    Data root = serializer.read(Data.class, reader);
    return root.getCompany();
}
Also used : Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 37 with Persister

use of org.simpleframework.xml.core.Persister in project applause by applause.

the class OfficeByIdProvider method extractItem.

protected Office extractItem(Reader reader) throws Exception {
    Serializer serializer = new Persister();
    Offices root = serializer.read(Offices.class, reader);
    return root.getOffice();
}
Also used : Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 38 with Persister

use of org.simpleframework.xml.core.Persister in project netxms by netxms.

the class ChartConfig method createXml.

/**
 * Create XML from configuration.
 *
 * @return XML document
 * @throws Exception if the schema for the object is not valid
 */
public String createXml() throws Exception {
    Serializer serializer = new Persister(new AnnotationStrategy());
    Writer writer = new StringWriter();
    serializer.write(this, writer);
    return writer.toString();
}
Also used : AnnotationStrategy(org.simpleframework.xml.convert.AnnotationStrategy) StringWriter(java.io.StringWriter) Persister(org.simpleframework.xml.core.Persister) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Serializer(org.simpleframework.xml.Serializer)

Example 39 with Persister

use of org.simpleframework.xml.core.Persister in project netxms by netxms.

the class ChartConfig method createFromXml.

/**
 * Create chart settings object from XML document
 *
 * @param xml XML document
 * @return deserialized object
 * @throws Exception if the object cannot be fully deserialized
 */
public static ChartConfig createFromXml(final String xml) throws Exception {
    if (xml == null)
        return new ChartConfig();
    // should be removed in 1.2.1
    if (!xml.startsWith("<chart>")) {
        ChartConfig config = new ChartConfig();
        config.parseLegacyConfig(xml);
        return config;
    }
    Serializer serializer = new Persister(new AnnotationStrategy());
    return serializer.read(ChartConfig.class, xml);
}
Also used : AnnotationStrategy(org.simpleframework.xml.convert.AnnotationStrategy) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 40 with Persister

use of org.simpleframework.xml.core.Persister in project netxms by netxms.

the class ChartConfig method createXml.

/**
 * Create XML from configuration.
 *
 * @return XML document
 * @throws Exception if the schema for the object is not valid
 */
public String createXml() throws Exception {
    Serializer serializer = new Persister(new AnnotationStrategy());
    Writer writer = new StringWriter();
    serializer.write(this, writer);
    return writer.toString();
}
Also used : AnnotationStrategy(org.simpleframework.xml.convert.AnnotationStrategy) StringWriter(java.io.StringWriter) Persister(org.simpleframework.xml.core.Persister) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Serializer(org.simpleframework.xml.Serializer)

Aggregations

Persister (org.simpleframework.xml.core.Persister)187 Serializer (org.simpleframework.xml.Serializer)149 StringWriter (java.io.StringWriter)74 Writer (java.io.Writer)62 Registry (org.simpleframework.xml.convert.Registry)30 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)30 Strategy (org.simpleframework.xml.strategy.Strategy)30 AnnotationStrategy (org.simpleframework.xml.convert.AnnotationStrategy)20 File (java.io.File)19 Test (org.junit.Test)14 IOException (java.io.IOException)13 Format (org.simpleframework.xml.stream.Format)11 StorageException (org.syncany.plugins.transfer.StorageException)8 Style (org.simpleframework.xml.stream.Style)7 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 SimpleDateFormat (java.text.SimpleDateFormat)5 ArrayList (java.util.ArrayList)5 CamelCaseStyle (org.simpleframework.xml.stream.CamelCaseStyle)5 ConfigTO (org.syncany.config.to.ConfigTO)5