Source Code Cross Referenced for MethodInfo.java in  » Code-Analyzer » JBlanket » csdl » jblanket » methodset » 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 » Code Analyzer » JBlanket » csdl.jblanket.methodset 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package csdl.jblanket.methodset;
002:
003:        import java.util.ArrayList;
004:        import java.util.List;
005:
006:        /**
007:         * Implements the MethodInfo abstract data type, which provides information
008:         * about a single Java method. Method instances are managed by the
009:         * MethodSet container.
010:         *
011:         * @author Philip Johnson
012:         * @version $Id: MethodInfo.java,v 1.1 2004/11/07 00:32:38 timshadel Exp $
013:         */
014:        public class MethodInfo {
015:
016:            /** The fully qualified class name. */
017:            private String className;
018:            /** The method name (no parentheses). */
019:            private String methodName;
020:            /** A list of fully qualified class names, in order. */
021:            private List parameterTypeList;
022:            /** The string representation of this method, used for ordering. */
023:            private String methodString;
024:            /** The hashcode for this method. */
025:            private int hashCode;
026:
027:            /**
028:             * Creates a Method representing information about a Method's type signature.
029:             *
030:             * @param className The fully qualified class name, such as "java.lang.String".
031:             * @param methodName The method name without parentheses, such as "getBaz".
032:             * @param parameterTypeList A list, in order, of fully qualified class names
033:             * corresponding to the parameters that this method is invoked with.
034:             */
035:            public MethodInfo(String className, String methodName,
036:                    List parameterTypeList) {
037:                // Make sure we don't get passed any nulls, because that will screw us later.
038:                if ((className == null) || (methodName == null)
039:                        || (parameterTypeList == null)) {
040:                    throw new RuntimeException(
041:                            "Args to MethodInfo constructor cannot be null!");
042:                }
043:                this .className = className;
044:                this .methodName = methodName;
045:                // Note, we do not copy the passed list, so hopefully it isn't modified later
046:                // by the client!
047:                this .parameterTypeList = parameterTypeList;
048:                this .methodString = this .className + "." + this .methodName
049:                        + " " + this .parameterTypeList;
050:                this .hashCode = this .methodString.hashCode();
051:            }
052:
053:            /**
054:             * Returns the fully qualified class name.
055:             *
056:             * @return The fully qualified class name.
057:             */
058:            public String getClassName() {
059:                return this .className;
060:            }
061:
062:            /**
063:             * Returns a string representation of the methodInfo, used only for comparison
064:             * purposes in the MethodSet container.
065:             *
066:             * @return The fully qualified class name.
067:             */
068:            String getMethodString() {
069:                return this .methodString;
070:            }
071:
072:            /**
073:             * Returns the method name.
074:             *
075:             * @return The method name.
076:             */
077:            public String getMethodName() {
078:                return this .methodName;
079:            }
080:
081:            /**
082:             * Returns the list of parameter types.
083:             * Note that this list is not copied, so changes made to this list instance
084:             * by the client will modify this method's internal representation!
085:             *
086:             * @return The parameter type list.
087:             */
088:            public List getParameterTypeList() {
089:                return this .parameterTypeList;
090:            }
091:
092:            /**
093:             * Returns the package corresponding to this method. For example, if the method's
094:             * class name is "java.lang.String", then the package is "java.lang". If the
095:             * method is not in a package, then the empty string is returned.
096:             *
097:             * @return The package string.
098:             */
099:            public String getPackageName() {
100:                int endPackageIndex = this .className.lastIndexOf('.');
101:                return (endPackageIndex >= 0) ? this .className
102:                        .substring((endPackageIndex + 1)) : "";
103:            }
104:
105:            /**
106:             * Provides a readable representation of the Method.
107:             *
108:             * @return The MethodSet as a string.
109:             */
110:            public String toString() {
111:                return "[Method " + methodString + "]";
112:            }
113:
114:            /**
115:             * Implements the "natural ordering" for methods.
116:             * Methods are ordered by their string representation.
117:             *
118:             * @param obj A method instance.
119:             * @return Standard compareTo return values.
120:             */
121:            public int compareTo(Object obj) {
122:                return this .methodString
123:                        .compareTo(((MethodInfo) obj).methodString);
124:            }
125:
126:            /**
127:             * Two Methods are equal() iff their string representations are equal.
128:             *
129:             * @param obj An object, which could or could not be a method.
130:             * @return True if equal.
131:             */
132:            public boolean equals(Object obj) {
133:                return ((obj instanceof  MethodInfo) && (this .methodString
134:                        .equals(((MethodInfo) obj).methodString)));
135:            }
136:
137:            /**
138:             * Compute the hashcode following recommendations in "Effective Java".
139:             *
140:             * @return The hashcode.
141:             */
142:            public int hashCode() {
143:                return this .hashCode;
144:            }
145:
146:            /**
147:             * Main for one-off testing of this data structure.
148:             *
149:             * @param args Ignored.
150:             */
151:            public static void main(String args[]) {
152:                ArrayList params = new ArrayList();
153:                params.add("java.lang.String");
154:                params.add("java.lang.Boolean");
155:                MethodInfo method1 = new MethodInfo("foo.bar.Baz", "qux",
156:                        params);
157:                System.out.println(method1);
158:                System.out.println("Package: " + method1.getPackageName());
159:                MethodInfo method2 = new MethodInfo("Baz", "qux", null);
160:                System.out.println("Package: " + method2.getPackageName());
161:                System.out.println("Test equal methods: "
162:                        + method1.equals(method1));
163:                System.out.println("Test non-equal methods: "
164:                        + method1.equals(method2));
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.