X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FSerialUtils.java;h=ad3b5d4da2a8dae4955e12ce28f2cfd9a51fc5f7;hb=601003e69e1dc81774243c6eadf7982b6b563b33;hp=c4b7cf9db8539c569d172fd9104a639b10b37823;hpb=24604392c3aa6d9298aacd10fde7bb2df1322a10;p=fanfix.git diff --git a/src/be/nikiroo/utils/serial/SerialUtils.java b/src/be/nikiroo/utils/serial/SerialUtils.java index c4b7cf9..ad3b5d4 100644 --- a/src/be/nikiroo/utils/serial/SerialUtils.java +++ b/src/be/nikiroo/utils/serial/SerialUtils.java @@ -65,8 +65,6 @@ public class SerialUtils { protected void toStream(OutputStream out, Object value) throws IOException { - // TODO: we use \n to separate, and b64 to un-\n - // -- but we could use \\n ? String type = value.getClass().getCanonicalName(); type = type.substring(0, type.length() - 2); // remove the [] @@ -79,11 +77,11 @@ public class SerialUtils { write(out, "\r"); if (!SerialUtils.encode(out, item)) { try { - // TODO: bad escaping? write(out, "B64:"); OutputStream out64 = new Base64OutputStream( out, true); new Exporter(out64).append(item); + out64.flush(); } catch (NotSerializableException e) { throw new UnknownFormatConversionException(e .getMessage()); @@ -464,7 +462,6 @@ public class SerialUtils { } } - // TODO: Not efficient for (String prefix : new String[] { "c\"", "\"", "b", "s", "i", "l", "f", "d", "E:" }) { if (encodedValue.startsWith(prefix)) { @@ -514,7 +511,6 @@ public class SerialUtils { throw new IOException("Unknown custom type: " + type); } finally { content.close(false); - // TODO: check what happens with thrown Exception in finally encodedValue.end(); } } @@ -676,20 +672,6 @@ public class SerialUtils { out.write('\"'); } - // aa bb -> "aa\tbb" - static void encodeString(OutputStream out, InputStream raw) - throws IOException { - out.write('\"'); - byte buffer[] = new byte[4096]; - for (int len = 0; (len = raw.read(buffer)) > 0;) { - for (int i = 0; i < len; i++) { - // TODO: not 100% correct, look up howto for UTF-8 - encodeString(out, (char) buffer[i]); - } - } - out.write('\"'); - } - // for encoding string, NOT to encode a char by itself! static void encodeString(OutputStream out, char raw) throws IOException { switch (raw) {