en cours, 2
[nikiroo-utils.git] / src / be / nikiroo / utils / serial / SerialUtils.java
index e2d8decea64113bfe76ac0962196e325a2fcf2d8..e88337b0a7f68ac03fd10ce2696909bb0cf8a187 100644 (file)
@@ -56,39 +56,42 @@ public class SerialUtils {
                // Array types:
                customTypes.put("[]", new CustomSerializer() {
                        @Override
-                       protected String toString(Object value) {
+                       protected void toStream(OutputStream out, Object value)
+                                       throws IOException {
                                String type = value.getClass().getCanonicalName();
                                type = type.substring(0, type.length() - 2); // remove the []
 
-                               StringBuilder builder = new StringBuilder();
-                               builder.append(type).append("\n");
+                               write(out,type);
+                               write(out,"\n");
                                try {
                                        for (int i = 0; true; i++) {
                                                Object item = Array.get(value, i);
                                                // encode it normally if direct value
-                                               if (!SerialUtils.encode(builder, item)) {
+                                               if (!SerialUtils.encode(out, item)) {
                                                        try {
-                                                               // use ZIP: if not
-                                                               new Exporter().append(item).appendTo(builder,
-                                                                               true, false);
+                                                               // TODO: use ZIP: if not?
+                                                               new Exporter(out).append(item);
                                                        } catch (NotSerializableException e) {
                                                                throw new UnknownFormatConversionException(e
                                                                                .getMessage());
                                                        }
                                                }
-                                               builder.append("\n");
+                                               write(out,"\n");
                                        }
                                } catch (ArrayIndexOutOfBoundsException e) {
                                        // Done.
                                }
-
-                               return builder.toString();
                        }
 
                        @Override
                        protected String getType() {
                                return "[]";
                        }
+                       
+                       @Override
+                       protected Object fromStream(InputStream in) throws IOException {
+                               return null;
+                       }
 
                        @Override
                        protected Object fromString(String content) throws IOException {