X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FSerialUtils.java;h=e88337b0a7f68ac03fd10ce2696909bb0cf8a187;hb=ecd81c088d8df94c47c85399afdab87bbd39afaf;hp=e2d8decea64113bfe76ac0962196e325a2fcf2d8;hpb=68532958426cd3c6187aa89eae4f137bc057293b;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/serial/SerialUtils.java b/src/be/nikiroo/utils/serial/SerialUtils.java index e2d8dec..e88337b 100644 --- a/src/be/nikiroo/utils/serial/SerialUtils.java +++ b/src/be/nikiroo/utils/serial/SerialUtils.java @@ -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 {