001 package nl.cwi.sen1.visplugin; 002 003 // Java tool interface class VisualizationPluginTool 004 // This file is generated automatically, please do not edit! 005 // generation time: Mar 14, 2007 12:48:38 PM 006 007 008 import java.util.HashSet; 009 import java.util.List; 010 import java.util.Set; 011 012 import toolbus.AbstractTool; 013 014 import aterm.ATerm; 015 import aterm.ATermAppl; 016 import aterm.ATermFactory; 017 import aterm.ATermList; 018 019 abstract public class VisualizationPluginTool 020 extends AbstractTool 021 implements VisualizationPluginTif 022 { 023 // This table will hold the complete input signature 024 private Set<ATerm> sigTable = new HashSet<ATerm>(); 025 026 // Patterns that are used to match against incoming terms 027 private ATerm PvpFileDialogResult0; 028 private ATerm PvpVisualizeFact0; 029 private ATerm PvpRstoreUnloaded0; 030 private ATerm PvpFileDialogCancel0; 031 private ATerm PvpFactOutOfDate0; 032 private ATerm PvpGetName0; 033 private ATerm PvpIsTypeSupported0; 034 private ATerm PrecAckEvent0; 035 private ATerm PrecTerminate0; 036 037 // Mimic the constructor from the AbstractTool class 038 protected VisualizationPluginTool(ATermFactory factory) 039 { 040 super(factory); 041 initSigTable(); 042 initPatterns(); 043 } 044 045 // This method initializes the table with input signatures 046 private void initSigTable() 047 { 048 sigTable.add(factory.parse("rec-eval(<visualizationPlugin>,vp-get-name)")); 049 sigTable.add(factory.parse("rec-eval(<visualizationPlugin>,vp-is-type-supported(<term>))")); 050 sigTable.add(factory.parse("rec-do(<visualizationPlugin>,vp-visualize-fact(<int>,<int>,<term>))")); 051 sigTable.add(factory.parse("rec-do(<visualizationPlugin>,vp-fact-out-of-date(<int>,<int>))")); 052 sigTable.add(factory.parse("rec-ack-event(<visualizationPlugin>,<term>)")); 053 sigTable.add(factory.parse("rec-do(<visualizationPlugin>,vp-file-dialog-result(<int>,<str>))")); 054 sigTable.add(factory.parse("rec-do(<visualizationPlugin>,vp-file-dialog-cancel(<int>))")); 055 sigTable.add(factory.parse("rec-do(<visualizationPlugin>,vp-rstore-unloaded(<int>))")); 056 sigTable.add(factory.parse("rec-terminate(<visualizationPlugin>,<term>)")); 057 } 058 059 // Initialize the patterns that are used to match against incoming terms 060 private void initPatterns() 061 { 062 PvpFileDialogResult0 = factory.parse("rec-do(vp-file-dialog-result(<int>,<str>))"); 063 PvpVisualizeFact0 = factory.parse("rec-do(vp-visualize-fact(<int>,<int>,<term>))"); 064 PvpRstoreUnloaded0 = factory.parse("rec-do(vp-rstore-unloaded(<int>))"); 065 PvpFileDialogCancel0 = factory.parse("rec-do(vp-file-dialog-cancel(<int>))"); 066 PvpFactOutOfDate0 = factory.parse("rec-do(vp-fact-out-of-date(<int>,<int>))"); 067 PvpGetName0 = factory.parse("rec-eval(vp-get-name)"); 068 PvpIsTypeSupported0 = factory.parse("rec-eval(vp-is-type-supported(<term>))"); 069 PrecAckEvent0 = factory.parse("rec-ack-event(<term>)"); 070 PrecTerminate0 = factory.parse("rec-terminate(<term>)"); 071 } 072 073 // The generic handler calls the specific handlers 074 public ATerm handler(ATerm term) 075 { 076 List<?> result; 077 078 result = term.match(PvpFileDialogResult0); 079 if (result != null) { 080 vpFileDialogResult(((Integer)result.get(0)).intValue(), (String)result.get(1)); 081 return null; 082 } 083 result = term.match(PvpVisualizeFact0); 084 if (result != null) { 085 vpVisualizeFact(((Integer)result.get(0)).intValue(), ((Integer)result.get(1)).intValue(), (ATerm)result.get(2)); 086 return null; 087 } 088 result = term.match(PvpRstoreUnloaded0); 089 if (result != null) { 090 vpRstoreUnloaded(((Integer)result.get(0)).intValue()); 091 return null; 092 } 093 result = term.match(PvpFileDialogCancel0); 094 if (result != null) { 095 vpFileDialogCancel(((Integer)result.get(0)).intValue()); 096 return null; 097 } 098 result = term.match(PvpFactOutOfDate0); 099 if (result != null) { 100 vpFactOutOfDate(((Integer)result.get(0)).intValue(), ((Integer)result.get(1)).intValue()); 101 return null; 102 } 103 result = term.match(PvpGetName0); 104 if (result != null) { 105 return vpGetName(); 106 } 107 result = term.match(PvpIsTypeSupported0); 108 if (result != null) { 109 return vpIsTypeSupported((ATerm)result.get(0)); 110 } 111 result = term.match(PrecAckEvent0); 112 if (result != null) { 113 recAckEvent((ATerm)result.get(0)); 114 return null; 115 } 116 result = term.match(PrecTerminate0); 117 if (result != null) { 118 recTerminate((ATerm)result.get(0)); 119 return null; 120 } 121 122 notInInputSignature(term); 123 return null; 124 } 125 126 // Check the input signature 127 public void checkInputSignature(ATermList sigs) 128 { 129 while(!sigs.isEmpty()) { 130 ATermAppl sig = (ATermAppl)sigs.getFirst(); 131 sigs = sigs.getNext(); 132 if (!sigTable.contains(sig)) { 133 // Sorry, but the term is not in the input signature! 134 notInInputSignature(sig); 135 } 136 } 137 } 138 139 // This function is called when an input term 140 // was not in the input signature. 141 void notInInputSignature(ATerm t) 142 { 143 throw new RuntimeException("term not in input signature: " + t); 144 } 145 }