Source Code Cross Referenced for Rule.java in  » Database-ORM » toplink » persistence » antlr » preprocessor » 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 » Database ORM » toplink » persistence.antlr.preprocessor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package persistence.antlr.preprocessor;
002:
003:        /* ANTLR Translator Generator
004:         * Project led by Terence Parr at http://www.jGuru.com
005:         * Software rights: http://www.antlr.org/license.html
006:         *
007:         */
008:
009:        import persistence.antlr.collections.impl.IndexedVector;
010:
011:        import java.util.Hashtable;
012:        import java.util.Enumeration;
013:
014:        class Rule {
015:            protected String name;
016:            protected String block;
017:            protected String args;
018:            protected String returnValue;
019:            protected String throwsSpec;
020:            protected String initAction;
021:            protected IndexedVector options;
022:            protected String visibility;
023:            protected Grammar enclosingGrammar;
024:            protected boolean bang = false;
025:
026:            public Rule(String n, String b, IndexedVector options, Grammar gr) {
027:                name = n;
028:                block = b;
029:                this .options = options;
030:                setEnclosingGrammar(gr);
031:            }
032:
033:            public String getArgs() {
034:                return args;
035:            }
036:
037:            public boolean getBang() {
038:                return bang;
039:            }
040:
041:            public String getName() {
042:                return name;
043:            }
044:
045:            public String getReturnValue() {
046:                return returnValue;
047:            }
048:
049:            public String getVisibility() {
050:                return visibility;
051:            }
052:
053:            /** If 'rule' narrows the visible of 'this', return true;
054:             *  For example, 'this' is public and 'rule' is private,
055:             *  true is returned.  You cannot narrow the vis. of
056:             *  a rule.
057:             */
058:            public boolean narrowerVisibility(Rule rule) {
059:                if (visibility.equals("public")) {
060:                    if (!rule.equals("public")) {
061:                        return true; // everything narrower than public
062:                    }
063:                    return false;
064:                } else if (visibility.equals("protected")) {
065:                    if (rule.equals("private")) {
066:                        return true; // private narrower than protected
067:                    }
068:                    return false;
069:                } else if (visibility.equals("private")) {
070:                    return false; // nothing is narrower than private
071:                }
072:                return false;
073:            }
074:
075:            /** Two rules have the same signature if they have:
076:             *  	same name
077:             *		same return value
078:             *		same args
079:             *	I do a simple string compare now, but later
080:             *	the type could be pulled out so it is insensitive
081:             *	to names of args etc...
082:             */
083:            public boolean sameSignature(Rule rule) {
084:                boolean nSame = true;
085:                boolean aSame = true;
086:                boolean rSame = true;
087:
088:                nSame = name.equals(rule.getName());
089:                if (args != null) {
090:                    aSame = args.equals(rule.getArgs());
091:                }
092:                if (returnValue != null) {
093:                    rSame = returnValue.equals(rule.getReturnValue());
094:                }
095:                return nSame && aSame && rSame;
096:            }
097:
098:            public void setArgs(String a) {
099:                args = a;
100:            }
101:
102:            public void setBang() {
103:                bang = true;
104:            }
105:
106:            public void setEnclosingGrammar(Grammar g) {
107:                enclosingGrammar = g;
108:            }
109:
110:            public void setInitAction(String a) {
111:                initAction = a;
112:            }
113:
114:            public void setOptions(IndexedVector options) {
115:                this .options = options;
116:            }
117:
118:            public void setReturnValue(String ret) {
119:                returnValue = ret;
120:            }
121:
122:            public void setThrowsSpec(String t) {
123:                throwsSpec = t;
124:            }
125:
126:            public void setVisibility(String v) {
127:                visibility = v;
128:            }
129:
130:            public String toString() {
131:                String s = "";
132:                String retString = returnValue == null ? "" : "returns "
133:                        + returnValue;
134:                String argString = args == null ? "" : args;
135:                String bang = getBang() ? "!" : "";
136:
137:                s += visibility == null ? "" : visibility + " ";
138:                s += name + bang + argString + " " + retString + throwsSpec;
139:                if (options != null) {
140:                    s += System.getProperty("line.separator") + "options {"
141:                            + System.getProperty("line.separator");
142:                    for (Enumeration e = options.elements(); e
143:                            .hasMoreElements();) {
144:                        s += (Option) e.nextElement()
145:                                + System.getProperty("line.separator");
146:                    }
147:                    s += "}" + System.getProperty("line.separator");
148:                }
149:                if (initAction != null) {
150:                    s += initAction + System.getProperty("line.separator");
151:                }
152:                s += block;
153:                return s;
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.