data in: in3
data out: out1
+ shortcut to: in1
data out: out2
+ shortcut to: in2
+data out: out3
+ shortcut to: in3
== Constants ========================================================
== TeX ==============================================================
== Ports ===========================================================
in: inEnqueue
+
in: inEnqueueOp
constant rev: .......................1.............
constant inv: ........................1............
out: outDequeue
in: inDequeueOp
+== Sample Code ======================================================
+
+
== Constants ========================================================
== TeX ==============================================================
/** default implementation: the empty string */
public String getDestinationName() { return ""; }
+ /** return the BenkoBox which is the destination of this Box's shortcut (if any) */
+ public BenkoBox getShortcut() { return null; }
+
}
public boolean isInbox() { return inbox; }
public boolean isOutbox() { return !inbox; }
public boolean tokensOnly() { return tokenOnly; }
+ public String getShortcut() { return shortcut; }
public Iterator<String> iterator() { return destinations.iterator(); }
// private //////////////////////////////////////////////////////////////////////////////
private final ShipDescription ship;
+ private final String shortcut;
private final String name;
private final boolean inbox;
private final boolean tokenOnly;
private ArrayList<String> destinations = new ArrayList<String>();
BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox) {
+ this(ship, name, tokenOnly, inbox, null);
+ }
+ BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox, String shortcut) {
this.ship = ship;
this.name = name;
this.inbox = inbox;
this.tokenOnly = tokenOnly;
+ this.shortcut = shortcut;
ship.add(this);
}
} else if (section.equals("ports")) {
BufferedReader br = new BufferedReader(new StringReader(sections.get(section)));
boolean rightSide = false;
+ BenkoBoxDescription p = null;
for(String s = br.readLine(); s != null; s = br.readLine()) {
if (s.trim().length()==0) { rightSide = true; continue; }
else if (key.equals("out")) { tokenOnly = false; inbox = false; }
else if (key.startsWith("constant")) {
continue;
+ } else if (key.startsWith("shortcut to")) {
+ continue;
}
else throw new RuntimeException("unknown port type: \""+key+"\"");
- BenkoBoxDescription p = null;
+ p = null;
String val = s.substring(s.indexOf(':')+1).trim();
String boxname = val.indexOf('.') != -1 ? val.substring(0, val.indexOf('.')) : val;
String dest = val.indexOf('.') != -1 ? val.substring(val.indexOf('.')+1) : "";