Source Code Cross Referenced for JavaDispatchImpl.java in  » Ajax » GWT » com » google » gwt » dev » shell » 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 » GWT » com.google.gwt.dev.shell 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * 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, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.dev.shell;
017:
018:        import java.lang.reflect.Field;
019:        import java.lang.reflect.Member;
020:        import java.lang.reflect.Method;
021:
022:        /**
023:         * Class for wrapping Java things for JavaScript.
024:         */
025:        public class JavaDispatchImpl implements  JavaDispatch {
026:
027:            private final CompilingClassLoader classLoader;
028:
029:            private final Object target;
030:
031:            /**
032:             * This constructor initializes a dispatcher for handling static members.
033:             * 
034:             * @param ccl class loader to use for dispatching member access
035:             */
036:            public JavaDispatchImpl(CompilingClassLoader ccl) {
037:                classLoader = ccl;
038:                target = null;
039:            }
040:
041:            /**
042:             * This constructor initializes a dispatcher around a particular instance.
043:             * 
044:             * @param ccl class loader to use for dispatching member access
045:             * @param target the instance object to use for dispatching member accesses
046:             * 
047:             * @throws NullPointerException if target is null
048:             */
049:            public JavaDispatchImpl(CompilingClassLoader ccl, Object target) {
050:                if (target == null) {
051:                    throw new NullPointerException("target cannot be null");
052:                }
053:
054:                classLoader = ccl;
055:                this .target = target;
056:            }
057:
058:            /**
059:             * @param dispId the unique number of a field
060:             * @return the field
061:             */
062:            public Field getField(int dispId) {
063:                return (Field) getMember(dispId);
064:            }
065:
066:            /**
067:             * @param dispId the unique number of a field
068:             * @return true the value of the field
069:             * @throws IllegalArgumentException
070:             */
071:            public Object getFieldValue(int dispId) {
072:                Field field = (Field) getMember(dispId);
073:                try {
074:                    return field.get(target);
075:                } catch (IllegalAccessException e) {
076:                    // should never, ever happen
077:                    e.printStackTrace();
078:                    throw new RuntimeException(e);
079:                }
080:            }
081:
082:            /**
083:             * @param dispId the unique number of a method
084:             * @return the method
085:             */
086:            public Method getMethod(int dispId) {
087:                return (Method) getMember(dispId);
088:            }
089:
090:            public Object getTarget() {
091:                return target;
092:            }
093:
094:            /**
095:             * @param dispId the unique number of a method or field
096:             * @return true if the dispId represents a field
097:             */
098:            public boolean isField(int dispId) {
099:                if (dispId < 0) {
100:                    return false;
101:                }
102:
103:                return getMember(dispId) instanceof  Field;
104:            }
105:
106:            /**
107:             * @param dispId the unique number of a method or field
108:             * @return true if the dispId represents a method
109:             */
110:            public boolean isMethod(int dispId) {
111:                if (dispId < 0) {
112:                    return false;
113:                }
114:
115:                return getMember(dispId) instanceof  Method;
116:            }
117:
118:            /**
119:             * @param dispId the unique number of a field
120:             * @param value the value to assign to the field
121:             * @throws IllegalArgumentException
122:             */
123:            public void setFieldValue(int dispId, Object value) {
124:                Field field = (Field) getMember(dispId);
125:                try {
126:                    field.set(target, value);
127:                } catch (IllegalAccessException e) {
128:                    // should never, ever happen
129:                    e.printStackTrace();
130:                    throw new RuntimeException(e);
131:                }
132:            }
133:
134:            /**
135:             * @param dispId the unique number of a method or field
136:             * @return the member
137:             */
138:            protected Member getMember(int dispId) {
139:                DispatchClassInfo clsInfo = classLoader
140:                        .getClassInfoByDispId(dispId);
141:                return clsInfo.getMember(dispId);
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.