jdoc
authorNiki Roo <niki@nikiroo.be>
Wed, 29 May 2019 20:13:34 +0000 (22:13 +0200)
committerNiki Roo <niki@nikiroo.be>
Wed, 29 May 2019 20:13:34 +0000 (22:13 +0200)
src/be/nikiroo/utils/serial/SerialUtils.java
src/be/nikiroo/utils/serial/server/ServerBridge.java

index c4b7cf9db8539c569d172fd9104a639b10b37823..5a20215cb97dca4956df7f9e986d453c73a1c626 100644 (file)
@@ -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)) {
@@ -676,20 +673,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) {
index b97699622b3a8e8b0c2325a758c9eb3f5b567eb3..0b734c6bbd6ca105b852406b2a97ec64ee71b589 100644 (file)
@@ -226,7 +226,6 @@ public class ServerBridge extends Server {
         *            the data to trace
         */
        private void trace(String prefix, String data) {
-               // TODO: we convert to string and back
                int size = data == null ? 0 : data.length();
                String ssize = StringUtils.formatNumber(size) + "bytes";