Search in sources :

Example 66 with Persister

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

the class EmbeddedDashboardConfig method createFromXml.

/**
 * Create line chart settings object from XML document
 *
 * @param xml XML document
 * @return deserialized object
 * @throws Exception if the object cannot be fully deserialized
 */
public static EmbeddedDashboardConfig createFromXml(final String xml) throws Exception {
    Serializer serializer = new Persister();
    EmbeddedDashboardConfig config = serializer.read(EmbeddedDashboardConfig.class, xml);
    // fix configuration if it was saved in old format
    if ((config.objectId != 0) && (config.dashboardObjects.length == 0)) {
        config.dashboardObjects = new long[1];
        config.dashboardObjects[0] = config.objectId;
        config.objectId = 0;
    }
    return config;
}
Also used : Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 67 with Persister

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

the class EmbeddedDashboardConfig method createXml.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig#createXml()
	 */
@Override
public String createXml() throws Exception {
    Serializer serializer = new Persister();
    Writer writer = new StringWriter();
    serializer.write(this, writer);
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) Persister(org.simpleframework.xml.core.Persister) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Serializer(org.simpleframework.xml.Serializer)

Example 68 with Persister

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

the class LabelConfig method createFromXml.

/**
 * Create label configuration object from XML document
 *
 * @param xml XML document
 * @return deserialized object
 * @throws Exception if the object cannot be fully deserialized
 */
public static LabelConfig createFromXml(final String xml) throws Exception {
    Serializer serializer = new Persister();
    LabelConfig config = serializer.read(LabelConfig.class, xml);
    // Update from old versions
    if ((config.foreground != null) && config.foreground.startsWith("0x")) {
        config.setTitleForeground("#" + config.foreground.substring(2));
        config.foreground = null;
    }
    if ((config.background != null) && config.background.startsWith("0x")) {
        config.setTitleBackground("#" + config.background.substring(2));
        config.background = null;
    }
    return config;
}
Also used : Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 69 with Persister

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

the class LogParser 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();
    Writer writer = new StringWriter();
    serializer.write(this, writer);
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) Persister(org.simpleframework.xml.core.Persister) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Serializer(org.simpleframework.xml.Serializer)

Example 70 with Persister

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

the class DashboardElementLayout method createXml.

/**
 * @return
 * @throws Exception
 */
public String createXml() throws Exception {
    Serializer serializer = new Persister();
    StringWriter writer = new StringWriter();
    serializer.write(this, writer);
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Aggregations

Persister (org.simpleframework.xml.core.Persister)177 Serializer (org.simpleframework.xml.Serializer)141 StringWriter (java.io.StringWriter)74 Writer (java.io.Writer)62 Registry (org.simpleframework.xml.convert.Registry)23 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)23 Strategy (org.simpleframework.xml.strategy.Strategy)23 AnnotationStrategy (org.simpleframework.xml.convert.AnnotationStrategy)20 File (java.io.File)18 Test (org.junit.Test)14 IOException (java.io.IOException)12 StorageException (org.syncany.plugins.transfer.StorageException)8 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)6 ConfigTO (org.syncany.config.to.ConfigTO)5 UnreliableLocalTransferSettings (org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileOutputStream (java.io.FileOutputStream)4 DateFormat (java.text.DateFormat)4 SimpleDateFormat (java.text.SimpleDateFormat)4 ArrayList (java.util.ArrayList)4