Search in sources :

Example 1 with DefaultPersistenceDelegate

use of java.beans.DefaultPersistenceDelegate in project jdk8u_jdk by JetBrains.

the class AbstractTest method test.

static void test(AbstractTest object) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    XMLEncoder encoder = new XMLEncoder(output);
    encoder.setPersistenceDelegate(object.getClass(), new DefaultPersistenceDelegate(new String[] { "value" }));
    encoder.writeObject(object);
    encoder.close();
    System.out.print(output);
    ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
    XMLDecoder decoder = new XMLDecoder(input);
    AbstractTest result = (AbstractTest) decoder.readObject();
    decoder.close();
    if (object.getValue() != result.getValue())
        throw new Error("Should be " + object);
}
Also used : XMLEncoder(java.beans.XMLEncoder) DefaultPersistenceDelegate(java.beans.DefaultPersistenceDelegate) ByteArrayInputStream(java.io.ByteArrayInputStream) XMLDecoder(java.beans.XMLDecoder) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 2 with DefaultPersistenceDelegate

use of java.beans.DefaultPersistenceDelegate in project jdk8u_jdk by JetBrains.

the class Test4968523 method main.

public static void main(String[] args) {
    String[] names = { "time" };
    test(Date.class, new DefaultPersistenceDelegate(names));
    test(null, new DefaultPersistenceDelegate());
}
Also used : DefaultPersistenceDelegate(java.beans.DefaultPersistenceDelegate)

Aggregations

DefaultPersistenceDelegate (java.beans.DefaultPersistenceDelegate)2 XMLDecoder (java.beans.XMLDecoder)1 XMLEncoder (java.beans.XMLEncoder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1