Source Code Cross Referenced for Expressions.java in  » Ajax » zk » org » zkoss » xel » 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 » zk » org.zkoss.xel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Expressions.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Thu Aug 30 11:09:33     2007, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2007 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:        package org.zkoss.xel;
020:
021:        import java.util.Collection;
022:        import java.util.Collections;
023:
024:        import org.zkoss.lang.Classes;
025:        import org.zkoss.util.logging.Log;
026:
027:        /**
028:         * Utilities to use XEL.
029:         *
030:         * @author tomyeh
031:         * @since 3.0.0
032:         */
033:        public class Expressions {
034:            private static final Log log = Log.lookup(Expressions.class);
035:
036:            /** An empty function mapper, i.e., it has no function defined at all.
037:             * It is serializable.
038:             */
039:            public static final FunctionMapper EMPTY_MAPPER = new EmptyMapper();
040:            /** An empty variable resolver, i.e., it has no variable defined at all.
041:             * It is serializable.
042:             */
043:            public static final VariableResolver EMPTY_RESOLVER = new EmptyResolver();
044:
045:            /** An dummy expression that does nothing.
046:             * It is usually used as a flag to denote exceptional cases.
047:             * It it serializable.
048:             */
049:            public static final Expression DUMMY_EXPRESSION = new DummyExpr();
050:
051:            /** The implemetation of {@link ExpressionFactory}. */
052:            private static Class _expfcls;
053:
054:            /** Instantiates an instance of {@link ExpressionFactory}.
055:             *
056:             * <p>The default class is {@link org.zkoss.xel.el.ELFactory}.
057:             * To override it, you can specify the class by calling
058:             * {@link #setExpressionFactoryClass}.
059:             *
060:             * <p>For the ZK user, you can override it with zk.xml
061:             * or org.zkoss.zk.ui.util.Configuration.
062:             *
063:             * @exception XelException if the specified class failed to load,
064:             * or instantiate.
065:             */
066:            public static final ExpressionFactory newExpressionFactory()
067:                    throws XelException {
068:                return newExpressionFactory(_expfcls);
069:            }
070:
071:            /** Instantiates an instance of {@link ExpressionFactory}.
072:             *
073:             * <p>The default class is {@link org.zkoss.xel.el.ELFactory}.
074:             * To override it, you can specify the class by calling
075:             * {@link #setExpressionFactoryClass}.
076:             *
077:             * <p>For the ZK user, you can override it with zk.xml
078:             * or org.zkoss.zk.ui.util.Configuration.
079:             *
080:             * @param expfcls the class that implements {@link ExpressionFactory},
081:             * or null to use the default.
082:             * @exception XelException if the specified class failed to load,
083:             * or instantiate.
084:             */
085:            public static final ExpressionFactory newExpressionFactory(
086:                    Class expfcls) {
087:                if (expfcls != null) {
088:                    try {
089:                        return (ExpressionFactory) expfcls.newInstance();
090:                    } catch (Throwable ex) {
091:                        throw XelException.Aide.wrap(ex,
092:                                "Unable to instantiate " + expfcls);
093:                    }
094:                }
095:                return newDefautFactory();
096:            }
097:
098:            private static final ExpressionFactory newDefautFactory() {
099:                return new org.zkoss.xel.el.ELFactory();
100:            }
101:
102:            /** Evaluates an expression.
103:             *
104:             * @param ctx the context information to evaluate the expression
105:             * It can be null, in which case no functions are supported for this
106:             * invocation.
107:             * @param expression the expression to be evaluated.
108:             * Note: the expression is enclosed
109:             * with ${ and }, regardingless what implemetnation is used.
110:             * @param expectedType the expected type of the result of the evaluation
111:             */
112:            public static final Object evaluate(XelContext ctx,
113:                    String expression, Class expectedType) throws XelException {
114:                return newExpressionFactory().evaluate(ctx, expression,
115:                        expectedType);
116:            }
117:
118:            /** Sets the implementation of the expression factory that shall
119:             * be used by the whole system, or null to use the system default.
120:             *
121:             * <p>Default: null - it means {@link org.zkoss.xel.el.ELFactory}.
122:             *
123:             * <p>Note: you can only specify an implementation that is compatible
124:             * with JSP EL here, since all builtin pages depend on it.
125:             *
126:             * @param expfcls the implemtation class, or null to use the default.
127:             * Note: expfcls must implement {@link ExpressionFactory}.
128:             * If null, the system default is used.
129:             */
130:            public static final void setExpressionFactoryClass(Class expfcls) {
131:                if (expfcls != null
132:                        && !ExpressionFactory.class.isAssignableFrom(expfcls))
133:                    throw new IllegalArgumentException(expfcls
134:                            + " must implement " + ExpressionFactory.class);
135:                _expfcls = expfcls;
136:            }
137:
138:            /** Returns the implementation of the expression factory that
139:             * is used by the whole system, or null to use the system default.
140:             *
141:             * @see #setExpressionFactoryClass
142:             */
143:            public static final Class getExpressionFactoryClass() {
144:                return _expfcls;
145:            }
146:        }
147:
148:        /*package*/class EmptyMapper implements  FunctionMapper,
149:                java.io.Serializable {
150:            //-- FunctionMapper --//
151:            public Function resolveFunction(String prefix, String name) {
152:                return null;
153:            }
154:
155:            public Collection getClassNames() {
156:                return Collections.EMPTY_LIST;
157:            }
158:
159:            public Class resolveClass(String name) {
160:                return null;
161:            }
162:        }
163:
164:        /*package*/class EmptyResolver implements  VariableResolver,
165:                java.io.Serializable {
166:            public Object resolveVariable(String name) {
167:                return null;
168:            }
169:        }
170:
171:        /*package*/class DummyExpr implements  Expression, java.io.Serializable {
172:            public Object evaluate(XelContext ctx) throws XelException {
173:                return null;
174:            }
175:        };
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.