1 package edu.berkeley.fleet.doc;
6 public class BenkoBoxDescription implements Iterable<String> {
8 public String getName() { return name; }
9 public boolean isInbox() { return inbox; }
10 public boolean isOutbox() { return !inbox; }
11 public boolean tokensOnly() { return tokenOnly; }
12 public String getShortcut() { return shortcut; }
13 public Iterator<String> iterator() { return destinations.iterator(); }
15 // private //////////////////////////////////////////////////////////////////////////////
17 private final ShipDescription ship;
18 private final String shortcut;
19 private final String name;
20 private final boolean inbox;
21 private final boolean tokenOnly;
22 private ArrayList<String> destinations = new ArrayList<String>();
25 public HashMap<String,Constant> constants = new HashMap<String,Constant>();
27 BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox) {
28 this(ship, name, tokenOnly, inbox, null);
30 BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox, String shortcut) {
34 this.tokenOnly = tokenOnly;
35 this.shortcut = shortcut;
39 void addDest(String dest) { destinations.add(dest); }
41 public Constant getConstant(String name) {
42 Constant ret = constants.get(name);
43 if (ret == null) ret = ship.getConstant(name);
47 public long resolveLiteral(String s) {
50 if (s.indexOf('=') != -1) {
51 val = Long.parseLong(s.substring(s.indexOf('=')+1));
52 s = s.substring(0, s.indexOf('='));
54 Constant c = getConstant(s);
55 if (c==null) throw new RuntimeException("no constant " + s + " on benkobox " + this);