Source Code Cross Referenced for GroovySourceAST.java in  » Scripting » groovy-1.0 » org » codehaus » groovy » antlr » 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 » Scripting » groovy 1.0 » org.codehaus.groovy.antlr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.codehaus.groovy.antlr;
002:
003:        import antlr.collections.AST;
004:        import antlr.*;
005:
006:        import java.util.List;
007:        import java.util.ArrayList;
008:
009:        /**
010:         * We have an AST subclass so we can track source information.
011:         * Very odd that ANTLR doesn't do this by default.
012:         *
013:         * @author Mike Spille
014:         * @author Jeremy Rayner <groovy@ross-rayner.com>
015:         */
016:        public class GroovySourceAST extends CommonAST implements  Comparable {
017:            private int line;
018:            private int col;
019:            private int lineLast;
020:            private int colLast;
021:            private String snippet;
022:
023:            public GroovySourceAST() {
024:            }
025:
026:            public GroovySourceAST(Token t) {
027:                super (t);
028:            }
029:
030:            public void initialize(AST ast) {
031:                super .initialize(ast);
032:                line = ast.getLine();
033:                col = ast.getColumn();
034:            }
035:
036:            public void initialize(Token t) {
037:                super .initialize(t);
038:                line = t.getLine();
039:                col = t.getColumn();
040:            }
041:
042:            public void setLast(Token last) {
043:                lineLast = last.getLine();
044:                colLast = last.getColumn();
045:            }
046:
047:            public int getLineLast() {
048:                return lineLast;
049:            }
050:
051:            public void setLineLast(int lineLast) {
052:                this .lineLast = lineLast;
053:            }
054:
055:            public int getColumnLast() {
056:                return colLast;
057:            }
058:
059:            public void setColumnLast(int colLast) {
060:                this .colLast = colLast;
061:            }
062:
063:            public void setLine(int line) {
064:                this .line = line;
065:            }
066:
067:            public int getLine() {
068:                return (line);
069:            }
070:
071:            public void setColumn(int column) {
072:                this .col = column;
073:            }
074:
075:            public int getColumn() {
076:                return (col);
077:            }
078:
079:            public void setSnippet(String snippet) {
080:                this .snippet = snippet;
081:            }
082:
083:            public String getSnippet() {
084:                return snippet;
085:            }
086:
087:            public int compareTo(Object object) {
088:                if (object == null) {
089:                    return 0;
090:                }
091:                if (!(object instanceof  AST)) {
092:                    return 0;
093:                }
094:                AST that = (AST) object;
095:
096:                // todo - possibly check for line/col with values of 0 or less...
097:
098:                if (this .getLine() < that.getLine()) {
099:                    return -1;
100:                }
101:                if (this .getLine() > that.getLine()) {
102:                    return 1;
103:                }
104:
105:                if (this .getColumn() < that.getColumn()) {
106:                    return -1;
107:                }
108:                if (this .getColumn() > that.getColumn()) {
109:                    return 1;
110:                }
111:
112:                return 0;
113:            }
114:
115:            public GroovySourceAST childAt(int position) {
116:                List list = new ArrayList();
117:                AST child = this .getFirstChild();
118:                while (child != null) {
119:                    list.add(child);
120:                    child = child.getNextSibling();
121:                }
122:                try {
123:                    return (GroovySourceAST) list.get(position);
124:                } catch (IndexOutOfBoundsException e) {
125:                    return null;
126:                }
127:            }
128:
129:            public GroovySourceAST childOfType(int type) {
130:                AST child = this .getFirstChild();
131:                while (child != null) {
132:                    if (child.getType() == type) {
133:                        return (GroovySourceAST) child;
134:                    }
135:                    child = child.getNextSibling();
136:                }
137:                return null;
138:            }
139:
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.