Source Code Cross Referenced for PropertyResolverImpl.java in  » J2EE » myfaces-core-1.2.0 » org » apache » myfaces » el » 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 » J2EE » myfaces core 1.2.0 » org.apache.myfaces.el 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.apache.myfaces.el;
017:
018:        import java.util.List;
019:
020:        import javax.el.ELContext;
021:        import javax.el.ELException;
022:        import javax.el.ELResolver;
023:        import javax.faces.context.FacesContext;
024:        import javax.faces.el.EvaluationException;
025:        import javax.faces.el.PropertyNotFoundException;
026:        import javax.faces.el.PropertyResolver;
027:
028:        /**
029:         * @author Manfred Geiler (latest modification by $Author: pmcmahan $)
030:         * @author Anton Koinov
031:         * @version $Revision: 528504 $ $Date: 2007-04-13 16:42:18 +0200 (Fr, 13 Apr 2007) $
032:         */
033:        @SuppressWarnings("deprecation")
034:        public class PropertyResolverImpl extends PropertyResolver {
035:            // ~ Public PropertyResolver Methods
036:            // ----------------------------------------
037:
038:            @Override
039:            public Object getValue(final Object base, final Object property)
040:                    throws EvaluationException, PropertyNotFoundException {
041:                return invokeResolver(new ResolverInvoker<Object>(base,
042:                        property) {
043:                    public Object invoke(ELResolver resolver, ELContext context) {
044:                        return getELResolver().getValue(getELContext(), base,
045:                                property);
046:                    }
047:                });
048:            }
049:
050:            @Override
051:            public Object getValue(final Object base, final int index)
052:                    throws EvaluationException, PropertyNotFoundException {
053:                return getValue(base, new Integer(index));
054:            }
055:
056:            @Override
057:            public void setValue(final Object base, final Object property,
058:                    final Object newValue) throws EvaluationException,
059:                    PropertyNotFoundException {
060:                if (base == null || property == null)
061:                    throw new PropertyNotFoundException();
062:
063:                invokeResolver(new ResolverInvoker<Object>(base, property) {
064:                    @Override
065:                    public Object invoke(ELResolver resolver, ELContext context) {
066:                        resolver.setValue(context, base, property, newValue);
067:                        return null;
068:                    }
069:
070:                    @Override
071:                    String getMessage() {
072:                        return super .getMessage() + " newValue: '" + newValue
073:                                + "'";
074:                    }
075:                });
076:            }
077:
078:            @Override
079:            public void setValue(Object base, int index, Object newValue)
080:                    throws EvaluationException, PropertyNotFoundException {
081:                if (base == null)
082:                    throw new PropertyNotFoundException();
083:
084:                if (base instanceof  Object[]) {
085:                    if (index < 0 || index >= ((Object[]) base).length) {
086:                        throw new PropertyNotFoundException();
087:                    }
088:                } else if (base instanceof  List) {
089:                    if (index < 0 || index >= ((List) base).size()) {
090:                        throw new PropertyNotFoundException();
091:                    }
092:                }
093:
094:                setValue(base, new Integer(index), newValue);
095:            }
096:
097:            @Override
098:            public boolean isReadOnly(final Object base, final Object property) {
099:                return invokeResolver(new ResolverInvoker<Boolean>(base,
100:                        property) {
101:                    public Boolean invoke(ELResolver resolver, ELContext context) {
102:                        return Boolean.valueOf(getELResolver().isReadOnly(
103:                                getELContext(), base, property));
104:                    }
105:                });
106:            }
107:
108:            @Override
109:            public boolean isReadOnly(Object base, int index) {
110:                return isReadOnly(base, new Integer(index));
111:            }
112:
113:            @Override
114:            public Class getType(final Object base, final Object property) {
115:                if (base == null || property == null)
116:                    throw new PropertyNotFoundException();
117:
118:                return invokeResolver(new ResolverInvoker<Class>(base, property) {
119:                    public Class invoke(ELResolver resolver, ELContext context) {
120:                        return resolver.getType(context, base, property);
121:                    }
122:                });
123:            }
124:
125:            @Override
126:            public Class getType(Object base, int index) {
127:                if (base == null)
128:                    throw new PropertyNotFoundException();
129:
130:                if (base instanceof  Object[]) {
131:                    if (index < 0 || index >= ((Object[]) base).length) {
132:                        throw new PropertyNotFoundException();
133:                    }
134:                } else if (base instanceof  List) {
135:                    if (index < 0 || index >= ((List) base).size()) {
136:                        throw new PropertyNotFoundException();
137:                    }
138:                }
139:
140:                return getType(base, new Integer(index));
141:            }
142:
143:            // ~ Internal Helper Methods
144:            // ------------------------------------------------
145:
146:            ELContext getELContext() {
147:                return getFacesContext().getELContext();
148:            }
149:
150:            ELResolver getELResolver() {
151:                return getFacesContext().getApplication().getELResolver();
152:            }
153:
154:            FacesContext getFacesContext() {
155:                return FacesContext.getCurrentInstance();
156:            }
157:
158:            <T> T invokeResolver(ResolverInvoker<T> invoker)
159:                    throws EvaluationException, PropertyNotFoundException {
160:                try {
161:                    return invoker.invoke(getELResolver(), getELContext());
162:                } catch (javax.el.PropertyNotFoundException e) {
163:                    throw new PropertyNotFoundException("property not found: "
164:                            + invoker.getMessage() + ": " + e.getMessage(), e);
165:                } catch (ELException e) {
166:                    throw new EvaluationException("exception: "
167:                            + invoker.getMessage() + ": " + e.getMessage(), e);
168:                } catch (RuntimeException e) {
169:                    throw new RuntimeException("runtime exception: "
170:                            + invoker.getMessage() + ": " + e.getMessage(), e);
171:                }
172:            }
173:
174:            abstract static class ResolverInvoker<T> {
175:                private final Object _base;
176:                private final Object _property;
177:
178:                ResolverInvoker(Object base, Object property) {
179:                    _base = base;
180:                    _property = property;
181:                }
182:
183:                abstract T invoke(ELResolver resolver, ELContext context);
184:
185:                String getMessage() {
186:                    return "base: '" + _base + "' property/index: '"
187:                            + _property + "'";
188:                }
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.