create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / preset / loader / ShapeColumnParser.java
1 package net.sf.openrocket.preset.loader;
2
3 import java.util.Locale;
4
5 import net.sf.openrocket.preset.ComponentPreset;
6 import net.sf.openrocket.preset.TypedPropertyMap;
7 import net.sf.openrocket.rocketcomponent.Transition;
8 import net.sf.openrocket.rocketcomponent.Transition.Shape;
9 import net.sf.openrocket.util.BugException;
10
11 public class ShapeColumnParser extends BaseColumnParser {
12
13         public ShapeColumnParser() {
14                 super("Shape");
15         }
16
17         @Override
18         protected void doParse(String columnData, String[] data, TypedPropertyMap props) {
19                 Transition.Shape shape = null;
20                 String lc = columnData.toLowerCase(Locale.US);
21                 if ( "ogive".equals(lc) ) {
22                         shape = Shape.OGIVE;
23                 }
24                 if ( "conical".equals(lc) ) {
25                         shape = Shape.CONICAL;
26                 }
27                 if ( "cone".equals(lc) ) {
28                         shape = Shape.CONICAL;
29                 }
30                 if ( "elliptical".equals(lc) ) {
31                         shape = Shape.ELLIPSOID;
32                 }
33                 if ( "parabolic".equals(lc) ) {
34                         shape = Shape.PARABOLIC;
35                 }
36                 if ( "sears-haack".equals(lc) ) {
37                         shape = Shape.HAACK;
38                 }
39                 if ( "power-series".equals(lc) ) {
40                         shape = Shape.POWER;
41                 }
42                 // guessing at what "ps" means.  I think it might be power series.
43                 if ( "ps".equals(lc) ) {
44                         shape = Shape.POWER;
45                 }
46                 if ( "1".equals(lc) ) {
47                         shape = Shape.OGIVE;
48                 }
49                 if( "0". equals(lc) ) {
50                         shape = Shape.CONICAL;
51                 }
52                 if( "". equals(lc) ) {
53                         shape = Shape.CONICAL;
54                 }
55                 if ( "3".equals(lc) ) {
56                         shape = Shape.ELLIPSOID;
57                 }
58                 if ( shape == null ) {
59                         throw new BugException("Invalid shape parameter: " + columnData);
60                 }
61                 props.put(ComponentPreset.SHAPE, shape);
62         }
63
64 }