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);
}
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();
}
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);
}
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();
}
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)));
}
Aggregations