Source Code Cross Referenced for JavaConstructorInfo.java in  » Net » Terracotta » com » tc » aspectwerkz » reflect » impl » java » 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 » Net » Terracotta » com.tc.aspectwerkz.reflect.impl.java 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.aspectwerkz.reflect.impl.java;
005:
006:        import com.tc.aspectwerkz.reflect.ClassInfo;
007:        import com.tc.aspectwerkz.reflect.ConstructorInfo;
008:        import com.tc.aspectwerkz.reflect.ReflectHelper;
009:        import com.tc.backport175.bytecode.AnnotationElement;
010:
011:        import java.lang.reflect.Constructor;
012:
013:        /**
014:         * Implementation of the ConstructorInfo interface for java.lang.reflect.*.
015:         *
016:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
017:         */
018:        public class JavaConstructorInfo extends JavaMemberInfo implements 
019:                ConstructorInfo {
020:            /**
021:             * A list with the parameter types.
022:             */
023:            private ClassInfo[] m_parameterTypes = null;
024:
025:            /**
026:             * A list with the exception types.
027:             */
028:            private ClassInfo[] m_exceptionTypes = null;
029:
030:            /**
031:             * The signature of the class.
032:             */
033:            private String m_signature;
034:
035:            /**
036:             * Creates a new method meta data instance.
037:             *
038:             * @param constructor
039:             * @param declaringType
040:             */
041:            JavaConstructorInfo(final Constructor constructor,
042:                    final JavaClassInfo declaringType) {
043:                super (constructor, declaringType);
044:                m_signature = ReflectHelper
045:                        .getConstructorSignature(constructor);
046:            }
047:
048:            /**
049:             * Returns the constructor info for the constructor specified.
050:             *
051:             * @param constructor the constructor
052:             * @return the constructor info
053:             */
054:            public static ConstructorInfo getConstructorInfo(
055:                    final Constructor constructor) {
056:                Class declaringClass = constructor.getDeclaringClass();
057:                JavaClassInfoRepository repository = JavaClassInfoRepository
058:                        .getRepository(declaringClass.getClassLoader());
059:                ClassInfo classInfo = repository.getClassInfo(declaringClass
060:                        .getName());
061:                if (classInfo == null) {
062:                    classInfo = JavaClassInfo.getClassInfo(declaringClass);
063:                }
064:                return classInfo.getConstructor(ReflectHelper
065:                        .calculateHash(constructor));
066:            }
067:
068:            /**
069:             * Returns the signature for the element.
070:             *
071:             * @return the signature for the element
072:             */
073:            public String getSignature() {
074:                return m_signature;
075:            }
076:
077:            public String getGenericsSignature() {
078:                // XXX implement
079:                throw new RuntimeException();
080:            }
081:
082:            /**
083:             * Returns the attributes.
084:             *
085:             * @return the attributes
086:             */
087:            public AnnotationElement.Annotation[] getAnnotations() {
088:                return getDeclaringType().getAnnotationReader()
089:                        .getConstructorAnnotationElements(m_signature);
090:            }
091:
092:            /**
093:             * Returns the parameter types.
094:             *
095:             * @return the parameter types
096:             */
097:            public ClassInfo[] getParameterTypes() {
098:                if (m_parameterTypes == null) {
099:                    Class[] parameterTypes = ((Constructor) m_member)
100:                            .getParameterTypes();
101:                    m_parameterTypes = new ClassInfo[parameterTypes.length];
102:                    for (int i = 0; i < parameterTypes.length; i++) {
103:                        Class parameterType = parameterTypes[i];
104:                        ClassInfo metaData;
105:                        if (m_classInfoRepository.hasClassInfo(parameterType
106:                                .getName())) {
107:                            metaData = m_classInfoRepository
108:                                    .getClassInfo(parameterType.getName());
109:                        } else {
110:                            metaData = JavaClassInfo
111:                                    .getClassInfo(parameterType);
112:                            m_classInfoRepository.addClassInfo(metaData);
113:                        }
114:                        m_parameterTypes[i] = metaData;
115:                    }
116:                }
117:                return m_parameterTypes;
118:            }
119:
120:            /**
121:             * Returns the exception types.
122:             *
123:             * @return the exception types
124:             */
125:            public ClassInfo[] getExceptionTypes() {
126:                if (m_exceptionTypes == null) {
127:                    Class[] exceptionTypes = ((Constructor) m_member)
128:                            .getExceptionTypes();
129:                    m_exceptionTypes = new ClassInfo[exceptionTypes.length];
130:                    for (int i = 0; i < exceptionTypes.length; i++) {
131:                        Class exceptionType = exceptionTypes[i];
132:                        ClassInfo metaData;
133:                        if (m_classInfoRepository.hasClassInfo(exceptionType
134:                                .getName())) {
135:                            metaData = m_classInfoRepository
136:                                    .getClassInfo(exceptionType.getName());
137:                        } else {
138:                            metaData = JavaClassInfo
139:                                    .getClassInfo(exceptionType);
140:                            m_classInfoRepository.addClassInfo(metaData);
141:                        }
142:                        m_exceptionTypes[i] = metaData;
143:                    }
144:                }
145:                return m_exceptionTypes;
146:            }
147:
148:            public boolean equals(Object o) {
149:                if (this  == o) {
150:                    return true;
151:                }
152:                if (!(o instanceof  ConstructorInfo)) {
153:                    return false;
154:                }
155:                ConstructorInfo constructorInfo = (ConstructorInfo) o;
156:                if (!m_declaringType.getName().equals(
157:                        constructorInfo.getDeclaringType().getName())) {
158:                    return false;
159:                }
160:                if (!m_member.getName().equals(constructorInfo.getName())) {
161:                    return false;
162:                }
163:                Class[] parameterTypes1 = ((Constructor) m_member)
164:                        .getParameterTypes();
165:                ClassInfo[] parameterTypes2 = constructorInfo
166:                        .getParameterTypes();
167:                if (parameterTypes1.length != parameterTypes2.length) {
168:                    return false;
169:                }
170:                for (int i = 0; i < parameterTypes1.length; i++) {
171:                    if (!parameterTypes1[i].getName().equals(
172:                            parameterTypes2[i].getName())) {
173:                        return false;
174:                    }
175:                }
176:                return true;
177:            }
178:
179:            public int hashCode() {
180:                int result = 29;
181:                result = (29 * result) + m_declaringType.getName().hashCode();
182:                result = (29 * result) + m_member.getName().hashCode();
183:                Class[] parameterTypes = ((Constructor) m_member)
184:                        .getParameterTypes();
185:                for (int i = 0; i < parameterTypes.length; i++) {
186:                    result = (29 * result)
187:                            + parameterTypes[i].getName().hashCode();
188:                }
189:                return result;
190:            }
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.