1 6 7 package org.netbeans.modules.piaget.analyze; 8 9 import java.io.StreamTokenizer ; 10 import java.io.File ; 11 12 25 public abstract class TCRParser extends Parser { 26 27 boolean editor; 28 29 30 public TCRParser(File f) { 31 super(f); 32 } 33 34 protected void analyzeTokenInput() throws SyntaxException{ 35 nextLONG(); 36 timestamp = scanner.lval; 37 caseProperty(); 38 } 39 40 private void caseProperty() throws SyntaxException{ 41 nextWORD(); 42 if(svalIs("opened")){ 43 caseOpenClose(); 44 } else if(svalIs("activated")){ 45 String s=caseWindow(); 46 if(s!=null)analyzeActivated(s,editor); 47 } else if(svalIs("activatedNodes")){ 48 caseNodes(); 49 } else if(svalIs("NBGAINEDFOCUS")){ 50 analyzeGAINED(); 51 } else if(svalIs("NBLOSTFOCUS")){ 52 analyzeLOST(); 53 } else { 54 throw(new SyntaxException("skipped: "+scanner.sval)); 55 } 56 } 57 58 private void caseOpenClose() throws SyntaxException{ 59 String s; 60 nextWORD(); 61 if(svalIs("opening")){ 62 s=caseWindow(); 63 analyzeOpen(s,editor); 64 } else if(svalIs("closing")){ 65 s=caseWindow(); 66 analyzeClose(s,editor); 67 } else if(svalIs("exception")){ 68 throw(new SyntaxException("")); 69 } else { 70 throw(new SyntaxException("unexpected token open/close:"+scanner.sval)); 71 } 72 } 73 74 private String caseWindow() throws SyntaxException{ 75 nextWORD(); 76 if(svalIs("editor")){ 77 editor=true; 78 nextWORD(); 79 } else editor=false; 80 return scanner.sval; 81 } 82 83 private void caseNodes() throws SyntaxException{ 84 String p,s; 85 nextWORD(); 86 while(scanner.lastReturned==WORD){ 87 if(!svalIs("parent")) throw(new SyntaxException("no parent "+scanner.sval)); 88 nextWORD(); 89 p=scanner.sval; 90 nextWORD(); 91 if(!svalIs("node"))throw(new SyntaxException("node name not found")); 92 nextWORD(); 93 s=scanner.sval; 94 analyzeNode(p,s); 95 next(); 96 } 97 scanner.pushBack(); 99 } 100 101 102 105 abstract protected void eof(); 106 107 110 abstract protected void init(); 111 112 abstract protected void analyzeNode(String parent, String node); 113 114 abstract protected void analyzeOpen(String windowId, boolean editor); 115 116 abstract protected void analyzeClose(String windowId , boolean editor); 117 118 abstract protected void analyzeActivated(String windowId, boolean editor); 119 120 abstract protected void analyzeGAINED(); 121 122 abstract protected void analyzeLOST(); 123 124 } 125 | Popular Tags |