View Javadoc

1   package org.textensor.stochdiff.neuroml;
2   
3   import java.util.ArrayList;
4   
5   
6   import org.textensor.report.E;
7   import org.textensor.stochdiff.inter.AddableTo;
8   import org.textensor.stochdiff.inter.Transitional;
9   
10  
11  
12  public class morphml implements AddableTo, Transitional {
13  
14      public String id;
15  
16      // TODO read this all into an xmlns hash map;
17      public String xmlns;
18      public String xmlns_mml;
19      public String xmlns_meta;
20      public String xmlns_cml;
21      public String xmlns_xsi;
22      public String xsi_schemaLocation;
23  
24  
25      public String name;
26      public String lengthUnits;
27      public String length_units;
28  
29  
30  
31      public ArrayList<cell> cells = new ArrayList<cell>();
32  
33  
34  
35      public void add(Object obj) {
36          if (obj instanceof cell) {
37              cells.add((cell)obj);
38          } else if (obj instanceof meta) {
39              // ignore for now
40          } else {
41              E.error("unrecognized type " + obj);
42          }
43      }
44  
45  
46  
47      public cell getMorphMLCell() {
48          cell ret = null;
49          if (cells.size() > 0) {
50              Object obj = cells.get(0);
51              try {
52                  if (obj instanceof Transitional) {
53                      obj = ((Transitional)obj).getFinal();
54                  }
55              } catch (Exception ex) {
56                  E.error("cant convert from " + obj);
57              }
58              ret = (cell)obj;
59          }
60          return ret;
61      }
62  
63  
64      public Object getFinal() {
65          Object ret = null;
66          if (cells.size() > 0) {
67              ret = cells.get(0);
68  
69  //			E.info("first item in cells is a " + obj);
70  
71              // obj not necessarily a MorphMLCell in fact, because of population by reflection
72              if (ret instanceof Transitional) {
73  
74                  ret = ((Transitional)ret).getFinal();
75  
76              }
77          }
78          return ret;
79      }
80  
81  
82  
83  }