Version 4.5.0
[nikiroo-utils.git] / src / be / nikiroo / utils / serial / SerialUtils.java
index 114f80b2576a57a08177d944adfe755da2665544..706d579970f9456fd430d4ae2020185aa8c7ed24 100644 (file)
@@ -66,8 +66,8 @@ public class SerialUtils {
                                                if (!SerialUtils.encode(builder, item)) {
                                                        try {
                                                                // use ZIP: if not
-                                                               builder.append(new Exporter().append(item)
-                                                                               .toString(true));
+                                                               new Exporter().append(item).appendTo(builder,
+                                                                               true, false);
                                                        } catch (NotSerializableException e) {
                                                                throw new UnknownFormatConversionException(e
                                                                                .getMessage());
@@ -173,7 +173,6 @@ public class SerialUtils {
                        throws ClassNotFoundException, NoSuchMethodException {
 
                String desc = null;
-
                try {
                        Class<?> clazz = getClass(type);
                        String className = clazz.getName();
@@ -209,8 +208,18 @@ public class SerialUtils {
                                desc += end;
                                //
 
-                               ctor = clazz.getDeclaredConstructor(classes
-                                               .toArray(new Class[] {}));
+                               try {
+                                       ctor = clazz.getDeclaredConstructor(classes
+                                                       .toArray(new Class[] {}));
+                               } catch (NoSuchMethodException nsme) {
+                                       // TODO: it seems e do not always need a parameter for each
+                                       // level, so we currently try "ALL" levels or "FIRST" level
+                                       // only -> we should check the actual rule and use it
+                                       ctor = clazz.getDeclaredConstructor(classes.get(0));
+                                       Object firstParent = args.get(0);
+                                       args.clear();
+                                       args.add(firstParent);
+                               }
                                desc = null;
                        } else {
                                ctor = clazz.getDeclaredConstructor();