]> git.gag.com Git - debian/openrocket/blob - core/src/net/sf/openrocket/file/rocksim/importt/AttachedPartsHandler.java
bfb7692ad31d2b3e1f9395d52c2536e390559278
[debian/openrocket] / core / src / net / sf / openrocket / file / rocksim / importt / AttachedPartsHandler.java
1 /*
2  * AttachedPartsHandler.java
3  */
4 package net.sf.openrocket.file.rocksim.importt;
5
6 import net.sf.openrocket.aerodynamics.WarningSet;
7 import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
8 import net.sf.openrocket.file.simplesax.ElementHandler;
9 import net.sf.openrocket.rocketcomponent.RocketComponent;
10
11 import java.util.HashMap;
12
13 /**
14  * A SAX handler for the Rocksim AttachedParts XML type.  
15  */
16 class AttachedPartsHandler extends ElementHandler {
17     /** The parent component. */
18     private final RocketComponent component;
19
20     /**
21      * Constructor.
22      * 
23      * @param c  the parent
24      * 
25      * @throws IllegalArgumentException   thrown if <code>c</code> is null
26      */
27     public AttachedPartsHandler(RocketComponent c) throws IllegalArgumentException {
28         if (c == null) {
29             throw new IllegalArgumentException("The parent component of any attached part may not be null.");
30         }
31         component = c;
32     }
33
34     @Override
35     public ElementHandler openElement(String element, HashMap<String, String> attributes, WarningSet warnings) {
36         if (RocksimCommonConstants.FIN_SET.equals(element)) {
37             return new FinSetHandler(component);
38         }
39         if (RocksimCommonConstants.CUSTOM_FIN_SET.equals(element)) {
40             return new FinSetHandler(component);
41         }
42         if (RocksimCommonConstants.LAUNCH_LUG.equals(element)) {
43             return new LaunchLugHandler(component, warnings);
44         }
45         if (RocksimCommonConstants.PARACHUTE.equals(element)) {
46             return new ParachuteHandler(component, warnings);
47         }
48         if (RocksimCommonConstants.STREAMER.equals(element)) {
49             return new StreamerHandler(component, warnings);
50         }
51         if (RocksimCommonConstants.MASS_OBJECT.equals(element)) {
52             return new MassObjectHandler(component, warnings);
53         }
54         if (RocksimCommonConstants.RING.equals(element)) {
55             return new RingHandler(component, warnings);
56         }
57         if (RocksimCommonConstants.BODY_TUBE.equals(element)) {
58             return new InnerBodyTubeHandler(component, warnings);
59         }
60         if (RocksimCommonConstants.TRANSITION.equals(element)) {
61             return new TransitionHandler(component, warnings);
62         }
63         if (RocksimCommonConstants.TUBE_FIN_SET.equals(element)) {
64             warnings.add("Tube fins are not currently supported. Ignoring.");
65         }
66         if (RocksimCommonConstants.RING_TAIL.equals(element)) {
67             warnings.add("Ring tails are not currently supported. Ignoring.");
68         }
69         if (RocksimCommonConstants.EXTERNAL_POD.equals(element)) {
70             warnings.add("Pods are not currently supported. Ignoring.");
71         }
72         return null;
73     }
74 }
75