org.jhotdraw8.draw.io.XmlEncoderOutputFormat Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.jhotdraw8.draw Show documentation
Show all versions of org.jhotdraw8.draw Show documentation
JHotDraw8 Drawing Framework
The newest version!
/*
* @(#)XmlEncoderOutputFormat.java
* Copyright © 2023 The authors and contributors of JHotDraw. MIT License.
*/
package org.jhotdraw8.draw.io;
import org.jhotdraw8.draw.figure.Drawing;
import org.jhotdraw8.fxbase.concurrent.WorkState;
import org.jhotdraw8.fxcollection.typesafekey.Key;
import org.jhotdraw8.icollection.ChampMap;
import org.jhotdraw8.icollection.immutable.ImmutableMap;
import org.jspecify.annotations.Nullable;
import java.beans.XMLEncoder;
import java.io.OutputStream;
import java.net.URI;
/**
* XMLEncoderOutputFormat.
*
* @author Werner Randelshofer
*/
public class XmlEncoderOutputFormat implements OutputFormat {
public static final String XML_SERIALIZER_MIME_TYPE = "application/xml+ser";
private ImmutableMap, Object> options = ChampMap.of();
public XmlEncoderOutputFormat() {
}
@Override
public void write(OutputStream out, @Nullable URI documentHome, Drawing drawing, WorkState workState) {
try (XMLEncoder o = new XMLEncoder(out)) {
o.writeObject(drawing);
}
}
@Override
public ImmutableMap, Object> getOptions() {
return options;
}
@Override
public void setOptions(ImmutableMap, Object> options) {
this.options = options;
}
}