Source Code Cross Referenced for ASTLiteral.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 support for literals
003:         */package org.openlaszlo.sc.parser;
004:
005:        public class ASTLiteral extends SimpleNode {
006:
007:            private Object mValue = null;
008:
009:            public ASTLiteral(int id) {
010:                super (id);
011:            }
012:
013:            public ASTLiteral(Parser p, int id) {
014:                super (p, id);
015:            }
016:
017:            public static Node jjtCreate(int id) {
018:                return new ASTLiteral(id);
019:            }
020:
021:            public static Node jjtCreate(Parser p, int id) {
022:                return new ASTLiteral(p, id);
023:            }
024:
025:            // Added
026:            public ASTLiteral(Object value) {
027:                mValue = value;
028:            }
029:
030:            public Object getValue() {
031:                return mValue;
032:            }
033:
034:            static final int hexval(char c) {
035:                switch (c) {
036:                case '0':
037:                    return 0;
038:                case '1':
039:                    return 1;
040:                case '2':
041:                    return 2;
042:                case '3':
043:                    return 3;
044:                case '4':
045:                    return 4;
046:                case '5':
047:                    return 5;
048:                case '6':
049:                    return 6;
050:                case '7':
051:                    return 7;
052:                case '8':
053:                    return 8;
054:                case '9':
055:                    return 9;
056:
057:                case 'a':
058:                case 'A':
059:                    return 10;
060:                case 'b':
061:                case 'B':
062:                    return 11;
063:                case 'c':
064:                case 'C':
065:                    return 12;
066:                case 'd':
067:                case 'D':
068:                    return 13;
069:                case 'e':
070:                case 'E':
071:                    return 14;
072:                case 'f':
073:                case 'F':
074:                    return 15;
075:                }
076:
077:                throw new RuntimeException("Illegal hex or unicode constant");
078:                // Should never come here
079:            }
080:
081:            static final int octval(char c) {
082:                switch (c) {
083:                case '0':
084:                    return 0;
085:                case '1':
086:                    return 1;
087:                case '2':
088:                    return 2;
089:                case '3':
090:                    return 3;
091:                case '4':
092:                    return 4;
093:                case '5':
094:                    return 5;
095:                case '6':
096:                    return 6;
097:                case '7':
098:                    return 7;
099:                }
100:
101:                throw new RuntimeException("Illegal octal constant");
102:                // Should never come here
103:            }
104:
105:            public void setStringValue(String image) {
106:                int l = image.length();
107:                StringBuffer sb = new StringBuffer(l);
108:                for (int i = 0; i < l; i++) {
109:                    char c = image.charAt(i);
110:                    if ((c == '\\') && (i + 1 < l)) {
111:                        i++;
112:                        c = image.charAt(i);
113:                        if (c == 'n')
114:                            c = '\n';
115:                        else if (c == 'b')
116:                            c = '\b';
117:                        else if (c == 'f')
118:                            c = '\f';
119:                        else if (c == 'r')
120:                            c = '\r';
121:                        else if (c == 't')
122:                            c = '\t';
123:                        else if (c == 'v')
124:                            c = '\u000B';
125:                        else if (c == 'x') {
126:                            c = (char) (hexval(image.charAt(i + 1)) << 4 | hexval(image
127:                                    .charAt(i + 2)));
128:                            i += 2;
129:                        } else if (c == 'u') {
130:                            c = (char) (hexval(image.charAt(i + 1)) << 12
131:                                    | hexval(image.charAt(i + 2)) << 8
132:                                    | hexval(image.charAt(i + 3)) << 4 | hexval(image
133:                                    .charAt(i + 4)));
134:                            i += 4;
135:                        } else if (c >= '0' && c <= '7') {
136:                            // Accepts anything from 0 - 377
137:                            c = (char) (octval(image.charAt(i)));
138:                            i++;
139:                            for (int j = i + ((int) c <= 3 ? 2 : 1); (i < j)
140:                                    && (i < l) && (image.charAt(i) >= '0')
141:                                    && (image.charAt(i) <= '7'); i++) {
142:                                c = (char) ((c << 3) | octval(image.charAt(i)));
143:                            }
144:                        }
145:                    }
146:                    sb.append(c);
147:                }
148:                mValue = sb.toString();
149:            }
150:
151:            public void setRegexpValue(String image) {
152:                mValue = "" + image;
153:            }
154:
155:            public void setDecimalValue(String image) {
156:                try {
157:                    mValue = new Long(Long.parseLong(image));
158:                } catch (NumberFormatException e) {
159:                    mValue = new Double(image);
160:                }
161:            }
162:
163:            public void setOctalValue(String image) {
164:                try {
165:                    String imageWithout0 = image.substring(1);
166:                    mValue = new Long(Long.parseLong(imageWithout0, 8));
167:                } catch (NumberFormatException e) {
168:                    mValue = new Double(image);
169:                }
170:            }
171:
172:            public void setHexValue(String image) {
173:                try {
174:                    String imageWithout0x = image.substring(2);
175:                    mValue = new Long(Long.parseLong(imageWithout0x, 16));
176:                } catch (NumberFormatException e) {
177:                    mValue = new Double(image);
178:                }
179:            }
180:
181:            public void setFloatingPointValue(String image) {
182:                mValue = new Double(image);
183:            }
184:
185:            public void setBooleanValue(boolean value) {
186:                mValue = new Boolean(value);
187:            }
188:
189:            public void setNullValue() {
190:                mValue = null;
191:            }
192:
193:            public String toString() {
194:                if (mValue == null) {
195:                    return "null";
196:                }
197:                return "Literal(" + mValue.toString() + ")";
198:            }
199:
200:        }
201:
202:        /* J_LZ_COPYRIGHT_BEGIN *******************************************************
203:         * Copyright 2001-2006 Laszlo Systems, Inc.  All Rights Reserved.              *
204:         * Use is subject to license terms.                                            *
205:         * 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.