X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FExporter.java;h=2470bde4dace9f6dd0ca73f61373991a4cbd4283;hb=f19b48e27a56ebab18687debd9ef52581a03f06d;hp=8b04111979ddaa751548d11b56f7572381cc1fe2;hpb=db31c35860081535d6e7ddc83ab4af573bb0522e;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/serial/Exporter.java b/src/be/nikiroo/utils/serial/Exporter.java index 8b04111..2470bde 100644 --- a/src/be/nikiroo/utils/serial/Exporter.java +++ b/src/be/nikiroo/utils/serial/Exporter.java @@ -1,11 +1,11 @@ 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; -import be.nikiroo.utils.StringUtils; - /** * A simple class to serialise objects to {@link String}. *
@@ -16,43 +16,45 @@ import be.nikiroo.utils.StringUtils;
*/
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).
*
- * @return the items currently in this {@link Exporter}.
+ * @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
*/
- @Override
- public String toString() {
- return toString(null);
+ public Exporter append(Object o) throws NotSerializableException,
+ IOException {
+ SerialUtils.append(out, o, map);
+ return this;
}
}
\ No newline at end of file