7b689ac9e5b9e0e53fa28138c64640fbba800af5
[fleet.git] / src / edu / berkeley / fleet / doc / BenkoBoxDescription.java
1 package edu.berkeley.fleet.doc;
2
3 import java.io.*;
4 import java.util.*;
5
6 public class BenkoBoxDescription implements Iterable<String> {
7
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(); }
14
15     // private //////////////////////////////////////////////////////////////////////////////
16
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>();
23
24     // FIXME
25     public HashMap<String,Constant> constants = new HashMap<String,Constant>();
26
27     BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox) {
28         this(ship, name, tokenOnly, inbox, null);
29     }
30     BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox, String shortcut) {
31         this.ship = ship;
32         this.name = name;
33         this.inbox = inbox;
34         this.tokenOnly = tokenOnly;
35         this.shortcut = shortcut;
36         ship.add(this);
37     }
38
39     void addDest(String dest) { destinations.add(dest); }
40
41
42     public Constant getConstant(String name) {
43         Constant ret = constants.get(name);
44         if (ret == null) ret = ship.getConstant(name);
45         return ret;
46     }
47 }