1 package net.sf.openrocket.file;
3 import java.io.BufferedInputStream;
5 import java.io.FileInputStream;
6 import java.io.FileNotFoundException;
7 import java.io.IOException;
8 import java.io.InputStream;
10 import net.sf.openrocket.aerodynamics.WarningSet;
11 import net.sf.openrocket.document.OpenRocketDocument;
14 public abstract class RocketLoader {
15 protected final WarningSet warnings = new WarningSet();
19 * Loads a rocket from the specified File object.
21 public final OpenRocketDocument load(File source) throws RocketLoadException {
23 InputStream stream = null;
27 stream = new BufferedInputStream(new FileInputStream(source));
30 } catch (FileNotFoundException e) {
31 throw new RocketLoadException("File not found: " + source);
36 } catch (IOException e) {
44 * Loads a rocket from the specified InputStream.
46 public final OpenRocketDocument load(InputStream source) throws RocketLoadException {
50 return loadFromStream(source);
51 } catch (RocketLoadException e) {
53 } catch (IOException e) {
54 throw new RocketLoadException("I/O error: " + e.getMessage(), e);
61 * This method is called by the default implementations of {@link #load(File)}
62 * and {@link #load(InputStream)} to load the rocket.
64 * @throws RocketLoadException if an error occurs during loading.
66 protected abstract OpenRocketDocument loadFromStream(InputStream source) throws IOException,
71 public final WarningSet getWarnings() {