From b4baaadc79ab259006ae0fa29469d45fabbc9594 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sun, 3 May 2015 15:59:32 -0400 Subject: [PATCH] JmeExporter: remove useless return --- .../java/com/jme3/export/JmeExporter.java | 8 ++----- .../jme3/export/binary/BinaryExporter.java | 14 +++++------- .../java/com/jme3/export/xml/XMLExporter.java | 22 ++++++++++++------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/export/JmeExporter.java b/jme3-core/src/main/java/com/jme3/export/JmeExporter.java index 0afd170ea..b8c3abc60 100644 --- a/jme3-core/src/main/java/com/jme3/export/JmeExporter.java +++ b/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. diff --git a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryExporter.java b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryExporter.java index c02f7088a..b5f458697 100644 --- a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryExporter.java +++ b/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(); } } diff --git a/jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java b/jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java index 32138270d..0ede52884 100644 --- a/jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java +++ b/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; }