Explorar o código

JmeExporter: remove useless return

Kirill Vainer %!s(int64=10) %!d(string=hai) anos
pai
achega
b4baaadc79

+ 2 - 6
jme3-core/src/main/java/com/jme3/export/JmeExporter.java

@@ -46,22 +46,18 @@ public interface JmeExporter {
      * 
      * @param object The savable to export
      * @param f The output stream
-     * @return Always returns true. If an error occurs during export, 
-     * an exception is thrown
      * @throws IOException If an io exception occurs during export
      */
-    public boolean save(Savable object, OutputStream f) throws IOException;
+    public void save(Savable object, OutputStream f) throws IOException;
     
     /**
      * Export the {@link Savable} to a file.
      * 
      * @param object The savable to export
      * @param f The file to export to
-     * @return Always returns true. If an error occurs during export, 
-     * an exception is thrown
      * @throws IOException If an io exception occurs during export
      */
-    public boolean save(Savable object, File f) throws IOException;
+    public void save(Savable object, File f) throws IOException;
     
     /**
      * Returns the {@link OutputCapsule} for the given savable object.

+ 5 - 9
jme3-core/src/plugins/java/com/jme3/export/binary/BinaryExporter.java

@@ -168,7 +168,7 @@ public class BinaryExporter implements JmeExporter {
         return new BinaryExporter();
     }
 
-    public boolean save(Savable object, OutputStream os) throws IOException {
+    public void save(Savable object, OutputStream os) throws IOException {
         // reset some vars
         aliasCount = 1;
         idCount = 1;
@@ -286,7 +286,7 @@ public class BinaryExporter implements JmeExporter {
         out = null;
         os = null;
 
-        if (debug ) {
+        if (debug) {
             logger.fine("Stats:");
             logger.log(Level.FINE, "classes: {0}", classNum);
             logger.log(Level.FINE, "class table: {0} bytes", classTableSize);
@@ -294,8 +294,6 @@ public class BinaryExporter implements JmeExporter {
             logger.log(Level.FINE, "location table: {0} bytes", locationTableSize);
             logger.log(Level.FINE, "data: {0} bytes", location);
         }
-
-        return true;
     }
 
     protected String getChunk(BinaryIdContentPair pair) {
@@ -325,7 +323,7 @@ public class BinaryExporter implements JmeExporter {
         return bytes;
     }
 
-    public boolean save(Savable object, File f) throws IOException {
+    public void save(Savable object, File f) throws IOException {
         File parentDirectory = f.getParentFile();
         if (parentDirectory != null && !parentDirectory.exists()) {
             parentDirectory.mkdirs();
@@ -333,11 +331,9 @@ public class BinaryExporter implements JmeExporter {
 
         FileOutputStream fos = new FileOutputStream(f);
         try {
-            return save(object, fos);
+            save(object, fos);
         } finally {
-            if (fos != null) {
-                fos.close();
-            }
+            fos.close();
         }
     }
 

+ 14 - 8
jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java

@@ -40,6 +40,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 
 /**
  * Part of the jME XML IO system as introduced in the google code jmexml project.
@@ -61,7 +62,8 @@ public class XMLExporter implements JmeExporter {
        
     }
 
-    public boolean save(Savable object, OutputStream f) throws IOException {
+    @Override
+    public void save(Savable object, OutputStream f) throws IOException {
         try {
             //Initialize Document when saving so we don't retain state of previous exports
             this.domOut = new DOMOutputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(), this);
@@ -69,18 +71,22 @@ public class XMLExporter implements JmeExporter {
             DOMSerializer serializer = new DOMSerializer();
             serializer.serialize(domOut.getDoc(), f);
             f.flush();
-            return true;
-        } catch (Exception ex) {
-            IOException e = new IOException();
-            e.initCause(ex);
-            throw e;
+        } catch (ParserConfigurationException ex) {
+            throw new IOException(ex);
         }
     }
 
-    public boolean save(Savable object, File f) throws IOException {
-        return save(object, new FileOutputStream(f));
+    @Override
+    public void save(Savable object, File f) throws IOException {
+        FileOutputStream fos = new FileOutputStream(f);
+        try {
+            save(object, fos);
+        } finally {
+            fos.close();
+        }
     }
 
+    @Override
     public OutputCapsule getCapsule(Savable object) {
         return domOut;
     }