Source Code Cross Referenced for MethodSurrogate.java in  » Byte-Code » PROSE » ch » ethz » prose » query » 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 » Byte Code » PROSE » ch.ethz.prose.query 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        //  This file is part of the prose package.
003:        //
004:        //  The contents of this file are subject to the Mozilla Public License
005:        //  Version 1.1 (the "License"); you may not use this file except in
006:        //  compliance with the License. You may obtain a copy of the License at
007:        //  http://www.mozilla.org/MPL/
008:        //
009:        //  Software distributed under the License is distributed on an "AS IS" basis,
010:        //  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011:        //  for the specific language governing rights and limitations under the
012:        //  License.
013:        //
014:        //  The Original Code is prose.
015:        //
016:        //  The Initial Developer of the Original Code is Andrei Popovici. Portions
017:        //  created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018:        //  All Rights Reserved.
019:        //
020:        //  Contributor(s):
021:        // $Id: MethodSurrogate.java,v 1.1.1.1 2003/07/02 15:30:52 apopovic Exp $
022:        // =====================================================================
023:        //
024:        // (history at end)
025:        //
026:
027:        package ch.ethz.prose.query;
028:
029:        // used packages
030:        import java.lang.reflect.Method;
031:        import java.lang.NoSuchMethodException;
032:
033:        /**
034:         * Class MethodSurrogate represents a <code>Method</code> object.
035:         *
036:         * @version	$Revision: 1.1.1.1 $
037:         * @author	Philippe Schoch
038:         */
039:        public class MethodSurrogate extends Surrogate implements 
040:                java.io.Serializable {
041:
042:            private static final long serialVersionUID = 3258417243942367536L;
043:            private String declaringClassName;
044:            private String methodName;
045:            private String[] parameterTypes;
046:            private int hashCode;
047:
048:            /**
049:             * Constructs a new instance representing method <code>m</code>
050:             *
051:             * @param m the method to represent
052:             */
053:            public MethodSurrogate(Method m) {
054:                if (m == null)
055:                    throw new IllegalArgumentException(
056:                            "specified method must not be null");
057:
058:                hashCode = m.hashCode();
059:                methodName = m.getName();
060:                Class[] pt = m.getParameterTypes();
061:                parameterTypes = new String[pt.length];
062:                for (int i = 0; i < pt.length; i++)
063:                    parameterTypes[i] = pt[i].getName();
064:
065:                declaringClassName = m.getDeclaringClass().getName();
066:            }
067:
068:            /**
069:             * Returns the name of the contained method
070:             *
071:             * @return the name of the represented method
072:             */
073:            public String getName() {
074:                return methodName;
075:            }
076:
077:            /**
078:             * Returns the input parameter types of the contained method.
079:             *
080:             * @return the parameter types of the represented method as String Array.
081:             */
082:            public String[] getParameterTypes() {
083:                return parameterTypes;
084:            }
085:
086:            public Object toRealInstance() throws ClassNotFoundException,
087:                    NoSuchMethodException {
088:                return toRealInstance(declaringClassName);
089:            }
090:
091:            /**
092:             * Returns a <code>Method</code> Object that is represented by this
093:             * <code>MethodSurrogate</code>.
094:             *
095:             * @exception ClassNotFoundException	can be thrown if the declaring class of the method is not found.
096:             * @exception NoSuchMethodException 	can be thrown if the name of the method doesn't represent a <code>Method</code>.
097:             */
098:            public Method toRealInstance(String className)
099:                    throws ClassNotFoundException, NoSuchMethodException {
100:                Class[] parameterClasses = new Class[parameterTypes.length];
101:
102:                Class declaringClass = Class.forName(className);
103:                for (int i = 0; i < parameterTypes.length; i++) {
104:                    if (parameterTypes[i].equals("byte"))
105:                        parameterClasses[i] = byte.class;
106:                    else if (parameterTypes[i].equals("short"))
107:                        parameterClasses[i] = short.class;
108:                    else if (parameterTypes[i].equals("int"))
109:                        parameterClasses[i] = int.class;
110:                    else if (parameterTypes[i].equals("long"))
111:                        parameterClasses[i] = long.class;
112:                    else if (parameterTypes[i].equals("char"))
113:                        parameterClasses[i] = char.class;
114:                    else if (parameterTypes[i].equals("float"))
115:                        parameterClasses[i] = float.class;
116:                    else if (parameterTypes[i].equals("double"))
117:                        parameterClasses[i] = double.class;
118:                    else if (parameterTypes[i].equals("boolean"))
119:                        parameterClasses[i] = boolean.class;
120:                    else
121:                        parameterClasses[i] = Class.forName(parameterTypes[i]);
122:                }
123:                return (declaringClass.getDeclaredMethod(methodName,
124:                        parameterClasses));
125:            }
126:
127:            /**
128:             * Compares this instance with the passed object. Attention, this method has a
129:             * different semantic than the one in the <code>Method</code> class!!!
130:             *
131:             * @return <code>true</code> if the passed object is of type MethodSurrogate
132:             *          and has the same name and parameter types.
133:             */
134:            public boolean equals(Object o) {
135:                if (!(o instanceof  MethodSurrogate))
136:                    return false;
137:
138:                MethodSurrogate other = (MethodSurrogate) o;
139:
140:                if (!this .getName().equals(other.getName()))
141:                    return false;
142:
143:                if (this .parameterTypes.length != other.parameterTypes.length)
144:                    return false;
145:
146:                for (int i = 0; i < this .parameterTypes.length; i++)
147:                    if (!this .parameterTypes[i].equals(other.parameterTypes[i]))
148:                        return false;
149:
150:                return true;
151:            }
152:
153:            public int hashCode() {
154:                return hashCode;
155:            }
156:
157:            /**
158:             * Returns a string describing this <code>FieldSurrogate</code>. The format is the method name
159:             * followed by an opening paranthesis and all paramter types separated by colons and an closing paranthesis.
160:             */
161:            public String toString() {
162:                String s = methodName + "(";
163:                for (int i = 0; i < parameterTypes.length; i++) {
164:                    if (i == 0) {
165:                        s += parameterTypes[i];
166:                        continue;
167:                    }
168:                    s += (", " + parameterTypes[i]);
169:                }
170:                s += ")";
171:                return s;
172:            }
173:        }
174:
175:        //======================================================================
176:        //
177:        // $Log: MethodSurrogate.java,v $
178:        // Revision 1.1.1.1  2003/07/02 15:30:52  apopovic
179:        // Imported from ETH Zurich
180:        //
181:        // Revision 1.3  2003/05/20 16:05:09  popovici
182:        //
183:        // New QueryManager replaces functionality in AspectManager (better Soc)
184:        // New 'Surrogate' classes for usage in the QueryManager
185:        // The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
186:        //
187:        // Revision 1.2  2003/05/06 15:51:51  popovici
188:        // Mozilla-ification
189:        //
190:        // Revision 1.1  2003/05/05 13:58:21  popovici
191:        // renaming from runes to prose
192:        //
193:        // Revision 1.5  2003/04/17 15:14:57  popovici
194:        // Extension->Aspect renaming
195:        //
196:        // Revision 1.4  2003/03/13 14:16:56  popovici
197:        // All items traveling with Tupels are now Serializable
198:        //
199:        // Revision 1.3  2003/03/04 18:36:02  popovici
200:        // Organization of imprts
201:        //
202:        // Revision 1.2  2003/01/27 12:58:57  pschoch
203:        // new HashCode Policy with Surrogates; toString() of Surrogates improved
204:        //
205:        // Revision 1.1  2003/01/17 14:43:58  pschoch
206:        // Introduction of 'query' methods in the AspectManager and its
207:        // subclasses.  The result set is given back in form of surrogates; 4 new tests added to ExtensionManagerTest
208:        // ExtensionSystemTest
209:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.