001 // Java tool interface class DebugToolTool 002 // This file is generated automatically, please do not edit! 003 // generation time: Jun 10, 2004 3:05:13 PM 004 005 package nl.cwi.sen1.tide.tool.support; 006 007 import java.util.HashMap; 008 import java.util.List; 009 import java.util.Map; 010 011 import toolbus.SwingTool; 012 import aterm.ATerm; 013 import aterm.ATermAppl; 014 import aterm.ATermFactory; 015 import aterm.ATermList; 016 017 abstract public class DebugToolTool 018 extends SwingTool 019 implements DebugToolTif 020 { 021 // This table will hold the complete input signature 022 private Map<ATerm, Boolean> sigTable = new HashMap<ATerm, Boolean>(); 023 024 //{{{ Patterns that are used to match against incoming terms 025 026 private ATerm PprocessDestroyed0; 027 private ATerm PadapterDisconnected0; 028 private ATerm Pevent0; 029 private ATerm PprocessCreated0; 030 private ATerm PadapterConnected0; 031 private ATerm PrecAckEvent0; 032 private ATerm PrecTerminate0; 033 034 //}}} 035 036 //{{{ protected DebugToolTool(ATermFactory factory) 037 038 // Mimic the constructor from the AbstractTool class 039 protected DebugToolTool(ATermFactory factory) 040 { 041 super(factory); 042 initSigTable(); 043 initPatterns(); 044 } 045 046 //}}} 047 048 //{{{ private void initSigTable() 049 050 // This method initializes the table with input signatures 051 private void initSigTable() 052 { 053 sigTable.put(factory.parse("rec-terminate(<tide-control>,<term>)"), new Boolean(true)); 054 sigTable.put(factory.parse("rec-ack-event(<debug-tool>,<term>)"), new Boolean(true)); 055 sigTable.put(factory.parse("rec-do(<debug-tool>,adapter-connected(<debug-adapter>))"), new Boolean(true)); 056 sigTable.put(factory.parse("rec-do(<debug-tool>,adapter-disconnected(<debug-adapter>))"), new Boolean(true)); 057 sigTable.put(factory.parse("rec-do(<debug-tool>,process-created(<proc(<debug-adapter>,<int>)>,<str>))"), new Boolean(true)); 058 sigTable.put(factory.parse("rec-do(<debug-tool>,process-destroyed(<proc(<debug-adapter>,<int>)>))"), new Boolean(true)); 059 sigTable.put(factory.parse("rec-do(<debug-tool>,event(<proc(<debug-adapter>,<int>)>,<int>,<term>))"), new Boolean(true)); 060 sigTable.put(factory.parse("rec-terminate(<debug-tool>,<term>)"), new Boolean(true)); 061 sigTable.put(factory.parse("rec-eval(<debug-adapter>,evaluate(<int>,<term>))"), new Boolean(true)); 062 sigTable.put(factory.parse("rec-eval(<debug-adapter>,create-rule(<int>,<term>,<term>,<term>,<term>,<term>))"), new Boolean(true)); 063 sigTable.put(factory.parse("rec-eval(<debug-adapter>,enable-rule(<int>,<int>))"), new Boolean(true)); 064 sigTable.put(factory.parse("rec-eval(<debug-adapter>,disable-rule(<int>,<int>))"), new Boolean(true)); 065 sigTable.put(factory.parse("rec-eval(<debug-adapter>,modify-rule(<int>,<int>,<term>,<term>,<term>,<term>))"), new Boolean(true)); 066 sigTable.put(factory.parse("rec-eval(<debug-adapter>,delete-rule(<int>,<int>))"), new Boolean(true)); 067 sigTable.put(factory.parse("rec-ack-event(<debug-adapter>,<term>)"), new Boolean(true)); 068 sigTable.put(factory.parse("rec-terminate(<debug-adapter>,<term>)"), new Boolean(true)); 069 } 070 071 //}}} 072 //{{{ private void initPatterns() 073 074 // Initialize the patterns that are used to match against incoming terms 075 private void initPatterns() 076 { 077 PprocessDestroyed0 = factory.parse("rec-do(process-destroyed(<term>))"); 078 PadapterDisconnected0 = factory.parse("rec-do(adapter-disconnected(<term>))"); 079 Pevent0 = factory.parse("rec-do(event(<term>,<int>,<term>))"); 080 PprocessCreated0 = factory.parse("rec-do(process-created(<term>,<str>))"); 081 PadapterConnected0 = factory.parse("rec-do(adapter-connected(<term>))"); 082 PrecAckEvent0 = factory.parse("rec-ack-event(<term>)"); 083 PrecTerminate0 = factory.parse("rec-terminate(<term>)"); 084 } 085 086 //}}} 087 088 //{{{ public ATerm handler(ATerm term) 089 090 // The generic handler calls the specific handlers 091 public ATerm handler(ATerm term) 092 { 093 List<?> result; 094 095 result = term.match(PprocessDestroyed0); 096 if (result != null) { 097 processDestroyed((ATerm)result.get(0)); 098 return null; 099 } 100 result = term.match(PadapterDisconnected0); 101 if (result != null) { 102 adapterDisconnected((ATerm)result.get(0)); 103 return null; 104 } 105 result = term.match(Pevent0); 106 if (result != null) { 107 event((ATerm)result.get(0), ((Integer)result.get(1)).intValue(), (ATerm)result.get(2)); 108 return null; 109 } 110 result = term.match(PprocessCreated0); 111 if (result != null) { 112 processCreated((ATerm)result.get(0), (String)result.get(1)); 113 return null; 114 } 115 result = term.match(PadapterConnected0); 116 if (result != null) { 117 adapterConnected((ATerm)result.get(0)); 118 return null; 119 } 120 result = term.match(PrecAckEvent0); 121 if (result != null) { 122 recAckEvent((ATerm)result.get(0)); 123 return null; 124 } 125 result = term.match(PrecTerminate0); 126 if (result != null) { 127 recTerminate((ATerm)result.get(0)); 128 return null; 129 } 130 131 notInInputSignature(term); 132 return null; 133 } 134 135 //}}} 136 //{{{ public void checkInputSignature(ATermList sigs) 137 138 // Check the input signature 139 public void checkInputSignature(ATermList sigs) 140 { 141 while(!sigs.isEmpty()) { 142 ATermAppl sig = (ATermAppl)sigs.getFirst(); 143 sigs = sigs.getNext(); 144 if (!sigTable.containsKey(sig)) { 145 // Sorry, but the term is not in the input signature! 146 notInInputSignature(sig); 147 } 148 } 149 } 150 151 //}}} 152 //{{{ void notInInputSignature(ATerm t) 153 154 // This function is called when an input term 155 // was not in the input signature. 156 void notInInputSignature(ATerm t) 157 { 158 throw new RuntimeException("term not in input signature: "+t); 159 } 160 161 //}}} 162 }