Source Code Cross Referenced for CompiledExpression.java in  » Scripting » mvel » org » mvel » compiler » 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 » mvel » org.mvel.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * MVEL (The MVFLEX Expression Language)
003:         *
004:         * Copyright (C) 2007 Christopher Brock, MVFLEX/Valhalla Project and the Codehaus
005:         *
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         *
010:         *     http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         *
018:         */package org.mvel.compiler;
019:
020:        import static org.mvel.MVELRuntime.execute;
021:        import org.mvel.ParserContext;
022:        import org.mvel.integration.VariableResolverFactory;
023:        import org.mvel.optimizers.AccessorOptimizer;
024:        import org.mvel.optimizers.OptimizerFactory;
025:        import org.mvel.util.ASTIterator;
026:        import org.mvel.util.ASTLinkedList;
027:        import static org.mvel.util.ParseTools.handleParserEgress;
028:
029:        import java.io.Serializable;
030:
031:        public class CompiledExpression implements  Serializable,
032:                ExecutableStatement {
033:            private ASTIterator tokens;
034:
035:            private Class knownEgressType;
036:            private Class knownIngressType;
037:
038:            private boolean convertableIngressEgress;
039:            private boolean optimized = false;
040:            private boolean importInjectionRequired = false;
041:            private boolean returnBigDecimal = false;
042:            private boolean literalOnly;
043:
044:            private Class<? extends AccessorOptimizer> accessorOptimizer;
045:
046:            private String sourceName;
047:
048:            private ParserContext parserContext;
049:
050:            public CompiledExpression(ASTIterator astMap, String sourceName,
051:                    Class egressType, ParserContext ctx, boolean literalOnly) {
052:                this .tokens = astMap;
053:                this .sourceName = sourceName;
054:                this .knownEgressType = egressType;
055:                this .literalOnly = literalOnly;
056:                setParserContext(ctx);
057:            }
058:
059:            public CompiledExpression(ASTIterator astMap, String sourceName,
060:                    boolean literalOnly) {
061:                this .tokens = astMap;
062:                this .sourceName = sourceName;
063:                this .literalOnly = literalOnly;
064:            }
065:
066:            public ASTIterator getInstructions() {
067:                return new ASTLinkedList(tokens.firstNode(), tokens.size());
068:            }
069:
070:            public void setInstructions(ASTIterator tokens) {
071:                this .tokens = tokens;
072:            }
073:
074:            public Class getKnownEgressType() {
075:                return knownEgressType;
076:            }
077:
078:            public void setKnownEgressType(Class knownEgressType) {
079:                this .knownEgressType = knownEgressType;
080:            }
081:
082:            public Class getKnownIngressType() {
083:                return knownIngressType;
084:            }
085:
086:            public void setKnownIngressType(Class knownIngressType) {
087:                this .knownIngressType = knownIngressType;
088:            }
089:
090:            public boolean isConvertableIngressEgress() {
091:                return convertableIngressEgress;
092:            }
093:
094:            public void setConvertableIngressEgress(
095:                    boolean convertableIngressEgress) {
096:                this .convertableIngressEgress = convertableIngressEgress;
097:            }
098:
099:            public void computeTypeConversionRule() {
100:                if (knownIngressType != null && knownEgressType != null) {
101:                    convertableIngressEgress = knownIngressType
102:                            .isAssignableFrom(knownEgressType);
103:                }
104:            }
105:
106:            public Object getValue(Object ctx, Object elCtx,
107:                    VariableResolverFactory variableFactory) {
108:                if (!optimized)
109:                    setupOptimizers();
110:                return getValue(ctx, variableFactory);
111:            }
112:
113:            public Object getValue(Object staticContext,
114:                    VariableResolverFactory factory) {
115:                if (!optimized)
116:                    setupOptimizers();
117:                return handleParserEgress(execute(false, this , staticContext,
118:                        factory), returnBigDecimal);
119:            }
120:
121:            public Object getDirectValue(Object staticContext,
122:                    VariableResolverFactory factory) {
123:                return execute(false, this , staticContext, factory);
124:            }
125:
126:            private void setupOptimizers() {
127:                if (accessorOptimizer != null)
128:                    OptimizerFactory
129:                            .setThreadAccessorOptimizer(accessorOptimizer);
130:                optimized = true;
131:            }
132:
133:            public ASTIterator getTokenIterator() {
134:                //return new ASTArrayList(tokens);
135:                return tokens;
136:            }
137:
138:            public boolean isOptimized() {
139:                return optimized;
140:            }
141:
142:            public void setOptimized(boolean optimized) {
143:                this .optimized = optimized;
144:            }
145:
146:            public Class<? extends AccessorOptimizer> getAccessorOptimizer() {
147:                return accessorOptimizer;
148:            }
149:
150:            public void setAccessorOptimizer(
151:                    Class<? extends AccessorOptimizer> accessorOptimizer) {
152:                this .accessorOptimizer = accessorOptimizer;
153:            }
154:
155:            public String getSourceName() {
156:                return sourceName;
157:            }
158:
159:            public void setSourceName(String sourceName) {
160:                this .sourceName = sourceName;
161:            }
162:
163:            public boolean intOptimized() {
164:                return false;
165:            }
166:
167:            public ParserContext getParserContext() {
168:                return parserContext;
169:            }
170:
171:            public void setParserContext(ParserContext parserContext) {
172:                if ((this .parserContext = parserContext) != null) {
173:                    this .importInjectionRequired = parserContext.getImports() != null
174:                            && parserContext.getImports().size() != 0;
175:                }
176:            }
177:
178:            public boolean isReturnBigDecimal() {
179:                return returnBigDecimal;
180:            }
181:
182:            public void setReturnBigDecimal(boolean returnBigDecimal) {
183:                this .returnBigDecimal = returnBigDecimal;
184:            }
185:
186:            public boolean isImportInjectionRequired() {
187:                return importInjectionRequired;
188:            }
189:
190:            public void setImportInjectionRequired(
191:                    boolean importInjectionRequired) {
192:                this .importInjectionRequired = importInjectionRequired;
193:            }
194:
195:            public Object setValue(Object ctx, Object elCtx,
196:                    VariableResolverFactory variableFactory, Object value) {
197:                return null;
198:            }
199:
200:            public boolean isLiteralOnly() {
201:                return literalOnly;
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.