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 AbstractRocketLoader implements RocketLoader {
15 protected final WarningSet warnings = new WarningSet();
19 * Loads a rocket from the specified File object.
22 public final OpenRocketDocument load(File source, MotorFinder motorFinder) throws RocketLoadException {
24 InputStream stream = null;
28 stream = new BufferedInputStream(new FileInputStream(source));
29 return load(stream, motorFinder);
31 } catch (FileNotFoundException e) {
32 throw new RocketLoadException("File not found: " + source);
37 } catch (IOException e) {
45 * Loads a rocket from the specified InputStream.
48 public final OpenRocketDocument load(InputStream source, MotorFinder motorFinder) throws RocketLoadException {
52 return loadFromStream(source, motorFinder);
53 } catch (RocketLoadException e) {
55 } catch (IOException e) {
56 throw new RocketLoadException("I/O error: " + e.getMessage(), e);
63 * This method is called by the default implementations of #load(File)
64 * and load(InputStream) to load the rocket.
66 * @throws RocketLoadException if an error occurs during loading.
68 protected abstract OpenRocketDocument loadFromStream(InputStream source, MotorFinder motorFinder) throws IOException,
74 public final WarningSet getWarnings() {