Source Code Cross Referenced for DebugEventHub.java in  » Parser » antlr-3.0.1 » org » antlr » runtime » debug » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Parser » antlr 3.0.1 » org.antlr.runtime.debug 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.antlr.runtime.debug;
002:
003:        import org.antlr.runtime.Token;
004:        import org.antlr.runtime.RecognitionException;
005:
006:        import java.util.List;
007:        import java.util.ArrayList;
008:
009:        /** Broadcast debug events to multiple listeners.  Lets you debug and still
010:         *  use the event mechanism to build parse trees etc...  Not thread-safe.
011:         *  Don't add events in one thread while parser fires events in another.
012:         * 
013:         *  @see also DebugEventRepeater
014:         */
015:        public class DebugEventHub implements  DebugEventListener {
016:            protected List listeners = new ArrayList();
017:
018:            public DebugEventHub(DebugEventListener listener) {
019:                listeners.add(listener);
020:            }
021:
022:            public DebugEventHub(DebugEventListener a, DebugEventListener b) {
023:                listeners.add(a);
024:                listeners.add(b);
025:            }
026:
027:            /** Add another listener to broadcast events too.  Not thread-safe.
028:             *  Don't add events in one thread while parser fires events in another.
029:             */
030:            public void addListener(DebugEventListener listener) {
031:                listeners.add(listeners);
032:            }
033:
034:            /* To avoid a mess like this:
035:            	public void enterRule(final String ruleName) {
036:            		broadcast(new Code(){
037:            			public void exec(DebugEventListener listener) {listener.enterRule(ruleName);}}
038:            			);
039:            	}
040:            	I am dup'ing the for-loop in each.  Where are Java closures!? blech!
041:             */
042:
043:            public void enterRule(String ruleName) {
044:                for (int i = 0; i < listeners.size(); i++) {
045:                    DebugEventListener listener = (DebugEventListener) listeners
046:                            .get(i);
047:                    listener.enterRule(ruleName);
048:                }
049:            }
050:
051:            public void exitRule(String ruleName) {
052:                for (int i = 0; i < listeners.size(); i++) {
053:                    DebugEventListener listener = (DebugEventListener) listeners
054:                            .get(i);
055:                    listener.exitRule(ruleName);
056:                }
057:            }
058:
059:            public void enterAlt(int alt) {
060:                for (int i = 0; i < listeners.size(); i++) {
061:                    DebugEventListener listener = (DebugEventListener) listeners
062:                            .get(i);
063:                    listener.enterAlt(alt);
064:                }
065:            }
066:
067:            public void enterSubRule(int decisionNumber) {
068:                for (int i = 0; i < listeners.size(); i++) {
069:                    DebugEventListener listener = (DebugEventListener) listeners
070:                            .get(i);
071:                    listener.enterSubRule(decisionNumber);
072:                }
073:            }
074:
075:            public void exitSubRule(int decisionNumber) {
076:                for (int i = 0; i < listeners.size(); i++) {
077:                    DebugEventListener listener = (DebugEventListener) listeners
078:                            .get(i);
079:                    listener.exitSubRule(decisionNumber);
080:                }
081:            }
082:
083:            public void enterDecision(int decisionNumber) {
084:                for (int i = 0; i < listeners.size(); i++) {
085:                    DebugEventListener listener = (DebugEventListener) listeners
086:                            .get(i);
087:                    listener.enterDecision(decisionNumber);
088:                }
089:            }
090:
091:            public void exitDecision(int decisionNumber) {
092:                for (int i = 0; i < listeners.size(); i++) {
093:                    DebugEventListener listener = (DebugEventListener) listeners
094:                            .get(i);
095:                    listener.exitDecision(decisionNumber);
096:                }
097:            }
098:
099:            public void location(int line, int pos) {
100:                for (int i = 0; i < listeners.size(); i++) {
101:                    DebugEventListener listener = (DebugEventListener) listeners
102:                            .get(i);
103:                    listener.location(line, pos);
104:                }
105:            }
106:
107:            public void consumeToken(Token token) {
108:                for (int i = 0; i < listeners.size(); i++) {
109:                    DebugEventListener listener = (DebugEventListener) listeners
110:                            .get(i);
111:                    listener.consumeToken(token);
112:                }
113:            }
114:
115:            public void consumeHiddenToken(Token token) {
116:                for (int i = 0; i < listeners.size(); i++) {
117:                    DebugEventListener listener = (DebugEventListener) listeners
118:                            .get(i);
119:                    listener.consumeHiddenToken(token);
120:                }
121:            }
122:
123:            public void LT(int index, Token t) {
124:                for (int i = 0; i < listeners.size(); i++) {
125:                    DebugEventListener listener = (DebugEventListener) listeners
126:                            .get(i);
127:                    listener.LT(index, t);
128:                }
129:            }
130:
131:            public void mark(int index) {
132:                for (int i = 0; i < listeners.size(); i++) {
133:                    DebugEventListener listener = (DebugEventListener) listeners
134:                            .get(i);
135:                    listener.mark(index);
136:                }
137:            }
138:
139:            public void rewind(int index) {
140:                for (int i = 0; i < listeners.size(); i++) {
141:                    DebugEventListener listener = (DebugEventListener) listeners
142:                            .get(i);
143:                    listener.rewind(index);
144:                }
145:            }
146:
147:            public void rewind() {
148:                for (int i = 0; i < listeners.size(); i++) {
149:                    DebugEventListener listener = (DebugEventListener) listeners
150:                            .get(i);
151:                    listener.rewind();
152:                }
153:            }
154:
155:            public void beginBacktrack(int level) {
156:                for (int i = 0; i < listeners.size(); i++) {
157:                    DebugEventListener listener = (DebugEventListener) listeners
158:                            .get(i);
159:                    listener.beginBacktrack(level);
160:                }
161:            }
162:
163:            public void endBacktrack(int level, boolean successful) {
164:                for (int i = 0; i < listeners.size(); i++) {
165:                    DebugEventListener listener = (DebugEventListener) listeners
166:                            .get(i);
167:                    listener.endBacktrack(level, successful);
168:                }
169:            }
170:
171:            public void recognitionException(RecognitionException e) {
172:                for (int i = 0; i < listeners.size(); i++) {
173:                    DebugEventListener listener = (DebugEventListener) listeners
174:                            .get(i);
175:                    listener.recognitionException(e);
176:                }
177:            }
178:
179:            public void beginResync() {
180:                for (int i = 0; i < listeners.size(); i++) {
181:                    DebugEventListener listener = (DebugEventListener) listeners
182:                            .get(i);
183:                    listener.beginResync();
184:                }
185:            }
186:
187:            public void endResync() {
188:                for (int i = 0; i < listeners.size(); i++) {
189:                    DebugEventListener listener = (DebugEventListener) listeners
190:                            .get(i);
191:                    listener.endResync();
192:                }
193:            }
194:
195:            public void semanticPredicate(boolean result, String predicate) {
196:                for (int i = 0; i < listeners.size(); i++) {
197:                    DebugEventListener listener = (DebugEventListener) listeners
198:                            .get(i);
199:                    listener.semanticPredicate(result, predicate);
200:                }
201:            }
202:
203:            public void commence() {
204:                for (int i = 0; i < listeners.size(); i++) {
205:                    DebugEventListener listener = (DebugEventListener) listeners
206:                            .get(i);
207:                    listener.commence();
208:                }
209:            }
210:
211:            public void terminate() {
212:                for (int i = 0; i < listeners.size(); i++) {
213:                    DebugEventListener listener = (DebugEventListener) listeners
214:                            .get(i);
215:                    listener.terminate();
216:                }
217:            }
218:
219:            // Tree parsing stuff
220:
221:            public void consumeNode(Object t) {
222:                for (int i = 0; i < listeners.size(); i++) {
223:                    DebugEventListener listener = (DebugEventListener) listeners
224:                            .get(i);
225:                    listener.consumeNode(t);
226:                }
227:            }
228:
229:            public void LT(int index, Object t) {
230:                for (int i = 0; i < listeners.size(); i++) {
231:                    DebugEventListener listener = (DebugEventListener) listeners
232:                            .get(i);
233:                    listener.LT(index, t);
234:                }
235:            }
236:
237:            // AST Stuff
238:
239:            public void nilNode(Object t) {
240:                for (int i = 0; i < listeners.size(); i++) {
241:                    DebugEventListener listener = (DebugEventListener) listeners
242:                            .get(i);
243:                    listener.nilNode(t);
244:                }
245:            }
246:
247:            public void createNode(Object t) {
248:                for (int i = 0; i < listeners.size(); i++) {
249:                    DebugEventListener listener = (DebugEventListener) listeners
250:                            .get(i);
251:                    listener.createNode(t);
252:                }
253:            }
254:
255:            public void createNode(Object node, Token token) {
256:                for (int i = 0; i < listeners.size(); i++) {
257:                    DebugEventListener listener = (DebugEventListener) listeners
258:                            .get(i);
259:                    listener.createNode(node, token);
260:                }
261:            }
262:
263:            public void becomeRoot(Object newRoot, Object oldRoot) {
264:                for (int i = 0; i < listeners.size(); i++) {
265:                    DebugEventListener listener = (DebugEventListener) listeners
266:                            .get(i);
267:                    listener.becomeRoot(newRoot, oldRoot);
268:                }
269:            }
270:
271:            public void addChild(Object root, Object child) {
272:                for (int i = 0; i < listeners.size(); i++) {
273:                    DebugEventListener listener = (DebugEventListener) listeners
274:                            .get(i);
275:                    listener.addChild(root, child);
276:                }
277:            }
278:
279:            public void setTokenBoundaries(Object t, int tokenStartIndex,
280:                    int tokenStopIndex) {
281:                for (int i = 0; i < listeners.size(); i++) {
282:                    DebugEventListener listener = (DebugEventListener) listeners
283:                            .get(i);
284:                    listener.setTokenBoundaries(t, tokenStartIndex,
285:                            tokenStopIndex);
286:                }
287:            }
288:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.