X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FExporter.java;h=2470bde4dace9f6dd0ca73f61373991a4cbd4283;hb=c8468a10176ff56b4d4457cebd9b2f064b93eaed;hp=709c5903f6b4e9e9f62515bc601432e6aad200b7;hpb=143a64f4c6804d0cd17595ffcf7a44f4a151ffdc;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/serial/Exporter.java b/src/be/nikiroo/utils/serial/Exporter.java index 709c590..2470bde 100644 --- a/src/be/nikiroo/utils/serial/Exporter.java +++ b/src/be/nikiroo/utils/serial/Exporter.java @@ -6,8 +6,6 @@ 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}. *

@@ -22,6 +20,9 @@ public class Exporter { /** * Create a new {@link Exporter}. + * + * @param out + * export the data to this stream */ public Exporter(OutputStream out) { if (out == null) { @@ -56,40 +57,4 @@ public class Exporter { SerialUtils.append(out, o, map); return this; } - - /** - * Append the exported items in a serialised form into the given - * {@link OutputStream}. - * - * @param out - * the {@link OutputStream} - * @param b64 - * TRUE to have BASE64-coded content, FALSE to have raw content, - * NULL to let the system decide - * @param zip - * TRUE to zip the BASE64 output if the output is indeed in - * BASE64 format, FALSE not to - */ - public void appendTo(OutputStream out, Boolean b64, boolean zip) { - if (b64 == null && out.length() < 128) { - b64 = false; - } - - if (b64 == null || b64) { - try { - String zipped = StringUtils.base64(out.toString(), zip); - if (b64 != null || zipped.length() < out.length() - 4) { - SerialUtils.write(out, zip ? "ZIP:" : "B64:"); - SerialUtils.write(out, zipped); - return; - } - } catch (IOException e) { - throw new RuntimeException( - "Base64 conversion of data failed, maybe not enough memory?", - e); - } - } - - out.append(out); - } } \ No newline at end of file