X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FExporter.java;fp=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FExporter.java;h=2470bde4dace9f6dd0ca73f61373991a4cbd4283;hb=5584adbbbf5444c0039fed2b35dc7d5bb57b71b1;hp=0000000000000000000000000000000000000000;hpb=ad207feb2815e429ae32484bc6930990099f8ea4;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/serial/Exporter.java b/src/be/nikiroo/utils/serial/Exporter.java new file mode 100644 index 0000000..2470bde --- /dev/null +++ b/src/be/nikiroo/utils/serial/Exporter.java @@ -0,0 +1,60 @@ +package be.nikiroo.utils.serial; + +import java.io.IOException; +import java.io.NotSerializableException; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; + +/** + * A simple class to serialise objects to {@link String}. + *
+ * This class does not support inner classes (it does support nested classes,
+ * though).
+ *
+ * @author niki
+ */
+public class Exporter {
+ private Map
+ * Important: If the operation fails (with a
+ * {@link NotSerializableException}), the {@link Exporter} will be corrupted
+ * (will contain bad, most probably not importable data).
+ *
+ * @param o
+ * the object to serialise
+ * @return this (for easier appending of multiple values)
+ *
+ * @throws NotSerializableException
+ * if the object cannot be serialised (in this case, the
+ * {@link Exporter} can contain bad, most probably not
+ * importable data)
+ * @throws IOException
+ * in case of I/O error
+ */
+ public Exporter append(Object o) throws NotSerializableException,
+ IOException {
+ SerialUtils.append(out, o, map);
+ return this;
+ }
+}
\ No newline at end of file