X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FExporter.java;h=6325484eda7ae32ba3a1ebd9055ab8849d8deacd;hb=088c1d7a37212c54251438841995aeb8e5b26fad;hp=8b522e9556054dea43572f6a5e4226f738e116b8;hpb=cd0c27d2e457ea19fcd9def879e1534a528292c2;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/serial/Exporter.java b/src/be/nikiroo/utils/serial/Exporter.java index 8b522e9..6325484 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,42 @@ 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