public String getSection(String sectionName) { return sections.get(sectionName); }
public Iterator<BenkoBoxDescription> iterator() { return benkoBoxes.iterator(); }
- public ShipDescription(BufferedReader r) throws IOException {
- String sectionName = "";
+ public ShipDescription(String name, BufferedReader r) throws IOException {
+ if (name.endsWith(".ship"))
+ name = name.substring(0, name.length() - ".ship".length());
+ while(name.indexOf('/') != -1) name = name.substring(name.indexOf('/')+1);
+ this.name = name;
+ String sectionName = null;
StringBuffer sb = new StringBuffer();
while(true) {
String s = r.readLine();
- if (s==null) break;
- if (s.startsWith("==")) {
- sections.put(sectionName, sb.toString());
+ if (s==null || s.startsWith("==")) {
+ if (sectionName != null) sections.put(sectionName, sb.toString());
+ if (s==null) break;
sb = new StringBuffer();
sectionName = s.trim();
while(sectionName.startsWith("="))
private HashMap<String,String> sections = new HashMap<String,String>();
+ // FIXME
+ public HashMap<String,Constant> constants = new HashMap<String,Constant>();
+
+ public Constant getConstant(String name) {
+ return constants.get(name);
+ }
+
private void processSection(String section) throws IOException {
if (section.equals("")) {
BufferedReader br = new BufferedReader(new StringReader(sections.get(section)));
if (key.toLowerCase().equals("ship"))
name = val.trim();
}
+ } else if (section.equals("constants")) {
+ BufferedReader br = new BufferedReader(new StringReader(sections.get(section)));
+ for(String s = br.readLine(); s != null; s = br.readLine()) {
+ if (s.indexOf(':')==-1) continue;
+ String key = s.substring(0, s.indexOf(':')).trim();
+ if (key.startsWith("constant")) {
+ String constname = key.substring("constant".length()+1).trim();
+ String val = s.substring(s.indexOf(':')+1).trim();
+ constants.put(constname, new Constant(val));
+ }
+ }
} else if (section.equals("ports")) {
BufferedReader br = new BufferedReader(new StringReader(sections.get(section)));
boolean rightSide = false;
else if (key.equals("in")) { tokenOnly = false; inbox = true; }
else if (key.equals("out")) { tokenOnly = false; inbox = false; }
else if (key.startsWith("constant")) {
+ String constname = key.substring("constant".length()+1).trim();
+ String val = s.substring(s.indexOf(':')+1).trim();
+ p.constants.put(constname, new Constant(val));
continue;
} else if (key.startsWith("shortcut to")) {
continue;
}
void add(BenkoBoxDescription b) { benkoBoxes.add(b); }
-
}
\ No newline at end of file