Source Code Cross Referenced for ASTModifiedDefinition.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » sc » parser » 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 » Ajax » Laszlo 4.0.10 » org.openlaszlo.sc.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Parser encapsulation of modifiers for classes, functions
003:         * (private/public/protected/internal/static/final/dynamic/override)
004:         */package org.openlaszlo.sc.parser;
005:
006:        public class ASTModifiedDefinition extends SimpleNode {
007:
008:            public static final String DEFAULT_ACCESS = "<default>";
009:            public static final String PUBLIC_ACCESS = "public";
010:            public static final String PROTECTED_ACCESS = "protected";
011:            public static final String INTERNAL_ACCESS = "internal";
012:            public static final String PRIVATE_ACCESS = "private";
013:
014:            private String access = DEFAULT_ACCESS;
015:            private boolean isStatic = false;
016:            private boolean isFinal = false;
017:            private boolean isDynamic = false;
018:            private boolean isOverride = false;
019:            private String namespace = null;
020:
021:            private Token t;
022:
023:            public ASTModifiedDefinition(int id) {
024:                super (id);
025:            }
026:
027:            public ASTModifiedDefinition(Parser p, int id) {
028:                super (p, id);
029:            }
030:
031:            public static Node jjtCreate(int id) {
032:                return new ASTModifiedDefinition(id);
033:            }
034:
035:            public static Node jjtCreate(Parser p, int id) {
036:                return new ASTModifiedDefinition(p, id);
037:            }
038:
039:            // Token is used for error reporting
040:            public ASTModifiedDefinition setToken(Token t) {
041:                this .t = t;
042:                return this ;
043:            }
044:
045:            public void setNamespace(String value) {
046:                if (access != DEFAULT_ACCESS) {
047:                    throw new ParseException(t, "cannot use namespace \""
048:                            + value + "\" with visibility \"" + access + "\"");
049:                }
050:                if (namespace != null) {
051:                    throw new ParseException(t,
052:                            "cannot set namespace twice: \"" + namespace
053:                                    + "\" and \"" + value + "\"");
054:                }
055:                this .namespace = value;
056:            }
057:
058:            public void setAccess(String value) {
059:                if (access != DEFAULT_ACCESS && value != access) {
060:                    throw new ParseException(t, "access level changed from \""
061:                            + access + "\" to \"" + value + "\"");
062:                }
063:                if (namespace != null) {
064:                    throw new ParseException(t, "cannot use namespace \""
065:                            + namespace + "\" with visibility \"" + value
066:                            + "\"");
067:                }
068:                this .access = value;
069:            }
070:
071:            public String getAccess() {
072:                return this .access;
073:            }
074:
075:            public void setStatic(boolean value) {
076:                isStatic = true;
077:            }
078:
079:            public boolean isStatic() {
080:                return isStatic;
081:            }
082:
083:            public void setFinal(boolean value) {
084:                isFinal = true;
085:            }
086:
087:            public boolean isFinal() {
088:                return isFinal;
089:            }
090:
091:            public void setDynamic(boolean value) {
092:                isDynamic = true;
093:            }
094:
095:            public boolean isDynamic() {
096:                return isDynamic;
097:            }
098:
099:            public void setOverride(boolean value) {
100:                isOverride = true;
101:            }
102:
103:            public boolean isOverride() {
104:                return isOverride;
105:            }
106:
107:            private void verifyVariable(SimpleNode subnode) {
108:                if (isOverride)
109:                    throw new ParseException(
110:                            "cannot use override on variable: " + subnode);
111:                if (isDynamic)
112:                    throw new ParseException("cannot use dynamic on variable: "
113:                            + subnode);
114:            }
115:
116:            private void verifyFunction(SimpleNode subnode) {
117:                if (isDynamic)
118:                    throw new ParseException("cannot use dynamic on variable: "
119:                            + subnode);
120:            }
121:
122:            private void verifyClass(SimpleNode subnode) {
123:                if (isOverride)
124:                    throw new ParseException("cannot use override on class: "
125:                            + subnode);
126:            }
127:
128:            public void verifyTopLevel(SimpleNode subnode) {
129:                if (subnode instanceof  ASTVariableStatement)
130:                    verifyVariable(subnode);
131:                else if (subnode instanceof  ASTFunctionDeclaration)
132:                    verifyFunction(subnode);
133:                else if (subnode instanceof  ASTClassDefinition)
134:                    verifyClass(subnode);
135:                else
136:                    throw new ParseException("unexpected type at top level: "
137:                            + subnode);
138:            }
139:
140:            public void verifyClassLevel(SimpleNode subnode) {
141:                if (subnode instanceof  ASTVariableStatement)
142:                    verifyVariable(subnode);
143:                else if (subnode instanceof  ASTFunctionDeclaration)
144:                    verifyFunction(subnode);
145:                else if (subnode instanceof  ASTClassDefinition)
146:                    throw new ParseException("inner classes not allowed: "
147:                            + subnode);
148:                else
149:                    throw new ParseException("unexpected type at class level: "
150:                            + subnode);
151:            }
152:
153:            public String toJavascriptString() {
154:                String str = namespace;
155:                if (namespace == null) {
156:                    if (access == DEFAULT_ACCESS)
157:                        str = "";
158:                    else
159:                        str = access;
160:                }
161:                if (isStatic)
162:                    str += " static";
163:                if (isDynamic)
164:                    str += " dynamic";
165:                if (isFinal)
166:                    str += " final";
167:                if (isOverride)
168:                    str += " override";
169:
170:                // might be a leading blank if no namespace
171:                if (str.length() > 0 && str.charAt(0) == ' ')
172:                    str = str.substring(1);
173:
174:                return str;
175:            }
176:
177:            public String toString() {
178:                String str = toJavascriptString();
179:                // For clarity, mark the namespace as such,
180:                // it always appears first
181:                if (namespace != null)
182:                    str = "namespace=" + str;
183:                return "ModifiedDefinition(" + str + ")";
184:            }
185:
186:            /** Accept the visitor */
187:            /* TODO: [2007-11-27 dda] Needed when VISITOR=true
188:            public Object jjtAccept(ParserVisitor visitor, Object data) {
189:                return visitor.visit(this, data);
190:            }
191:             */
192:
193:        }
194:
195:        /* J_LZ_COPYRIGHT_BEGIN *******************************************************
196:         * Copyright 2007 Laszlo Systems, Inc.  All Rights Reserved.              *
197:         * Use is subject to license terms.                                            *
198:         * J_LZ_COPYRIGHT_END *********************************************************/
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.