JmeExporter: remove useless return

experimental
Kirill Vainer 10 years ago
parent 17bf0f8ab3
commit b4baaadc79
  1. 8
      jme3-core/src/main/java/com/jme3/export/JmeExporter.java
  2. 14
      jme3-core/src/plugins/java/com/jme3/export/binary/BinaryExporter.java
  3. 22
      jme3-plugins/src/xml/java/com/jme3/export/xml/XMLExporter.java

@ -46,22 +46,18 @@ public interface JmeExporter {
* *
* @param object The savable to export * @param object The savable to export
* @param f The output stream * @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 * @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. * Export the {@link Savable} to a file.
* *
* @param object The savable to export * @param object The savable to export
* @param f The file to export to * @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 * @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. * Returns the {@link OutputCapsule} for the given savable object.

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

@ -40,6 +40,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import javax.xml.parsers.DocumentBuilderFactory; 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. * 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 { try {
//Initialize Document when saving so we don't retain state of previous exports //Initialize Document when saving so we don't retain state of previous exports
this.domOut = new DOMOutputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(), this); this.domOut = new DOMOutputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(), this);
@ -69,18 +71,22 @@ public class XMLExporter implements JmeExporter {
DOMSerializer serializer = new DOMSerializer(); DOMSerializer serializer = new DOMSerializer();
serializer.serialize(domOut.getDoc(), f); serializer.serialize(domOut.getDoc(), f);
f.flush(); f.flush();
return true; } catch (ParserConfigurationException ex) {
} catch (Exception ex) { throw new IOException(ex);
IOException e = new IOException();
e.initCause(ex);
throw e;
} }
} }
public boolean save(Savable object, File f) throws IOException { @Override
return save(object, new FileOutputStream(f)); 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) { public OutputCapsule getCapsule(Savable object) {
return domOut; return domOut;
} }

Loading…
Cancel
Save