Source Code Cross Referenced for JMethod.java in  » Testing » Ejb3Unit » com » bm » ejb3metadata » annotations » 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 » Testing » Ejb3Unit » com.bm.ejb3metadata.annotations 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * EasyBeans
003:         * Copyright (C) 2006 Bull S.A.S.
004:         * Contact: easybeans@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: JMethod.java 47 2006-02-28 10:42:29Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package com.bm.ejb3metadata.annotations;
025:
026:        import java.lang.reflect.Method;
027:        import java.util.Arrays;
028:
029:        import org.ejb3unit.asm.Type;
030:
031:        /**
032:         * This class defines a Method object. It is not based on reflection but allows
033:         * to build a JMethod based on java.lang.reflect.Method
034:         * @author Florent Benoit
035:         */
036:        public class JMethod {
037:
038:            /**
039:             * Name of the method.
040:             */
041:            private String name = null;
042:
043:            /**
044:             * Access mode (see {@link org.ejb3unit.asm.Opcodes}).
045:             */
046:            private int access;
047:
048:            /**
049:             * Method's descriptor.
050:             */
051:            private String descriptor = null;
052:
053:            /**
054:             * Method's signature.
055:             */
056:            private String signature;
057:
058:            /**
059:             * Exceptions of the method.
060:             */
061:            private String[] exceptions;
062:
063:            /**
064:             * Constructor.
065:             * @param access the access mode (see {@link org.ejb3unit.asm.Opcodes})
066:             * @param name the method's name.
067:             * @param descriptor the method's descriptor (see
068:             *        {@link org.ejb3unit.asm.Type Type}).
069:             * @param signature the method's signature. May be <tt>null</tt> if the
070:             *        method parameters, return type and exceptions do not use generic
071:             *        types.
072:             * @param exceptions the internal names of the method's exception classes
073:             *        (see
074:             *        {@link org.ejb3unit.asm.Type#getInternalName() getInternalName}).
075:             *        May be <tt>null</tt>.
076:             */
077:            public JMethod(final int access, final String name,
078:                    final String descriptor, final String signature,
079:                    final String[] exceptions) {
080:                this .access = access;
081:                this .name = name;
082:                this .descriptor = descriptor;
083:                this .signature = signature;
084:                this .exceptions = exceptions;
085:            }
086:
087:            /**
088:             * the access mode (see {@link org.ejb3unit.asm.Opcodes}).
089:             * @return the access mode (see {@link org.ejb3unit.asm.Opcodes})
090:             */
091:            public int getAccess() {
092:                return access;
093:            }
094:
095:            /**
096:             * Constructor.
097:             * @param m {@link java.lang.reflect.Method} method.
098:             */
099:            public JMethod(final Method m) {
100:                this .name = m.getName();
101:                this .descriptor = Type.getMethodDescriptor(m);
102:                // FIXME: make this ok
103:                // this.signature = Type.signature;
104:                // this.exceptions = exceptions;
105:            }
106:
107:            /**
108:             * Indicates whether some other object is "equal to" this one.
109:             * @param obj object to compare
110:             * @return true if given object is equals
111:             */
112:            @Override
113:            public boolean equals(final Object obj) {
114:                if (obj != null && obj instanceof  JMethod) {
115:                    JMethod other = (JMethod) obj;
116:
117:                    // same name
118:                    if (!this .name.equals(other.name)) {
119:                        return false;
120:                    }
121:
122:                    // same descriptor
123:                    if ((this .descriptor != null)
124:                            && (!this .descriptor.equals(other.descriptor))) {
125:                        return false;
126:                    }
127:
128:                    // Don't check signature (which include generics information)
129:                    // For example void method(List<Integer>) and
130:                    //             void method(List<String>)
131:                    // and even if signature is different, they have same erasure
132:                    // This is not allowed, so don't need to check signature information.
133:
134:                    // if all tests succeed, return true
135:                    return true;
136:                }
137:                return false;
138:            }
139:
140:            /**
141:             * a hash code value for the object.
142:             * @return a hash code value for the object.
143:             */
144:            @Override
145:            public int hashCode() {
146:                return name.hashCode();
147:            }
148:
149:            /**
150:             * method descriptor.
151:             * @return method descriptor
152:             */
153:            public String getDescriptor() {
154:                return descriptor;
155:            }
156:
157:            /**
158:             * method exceptions.
159:             * @return method exceptions
160:             */
161:            public String[] getExceptions() {
162:                return exceptions;
163:            }
164:
165:            /**
166:             * method name.
167:             * @return method name
168:             */
169:            public String getName() {
170:                return name;
171:            }
172:
173:            /**
174:             * method signature.
175:             * method signature
176:             * @return method signature
177:             */
178:            public String getSignature() {
179:                return signature;
180:            }
181:
182:            /**
183:             * string representation.
184:             * @return string representation
185:             */
186:            @Override
187:            public String toString() {
188:                StringBuilder sb = new StringBuilder();
189:                // classname
190:                sb.append(this .getClass().getName().substring(
191:                        this .getClass().getPackage().getName().length() + 1));
192:
193:                // name
194:                sb.append("[name=");
195:                sb.append(name);
196:
197:                // access
198:                sb.append(", access=");
199:                sb.append(access);
200:
201:                // descriptor
202:                if (descriptor != null) {
203:                    sb.append(", descriptor=");
204:                    sb.append(descriptor);
205:                }
206:
207:                // signature
208:                if (signature != null) {
209:                    sb.append(", signature=");
210:                    sb.append(signature);
211:                }
212:
213:                // exceptions
214:                if (exceptions != null) {
215:                    sb.append(", exceptions=");
216:                    sb.append(Arrays.asList(exceptions));
217:                }
218:                sb.append("]");
219:                return sb.toString();
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.