Search in sources :

Example 1 with AnnotationStrategy

use of org.simpleframework.xml.convert.AnnotationStrategy in project osm-contributor by jawg.

the class CommonSyncModule method getPersister.

@Provides
Persister getPersister() {
    RegistryMatcher matchers = new RegistryMatcher();
    matchers.bind(org.joda.time.DateTime.class, JodaTimeDateTimeTransform.class);
    Strategy strategy = new AnnotationStrategy();
    return new Persister(strategy, matchers);
}
Also used : AnnotationStrategy(org.simpleframework.xml.convert.AnnotationStrategy) AnnotationStrategy(org.simpleframework.xml.convert.AnnotationStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryMatcher(org.simpleframework.xml.transform.RegistryMatcher) Persister(org.simpleframework.xml.core.Persister) Provides(dagger.Provides)

Example 2 with AnnotationStrategy

use of org.simpleframework.xml.convert.AnnotationStrategy 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 3 with AnnotationStrategy

use of org.simpleframework.xml.convert.AnnotationStrategy 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 4 with AnnotationStrategy

use of org.simpleframework.xml.convert.AnnotationStrategy 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 5 with AnnotationStrategy

use of org.simpleframework.xml.convert.AnnotationStrategy in project netxms by netxms.

the class XMLTools method createSerializer.

/**
 * Create serializer with registered converters
 *
 * @return serializer with registered converters
 * @throws Exception on XML library failures
 */
public static Serializer createSerializer() throws Exception {
    Registry registry = new Registry();
    registry.bind(UUID.class, UUIDConverter.class);
    return new Persister(new AnnotationStrategy(new RegistryStrategy(registry)));
}
Also used : AnnotationStrategy(org.simpleframework.xml.convert.AnnotationStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister)

Aggregations

AnnotationStrategy (org.simpleframework.xml.convert.AnnotationStrategy)5 Persister (org.simpleframework.xml.core.Persister)5 Serializer (org.simpleframework.xml.Serializer)3 StringWriter (java.io.StringWriter)2 Writer (java.io.Writer)2 Provides (dagger.Provides)1 Registry (org.simpleframework.xml.convert.Registry)1 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)1 Strategy (org.simpleframework.xml.strategy.Strategy)1 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)1