[jboss-cvs] JBossAS SVN: r81547 - in projects/jboss-reflect/tags: 2.0.2.GA and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 25 08:34:09 EST 2008
Author: alesj
Date: 2008-11-25 08:34:08 -0500 (Tue, 25 Nov 2008)
New Revision: 81547
Added:
projects/jboss-reflect/tags/2.0.2.GA/
projects/jboss-reflect/tags/2.0.2.GA/pom.xml
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/NumberInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/TypeInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/ContainerAllTestSuite.java
projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCache.java
projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java
projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java
projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/typeinfo/
Removed:
projects/jboss-reflect/tags/2.0.2.GA/pom.xml
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/NumberInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/TypeInfo.java
projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/ContainerAllTestSuite.java
projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java
Log:
[maven-release-plugin] copy for tag 2.0.2.GA
Copied: projects/jboss-reflect/tags/2.0.2.GA (from rev 81411, projects/jboss-reflect/branches/Branch_2_0)
Deleted: projects/jboss-reflect/tags/2.0.2.GA/pom.xml
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/pom.xml 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/pom.xml 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,91 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>4</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-reflect</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>JBoss Reflection</name>
- <url>http://www.jboss.com/products/jbossmc</url>
- <description>JBoss Reflection</description>
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-reflect/branches/Branch_2_0</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-reflect/branches/Branch_2_0</developerConnection>
- <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-reflect/branches/Branch_2_0</url>
- </scm>
-
- <build>
- <finalName>${artifactId}</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.3</version>
- <configuration>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <includes>
- <include>org/jboss/test/**/*TestCase.java</include>
- </includes>
- <useSystemClassLoader>true</useSystemClassLoader>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.8.1.GA</version>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>2.0.5.GA</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>2.2.8.GA</version>
- </dependency>
-
- <!-- Test dependencies -->
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <version>1.1.1.GA</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>jboss.profiler.jvmti</groupId>
- <artifactId>jboss-profiler-jvmti</artifactId>
- <version>1.0.0.CR5</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-</project>
\ No newline at end of file
Copied: projects/jboss-reflect/tags/2.0.2.GA/pom.xml (from rev 81546, projects/jboss-reflect/branches/Branch_2_0/pom.xml)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/pom.xml (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/pom.xml 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,91 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-reflect</artifactId>
+ <version>2.0.2.GA</version>
+ <packaging>jar</packaging>
+ <name>JBoss Reflection</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Reflection</description>
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-reflect/tags/2.0.2.GA</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-reflect/tags/2.0.2.GA</developerConnection>
+ <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-reflect/tags/2.0.2.GA</url>
+ </scm>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>org/jboss/test/**/*TestCase.java</include>
+ </includes>
+ <useSystemClassLoader>true</useSystemClassLoader>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.8.1.GA</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>2.0.5.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.8.GA</version>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>1.1.1.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss.profiler.jvmti</groupId>
+ <artifactId>jboss-profiler-jvmti</artifactId>
+ <version>1.0.0.CR5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,411 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.beans.info.plugins;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import org.jboss.beans.info.spi.BeanAccessMode;
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.BeanInfoFactory;
-import org.jboss.beans.info.spi.EventInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.classadapter.spi.ClassAdapter;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.PrimitiveInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.util.JBossStringBuilder;
-import org.jboss.util.collection.WeakValueHashMap;
-
-/**
- * A bean info factory.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class AbstractBeanInfoFactory implements BeanInfoFactory
-{
- /** The cache */
- protected Map<ClassLoader, Map<String, Map<BeanAccessMode, BeanInfo>>> cache = new WeakHashMap<ClassLoader, Map<String, Map<BeanAccessMode, BeanInfo>>>();
-
- protected static boolean isGetter(MethodInfo minfo)
- {
- String name = minfo.getName();
- TypeInfo returnType = minfo.getReturnType();
- TypeInfo[] parameters = minfo.getParameterTypes();
- if ((name.length() > 3 && name.startsWith("get")) || (name.length() > 2 && name.startsWith("is")))
- {
- // isBoolean() is not a getter for java.lang.Boolean
- if (name.startsWith("is") && PrimitiveInfo.BOOLEAN.equals(returnType) == false)
- return false;
- if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
- return true;
- }
- return false;
- }
-
- protected static boolean isSetter(MethodInfo minfo)
- {
- String name = minfo.getName();
- TypeInfo returnType = minfo.getReturnType();
- TypeInfo[] parameters = minfo.getParameterTypes();
- if ((name.length() > 3 && name.startsWith("set")))
- {
- if (parameters.length == 1 && PrimitiveInfo.VOID.equals(returnType))
- return true;
- }
- return false;
- }
-
- protected static String getUpperPropertyName(String name)
- {
- int start = 3;
- if (name.startsWith("is"))
- start = 2;
-
- return name.substring(start);
- }
-
- protected static String getLowerPropertyName(String name)
- {
- // If the second character is upper case then we don't make
- // the first character lower case
- if (name.length() > 1)
- {
- if (Character.isUpperCase(name.charAt(1)))
- return name;
- }
-
- JBossStringBuilder buffer = new JBossStringBuilder(name.length());
- buffer.append(Character.toLowerCase(name.charAt(0)));
- if (name.length() > 1)
- buffer.append(name.substring(1));
- return buffer.toString();
- }
-
- /**
- * Create a new bean info factory
- */
- public AbstractBeanInfoFactory()
- {
- }
-
- public BeanInfo getBeanInfo(ClassAdapter classAdapter)
- {
- return getBeanInfo(classAdapter, BeanAccessMode.STANDARD);
- }
-
- public BeanInfo getBeanInfo(ClassAdapter classAdapter, BeanAccessMode accessMode)
- {
- if (classAdapter == null)
- throw new IllegalArgumentException("Null class adapter.");
- if (accessMode == null)
- accessMode = BeanAccessMode.STANDARD;
-
- synchronized (cache)
- {
- ClassLoader cl = classAdapter.getClassLoader();
- ClassInfo classInfo = classAdapter.getClassInfo();
- String className = classInfo.getName();
- Map<String, Map<BeanAccessMode, BeanInfo>> map = cache.get(cl);
- Map<BeanAccessMode, BeanInfo> modeMap = null;
- if (map != null)
- {
- modeMap = map.get(className);
- if (modeMap != null)
- {
- BeanInfo info = modeMap.get(accessMode);
- if (info != null)
- return info;
- }
- }
-
- Set<ConstructorInfo> constructors = getConstructors(classInfo);
- Set<MethodInfo> methods = getMethods(classInfo);
- Set<PropertyInfo> properties;
- if (classInfo.isAnnotation())
- properties = getAnnotationProperties(methods);
- else
- properties = getBeanProperties(methods);
- Set<EventInfo> events = getEvents(classInfo);
-
- BeanInfo result = createBeanInfo(classAdapter, accessMode, properties, constructors, methods, events);
- if (map == null)
- {
- map = new WeakValueHashMap<String, Map<BeanAccessMode, BeanInfo>>();
- cache.put(cl, map);
- }
- if (modeMap == null)
- {
- modeMap = new WeakValueHashMap<BeanAccessMode, BeanInfo>();
- map.put(className, modeMap);
- }
- modeMap.put(accessMode, result);
- return result;
- }
- }
-
- /**
- * Create the bean info
- *
- * @param classAdapter the class adapter
- * @param accessMode the access mode
- * @param properties the properties
- * @param constructors the constructors
- * @param methods the methods
- * @param events the events
- * @return the bean info
- */
- protected BeanInfo createBeanInfo(
- ClassAdapter classAdapter,
- BeanAccessMode accessMode,
- Set<PropertyInfo> properties,
- Set<ConstructorInfo> constructors,
- Set<MethodInfo> methods,
- Set<EventInfo> events)
- {
- return accessMode.create(this, classAdapter, properties, constructors, methods, events);
- }
-
- /**
- * Get the constructors
- *
- * @param classInfo the class info
- * @return the constructors
- */
- protected Set<ConstructorInfo> getConstructors(ClassInfo classInfo)
- {
- ConstructorInfo[] cinfos = classInfo.getDeclaredConstructors();
- if (cinfos == null || cinfos.length == 0)
- return null;
-
- HashSet<ConstructorInfo> result = new HashSet<ConstructorInfo>();
- for (int i = 0; i < cinfos.length; ++i)
- {
- if (cinfos[i].isPublic() && cinfos[i].isStatic() == false)
- result.add(cinfos[i]);
- }
- return result;
- }
-
- /**
- * Get the methods
- *
- * @param classInfo the class info
- * @return the methods
- */
- protected Set<MethodInfo> getMethods(ClassInfo classInfo)
- {
- HashSet<MethodInfo> result = new HashSet<MethodInfo>();
-
- while (classInfo != null)
- {
- MethodInfo[] minfos = classInfo.getDeclaredMethods();
- if (minfos != null && minfos.length > 0)
- {
- for (int i = 0; i < minfos.length; ++i)
- {
- if (result.contains(minfos[i]) == false && minfos[i].isPublic() && minfos[i].isStatic() == false && minfos[i].isVolatile() == false)
- result.add(minfos[i]);
- }
- }
-
- classInfo = classInfo.getSuperclass();
- }
-
- return result;
- }
-
- /**
- * Get the properties for a bean
- *
- * @param methods the methods
- * @return the properties
- */
- protected Set<PropertyInfo> getBeanProperties(Set<MethodInfo> methods)
- {
- HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
- HashMap<String, List<MethodInfo>> setters = new HashMap<String, List<MethodInfo>>();
- if (methods.isEmpty() == false)
- {
- for (MethodInfo methodInfo : methods)
- {
- String name = methodInfo.getName();
- if (isGetter(methodInfo))
- {
- String upperName = getUpperPropertyName(name);
- getters.put(upperName, methodInfo);
- }
- else if (isSetter(methodInfo))
- {
- String upperName = getUpperPropertyName(name);
- List<MethodInfo> list = setters.get(upperName);
- if (list == null)
- {
- list = new ArrayList<MethodInfo>();
- setters.put(upperName, list);
- }
- list.add(methodInfo);
- }
- }
- }
-
- HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
- if (getters.isEmpty() == false)
- {
- for (Iterator<Map.Entry<String, MethodInfo>> i = getters.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry<String, MethodInfo> entry = i.next();
- String name = entry.getKey();
- MethodInfo getter = entry.getValue();
- MethodInfo setter = null;
- List<MethodInfo> setterList = setters.remove(name);
- if (setterList != null && setterList.size() != 0)
- {
- for (int j = 0; j < setterList.size(); ++j)
- {
- MethodInfo thisSetter = setterList.get(j);
- TypeInfo pinfo = thisSetter.getParameterTypes()[0];
- if (getter.getReturnType().equals(pinfo) == true)
- {
- setter = thisSetter;
- break;
- }
- }
- }
- String lowerName = getLowerPropertyName(name);
-
- // Merge the annotations between the getters and setters
- AnnotationValue[] annotations = getter.getAnnotations();
- AnnotationValue[] setterAnnotations = null;
- if (setter != null)
- setterAnnotations = setter.getAnnotations();
- annotations = mergeAnnotations(annotations, setterAnnotations);
- TypeInfo type = getPropertyType(getter, setter);
- properties.add(new DefaultPropertyInfo(lowerName, name, type, getter, setter, annotations));
- }
- }
- if (setters.isEmpty() == false)
- {
- for (Iterator<Map.Entry<String, List<MethodInfo>>> i = setters.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry<String, List<MethodInfo>> entry = i.next();
- String name = entry.getKey();
- List<MethodInfo> setterList = entry.getValue();
- for(MethodInfo setter : setterList)
- {
- TypeInfo pinfo = setter.getParameterTypes()[0];
- String lowerName = getLowerPropertyName(name);
- AnnotationValue[] annotations = setter.getAnnotations();
- properties.add(new DefaultPropertyInfo(lowerName, name, pinfo, null, setter, annotations));
- }
- }
- }
- return properties;
- }
-
- /**
- * Merge annotations.
- *
- * @param first first array of annotations
- * @param second second array of annotations
- * @return merged annotations
- */
- static AnnotationValue[] mergeAnnotations(AnnotationValue[] first, AnnotationValue[] second)
- {
- if (first == null || first.length == 0)
- first = second;
- else if (second != null && second.length > 0)
- {
- HashSet<AnnotationValue> merged = new HashSet<AnnotationValue>();
- for (AnnotationValue annotation : first)
- merged.add(annotation);
- for (AnnotationValue annotation : second)
- merged.add(annotation);
- first = merged.toArray(new AnnotationValue[merged.size()]);
- }
- return first;
- }
-
- /**
- * Determine the type of PropertyInfo.
- *
- * @param getter the getter
- * @param setter the setter
- * @return property type
- */
- protected TypeInfo getPropertyType(MethodInfo getter, MethodInfo setter)
- {
- if (getter == null)
- throw new IllegalArgumentException("Getter should not be null!");
- if (setter == null)
- return getter.getReturnType();
- // TODO - determine more restrictive type among getter and setter
- return getter.getReturnType();
- }
-
- /**
- * Get the properties for an annotation
- *
- * @param methods the methods
- * @return the properties
- */
- protected Set<PropertyInfo> getAnnotationProperties(Set<MethodInfo> methods)
- {
- HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
- if (methods != null && methods.isEmpty() == false)
- {
- for (MethodInfo method : methods)
- {
- TypeInfo returnType = method.getReturnType();
- TypeInfo[] parameters = method.getParameterTypes();
- if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
- {
- String name = method.getName();
- properties.add(new DefaultPropertyInfo(name, name, returnType, method, null, method.getAnnotations()));
- }
- }
- }
- return properties;
- }
-
- /**
- * Get the events
- *
- * @param classInfo the class info
- * @return the events
- */
- protected Set<EventInfo> getEvents(ClassInfo classInfo)
- {
- return null;
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,410 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.BeanInfoFactory;
+import org.jboss.beans.info.spi.EventInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.PrimitiveInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.collection.WeakValueHashMap;
+
+/**
+ * A bean info factory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision$
+ */
+public class AbstractBeanInfoFactory implements BeanInfoFactory
+{
+ /** The cache */
+ protected Map<ClassLoader, Map<ClassInfo, Map<BeanAccessMode, BeanInfo>>> cache = new WeakHashMap<ClassLoader, Map<ClassInfo, Map<BeanAccessMode, BeanInfo>>>();
+
+ protected static boolean isGetter(MethodInfo minfo)
+ {
+ String name = minfo.getName();
+ TypeInfo returnType = minfo.getReturnType();
+ TypeInfo[] parameters = minfo.getParameterTypes();
+ if ((name.length() > 3 && name.startsWith("get")) || (name.length() > 2 && name.startsWith("is")))
+ {
+ // isBoolean() is not a getter for java.lang.Boolean
+ if (name.startsWith("is") && PrimitiveInfo.BOOLEAN.equals(returnType) == false)
+ return false;
+ if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
+ return true;
+ }
+ return false;
+ }
+
+ protected static boolean isSetter(MethodInfo minfo)
+ {
+ String name = minfo.getName();
+ TypeInfo returnType = minfo.getReturnType();
+ TypeInfo[] parameters = minfo.getParameterTypes();
+ if ((name.length() > 3 && name.startsWith("set")))
+ {
+ if (parameters.length == 1 && PrimitiveInfo.VOID.equals(returnType))
+ return true;
+ }
+ return false;
+ }
+
+ protected static String getUpperPropertyName(String name)
+ {
+ int start = 3;
+ if (name.startsWith("is"))
+ start = 2;
+
+ return name.substring(start);
+ }
+
+ protected static String getLowerPropertyName(String name)
+ {
+ // If the second character is upper case then we don't make
+ // the first character lower case
+ if (name.length() > 1)
+ {
+ if (Character.isUpperCase(name.charAt(1)))
+ return name;
+ }
+
+ JBossStringBuilder buffer = new JBossStringBuilder(name.length());
+ buffer.append(Character.toLowerCase(name.charAt(0)));
+ if (name.length() > 1)
+ buffer.append(name.substring(1));
+ return buffer.toString();
+ }
+
+ /**
+ * Create a new bean info factory
+ */
+ public AbstractBeanInfoFactory()
+ {
+ }
+
+ public BeanInfo getBeanInfo(ClassAdapter classAdapter)
+ {
+ return getBeanInfo(classAdapter, BeanAccessMode.STANDARD);
+ }
+
+ public BeanInfo getBeanInfo(ClassAdapter classAdapter, BeanAccessMode accessMode)
+ {
+ if (classAdapter == null)
+ throw new IllegalArgumentException("Null class adapter.");
+ if (accessMode == null)
+ accessMode = BeanAccessMode.STANDARD;
+
+ synchronized (cache)
+ {
+ ClassLoader cl = classAdapter.getClassLoader();
+ ClassInfo classInfo = classAdapter.getClassInfo();
+ Map<ClassInfo, Map<BeanAccessMode, BeanInfo>> classInfoMap = cache.get(cl);
+ Map<BeanAccessMode, BeanInfo> modeMap = null;
+ if (classInfoMap != null)
+ {
+ modeMap = classInfoMap.get(classInfo);
+ if (modeMap != null)
+ {
+ BeanInfo info = modeMap.get(accessMode);
+ if (info != null)
+ return info;
+ }
+ }
+
+ Set<ConstructorInfo> constructors = getConstructors(classInfo);
+ Set<MethodInfo> methods = getMethods(classInfo);
+ Set<PropertyInfo> properties;
+ if (classInfo.isAnnotation())
+ properties = getAnnotationProperties(methods);
+ else
+ properties = getBeanProperties(methods);
+ Set<EventInfo> events = getEvents(classInfo);
+
+ BeanInfo result = createBeanInfo(classAdapter, accessMode, properties, constructors, methods, events);
+ if (classInfoMap == null)
+ {
+ classInfoMap = new WeakHashMap<ClassInfo, Map<BeanAccessMode, BeanInfo>>();
+ cache.put(cl, classInfoMap);
+ }
+ if (modeMap == null)
+ {
+ modeMap = new WeakValueHashMap<BeanAccessMode, BeanInfo>();
+ classInfoMap.put(classInfo, modeMap);
+ }
+ modeMap.put(accessMode, result);
+ return result;
+ }
+ }
+
+ /**
+ * Create the bean info
+ *
+ * @param classAdapter the class adapter
+ * @param accessMode the access mode
+ * @param properties the properties
+ * @param constructors the constructors
+ * @param methods the methods
+ * @param events the events
+ * @return the bean info
+ */
+ protected BeanInfo createBeanInfo(
+ ClassAdapter classAdapter,
+ BeanAccessMode accessMode,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
+ {
+ return accessMode.create(this, classAdapter, properties, constructors, methods, events);
+ }
+
+ /**
+ * Get the constructors
+ *
+ * @param classInfo the class info
+ * @return the constructors
+ */
+ protected Set<ConstructorInfo> getConstructors(ClassInfo classInfo)
+ {
+ ConstructorInfo[] cinfos = classInfo.getDeclaredConstructors();
+ if (cinfos == null || cinfos.length == 0)
+ return null;
+
+ HashSet<ConstructorInfo> result = new HashSet<ConstructorInfo>();
+ for (int i = 0; i < cinfos.length; ++i)
+ {
+ if (cinfos[i].isPublic() && cinfos[i].isStatic() == false)
+ result.add(cinfos[i]);
+ }
+ return result;
+ }
+
+ /**
+ * Get the methods
+ *
+ * @param classInfo the class info
+ * @return the methods
+ */
+ protected Set<MethodInfo> getMethods(ClassInfo classInfo)
+ {
+ HashSet<MethodInfo> result = new HashSet<MethodInfo>();
+
+ while (classInfo != null)
+ {
+ MethodInfo[] minfos = classInfo.getDeclaredMethods();
+ if (minfos != null && minfos.length > 0)
+ {
+ for (int i = 0; i < minfos.length; ++i)
+ {
+ if (result.contains(minfos[i]) == false && minfos[i].isPublic() && minfos[i].isStatic() == false && minfos[i].isVolatile() == false)
+ result.add(minfos[i]);
+ }
+ }
+
+ classInfo = classInfo.getSuperclass();
+ }
+
+ return result;
+ }
+
+ /**
+ * Get the properties for a bean
+ *
+ * @param methods the methods
+ * @return the properties
+ */
+ protected Set<PropertyInfo> getBeanProperties(Set<MethodInfo> methods)
+ {
+ HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
+ HashMap<String, List<MethodInfo>> setters = new HashMap<String, List<MethodInfo>>();
+ if (methods.isEmpty() == false)
+ {
+ for (MethodInfo methodInfo : methods)
+ {
+ String name = methodInfo.getName();
+ if (isGetter(methodInfo))
+ {
+ String upperName = getUpperPropertyName(name);
+ getters.put(upperName, methodInfo);
+ }
+ else if (isSetter(methodInfo))
+ {
+ String upperName = getUpperPropertyName(name);
+ List<MethodInfo> list = setters.get(upperName);
+ if (list == null)
+ {
+ list = new ArrayList<MethodInfo>();
+ setters.put(upperName, list);
+ }
+ list.add(methodInfo);
+ }
+ }
+ }
+
+ HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
+ if (getters.isEmpty() == false)
+ {
+ for (Iterator<Map.Entry<String, MethodInfo>> i = getters.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry<String, MethodInfo> entry = i.next();
+ String name = entry.getKey();
+ MethodInfo getter = entry.getValue();
+ MethodInfo setter = null;
+ List<MethodInfo> setterList = setters.remove(name);
+ if (setterList != null && setterList.size() != 0)
+ {
+ for (int j = 0; j < setterList.size(); ++j)
+ {
+ MethodInfo thisSetter = setterList.get(j);
+ TypeInfo pinfo = thisSetter.getParameterTypes()[0];
+ if (getter.getReturnType().equals(pinfo) == true)
+ {
+ setter = thisSetter;
+ break;
+ }
+ }
+ }
+ String lowerName = getLowerPropertyName(name);
+
+ // Merge the annotations between the getters and setters
+ AnnotationValue[] annotations = getter.getAnnotations();
+ AnnotationValue[] setterAnnotations = null;
+ if (setter != null)
+ setterAnnotations = setter.getAnnotations();
+ annotations = mergeAnnotations(annotations, setterAnnotations);
+ TypeInfo type = getPropertyType(getter, setter);
+ properties.add(new DefaultPropertyInfo(lowerName, name, type, getter, setter, annotations));
+ }
+ }
+ if (setters.isEmpty() == false)
+ {
+ for (Iterator<Map.Entry<String, List<MethodInfo>>> i = setters.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry<String, List<MethodInfo>> entry = i.next();
+ String name = entry.getKey();
+ List<MethodInfo> setterList = entry.getValue();
+ for(MethodInfo setter : setterList)
+ {
+ TypeInfo pinfo = setter.getParameterTypes()[0];
+ String lowerName = getLowerPropertyName(name);
+ AnnotationValue[] annotations = setter.getAnnotations();
+ properties.add(new DefaultPropertyInfo(lowerName, name, pinfo, null, setter, annotations));
+ }
+ }
+ }
+ return properties;
+ }
+
+ /**
+ * Merge annotations.
+ *
+ * @param first first array of annotations
+ * @param second second array of annotations
+ * @return merged annotations
+ */
+ static AnnotationValue[] mergeAnnotations(AnnotationValue[] first, AnnotationValue[] second)
+ {
+ if (first == null || first.length == 0)
+ first = second;
+ else if (second != null && second.length > 0)
+ {
+ HashSet<AnnotationValue> merged = new HashSet<AnnotationValue>();
+ for (AnnotationValue annotation : first)
+ merged.add(annotation);
+ for (AnnotationValue annotation : second)
+ merged.add(annotation);
+ first = merged.toArray(new AnnotationValue[merged.size()]);
+ }
+ return first;
+ }
+
+ /**
+ * Determine the type of PropertyInfo.
+ *
+ * @param getter the getter
+ * @param setter the setter
+ * @return property type
+ */
+ protected TypeInfo getPropertyType(MethodInfo getter, MethodInfo setter)
+ {
+ if (getter == null)
+ throw new IllegalArgumentException("Getter should not be null!");
+ if (setter == null)
+ return getter.getReturnType();
+ // TODO - determine more restrictive type among getter and setter
+ return getter.getReturnType();
+ }
+
+ /**
+ * Get the properties for an annotation
+ *
+ * @param methods the methods
+ * @return the properties
+ */
+ protected Set<PropertyInfo> getAnnotationProperties(Set<MethodInfo> methods)
+ {
+ HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
+ if (methods != null && methods.isEmpty() == false)
+ {
+ for (MethodInfo method : methods)
+ {
+ TypeInfo returnType = method.getReturnType();
+ TypeInfo[] parameters = method.getParameterTypes();
+ if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
+ {
+ String name = method.getName();
+ properties.add(new DefaultPropertyInfo(name, name, returnType, method, null, method.getAnnotations()));
+ }
+ }
+ }
+ return properties;
+ }
+
+ /**
+ * Get the events
+ *
+ * @param classInfo the class info
+ * @return the events
+ */
+ protected Set<EventInfo> getEvents(ClassInfo classInfo)
+ {
+ return null;
+ }
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/joinpoint/plugins/Config.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,465 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.joinpoint.plugins;
-
-import java.util.Arrays;
-
-import org.jboss.joinpoint.spi.ConstructorJoinpoint;
-import org.jboss.joinpoint.spi.FieldGetJoinpoint;
-import org.jboss.joinpoint.spi.FieldSetJoinpoint;
-import org.jboss.joinpoint.spi.JoinpointException;
-import org.jboss.joinpoint.spi.JoinpointFactory;
-import org.jboss.joinpoint.spi.MethodJoinpoint;
-import org.jboss.logging.Logger;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
-
-/**
- * Config utilities.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class Config
-{
- /** The log */
- protected static final Logger log = Logger.getLogger(Config.class);
-
- /** No parameter types */
- private static final String[] NO_PARAMS_TYPES = new String[0];
-
- /** No parameters */
- private static final Object[] NO_PARAMS = new Object[0];
-
- /**
- * Instantiate an object
- *
- * @param jpf the join point factory
- * @param paramTypes the parameter types
- * @param params the parameters
- * @return the instantiated object
- * @throws Throwable for any error
- */
- public static Object instantiate(JoinpointFactory jpf, String[] paramTypes, Object[] params) throws Throwable
- {
- ConstructorJoinpoint joinpoint = getConstructorJoinpoint(jpf, paramTypes, params);
- return joinpoint.dispatch();
- }
-
- /**
- * Configure a field
- *
- * @param object the object to configure
- * @param jpf the join point factory
- * @param name the name of the field
- * @param value the value
- * @throws Throwable for any error
- */
- public static void configure(Object object, JoinpointFactory jpf, String name, Object value) throws Throwable
- {
- FieldSetJoinpoint joinpoint = getFieldSetJoinpoint(object, jpf, name, value);
- joinpoint.dispatch();
- }
-
- /**
- * Unconfigure a field
- *
- * @param object the object to unconfigure
- * @param jpf the join point factory
- * @param name the name of the field
- * @throws Throwable for any error
- */
- public static void unconfigure(Object object, JoinpointFactory jpf, String name) throws Throwable
- {
- FieldSetJoinpoint joinpoint = getFieldSetJoinpoint(object, jpf, name, null);
- joinpoint.dispatch();
- }
-
- /**
- * Invoke a method
- *
- * @param object the object to invoke
- * @param jpf the join point factory
- * @param name the name of the method
- * @param paramTypes the parameter types
- * @param params the parameters
- * @return the result of the invocation
- * @throws Throwable for any error
- */
- public static Object invoke(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
- {
- MethodJoinpoint joinpoint = getMethodJoinpoint(object, jpf, name, paramTypes, params);
- return joinpoint.dispatch();
- }
-
- /**
- * Get a constructor Joinpoint
- *
- * @param jpf the join point factory
- * @return the Joinpoint
- * @throws Throwable for any error
- */
- public static ConstructorJoinpoint getConstructorJoinpoint(JoinpointFactory jpf) throws Throwable
- {
- return getConstructorJoinpoint(jpf, null, null);
- }
-
- /**
- * Get a constructor Joinpoint
- *
- * @param jpf the join point factory
- * @param paramTypes the parameter types
- * @param params the parameters
- * @return the Joinpoint
- * @throws Throwable for any error
- */
- public static ConstructorJoinpoint getConstructorJoinpoint(JoinpointFactory jpf, String[] paramTypes, Object[] params) throws Throwable
- {
- if (paramTypes == null)
- paramTypes = NO_PARAMS_TYPES;
-
- if (params == null)
- params = NO_PARAMS;
-
- boolean trace = log.isTraceEnabled();
- if (trace)
- log.trace("Get constructor Joinpoint jpf=" + jpf + " paramTypes=" + Arrays.asList(paramTypes) + " params=" + Arrays.asList(params));
-
- ConstructorInfo constructorInfo = findConstructorInfo(jpf.getClassInfo(), paramTypes);
- ConstructorJoinpoint joinpoint = jpf.getConstructorJoinpoint(constructorInfo);
- joinpoint.setArguments(params);
- return joinpoint;
- }
-
- /**
- * Get a field get joinpoint
- *
- * @param object the object to configure
- * @param jpf the join point factory
- * @param name the name of the field
- * @return the Joinpoint
- * @throws Throwable for any error
- */
- public static FieldGetJoinpoint getFieldGetJoinpoint(Object object, JoinpointFactory jpf, String name) throws Throwable
- {
- boolean trace = log.isTraceEnabled();
- if (trace)
- log.trace("Get field get Joinpoint jpf=" + jpf + " target=" + object + " name=" + name);
-
- FieldInfo fieldInfo = findFieldInfo(jpf.getClassInfo(), name);
- FieldGetJoinpoint joinpoint = jpf.getFieldGetJoinpoint(fieldInfo);
- joinpoint.setTarget(object);
- return joinpoint;
- }
-
- /**
- * Get a field set joinpoint
- *
- * @param object the object to configure
- * @param jpf the join point factory
- * @param name the name of the field
- * @param value the value
- * @return the Joinpoint
- * @throws Throwable for any error
- */
- public static FieldSetJoinpoint getFieldSetJoinpoint(Object object, JoinpointFactory jpf, String name, Object value) throws Throwable
- {
- boolean trace = log.isTraceEnabled();
- if (trace)
- log.trace("Get field set Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " value=" + value);
-
- FieldInfo fieldInfo = findFieldInfo(jpf.getClassInfo(), name);
- FieldSetJoinpoint joinpoint = jpf.getFieldSetJoinpoint(fieldInfo);
- joinpoint.setTarget(object);
- joinpoint.setValue(value);
- return joinpoint;
- }
-
- /**
- * Get a method joinpoint
- *
- * @param object the object to invoke
- * @param jpf the join point factory
- * @param name the name of the method
- * @param paramTypes the parameter types
- * @param params the parameters
- * @return the join point
- * @throws Throwable for any error
- */
- public static MethodJoinpoint getMethodJoinpoint(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
- {
- boolean trace = log.isTraceEnabled();
- if (trace)
- {
- if (paramTypes != null)
- log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
- else
- log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=()");
- }
-
- MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes);
- MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
- joinpoint.setTarget(object);
- joinpoint.setArguments(params);
- return joinpoint;
- }
-
- /**
- * Get a static method joinpoint
- *
- * @param jpf the join point factory
- * @param name the name of the method
- * @param paramTypes the parameter types
- * @param params the parameters
- * @return the join point
- * @throws Throwable for any error
- */
- public static MethodJoinpoint getStaticMethodJoinpoint(JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
- {
- boolean trace = log.isTraceEnabled();
- if (trace)
- {
- if (paramTypes != null)
- log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
- else
- log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=()");
- }
-
- MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes, true, true);
- MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
- joinpoint.setArguments(params);
- return joinpoint;
- }
-
- /**
- * Find constructor info
- *
- * @param classInfo the class info
- * @param paramTypes the parameter types
- * @return the constructor info
- * @throws JoinpointException when no such constructor
- */
- public static ConstructorInfo findConstructorInfo(ClassInfo classInfo, String[] paramTypes) throws JoinpointException
- {
- ConstructorInfo[] constructors = classInfo.getDeclaredConstructors();
- if (constructors != null)
- {
- for (int i = 0; i < constructors.length; ++i)
- {
- if (equals(paramTypes, constructors[i].getParameterTypes()))
- return constructors[i];
- }
- throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " in " + Arrays.asList(constructors));
- }
- throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " no constructors");
- }
-
- /**
- * Find field info
- *
- * @param classInfo the class info
- * @param name the field name
- * @return the field info
- * @throws JoinpointException when no such field
- */
- public static FieldInfo findFieldInfo(ClassInfo classInfo, String name) throws JoinpointException
- {
- if (classInfo == null)
- throw new IllegalArgumentException("ClassInfo cannot be null!");
- ClassInfo current = classInfo;
- while (current != null)
- {
- FieldInfo result = locateFieldInfo(current, name);
- if (result != null)
- return result;
- current = current.getSuperclass();
- }
- throw new JoinpointException("Field not found '" + name + "' for class " + classInfo.getName());
- }
-
- /**
- * Find field info
- *
- * @param classInfo the class info
- * @param name the field name
- * @return the field info or null if not found
- */
- private static FieldInfo locateFieldInfo(ClassInfo classInfo, String name)
- {
- FieldInfo[] fields = classInfo.getDeclaredFields();
- if (fields != null)
- {
- for (int i = 0; i < fields.length; ++i)
- {
- if (name.equals(fields[i].getName()))
- return fields[i];
- }
- }
- return null;
- }
-
- /**
- * Find method info
- *
- * @param classInfo the class info
- * @param name the method name
- * @param paramTypes the parameter types
- * @return the method info
- * @throws JoinpointException when no such method
- */
- public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes) throws JoinpointException
- {
- return findMethodInfo(classInfo, name, paramTypes, false, true);
- }
-
- /**
- * Find method info
- *
- * @param classInfo the class info
- * @param name the method name
- * @param paramTypes the parameter types
- * @param strict is strict about method modifiers
- * @return the method info
- * @throws JoinpointException when no such method
- */
- public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean strict) throws JoinpointException
- {
- return findMethodInfo(classInfo, name, paramTypes, false, true, strict);
- }
-
- /**
- * Find method info
- *
- * @param classInfo the class info
- * @param name the method name
- * @param paramTypes the parameter types
- * @param isStatic must the method be static
- * @param isPublic must the method be public
- * @return the method info
- * @throws JoinpointException when no such method
- */
- public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic) throws JoinpointException
- {
- return findMethodInfo(classInfo, name, paramTypes, isStatic, isPublic, true);
- }
-
- /**
- * Find method info
- *
- * @param classInfo the class info
- * @param name the method name
- * @param paramTypes the parameter types
- * @param isStatic must the method be static
- * @param isPublic must the method be public
- * @param strict is strict about method modifiers
- * @return the method info
- * @throws JoinpointException when no such method
- */
- public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict) throws JoinpointException
- {
- if (name == null)
- throw new IllegalArgumentException("Null name");
-
- if (classInfo == null)
- throw new IllegalArgumentException("ClassInfo cannot be null!");
-
- if (paramTypes == null)
- paramTypes = NO_PARAMS_TYPES;
-
- ClassInfo current = classInfo;
- while (current != null)
- {
- MethodInfo result = locateMethodInfo(current, name, paramTypes, isStatic, isPublic, strict);
- if (result != null)
- return result;
- current = current.getSuperclass();
- }
- throw new JoinpointException("Method not found " + name + Arrays.asList(paramTypes) + " for class " + classInfo.getName());
- }
-
- /**
- * Find method info
- *
- * @param classInfo the class info
- * @param name the method name
- * @param paramTypes the parameter types
- * @param isStatic must the method be static
- * @param isPublic must the method be public
- * @param strict is strict about method modifiers
- * @return the method info or null if not found
- */
- private static MethodInfo locateMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict)
- {
- MethodInfo[] methods = classInfo.getDeclaredMethods();
- if (methods != null)
- {
- for (int i = 0; i < methods.length; ++i)
- {
- if (name.equals(methods[i].getName()) &&
- equals(paramTypes, methods[i].getParameterTypes()) &&
- (strict == false || (methods[i].isStatic() == isStatic && methods[i].isPublic() == isPublic)))
- return methods[i];
- }
- }
- return null;
- }
-
- /**
- * Test whether type names are equal to type infos
- *
- * @param typeNames the type names
- * @param typeInfos the type infos
- * @return true when they are equal
- */
- public static boolean equals(String[] typeNames, TypeInfo[] typeInfos)
- {
- if (simpleCheck(typeNames, typeInfos) == false)
- return false;
-
- for (int i = 0; i < typeNames.length; ++i)
- {
- if (typeNames[i] != null && typeNames[i].equals(typeInfos[i].getName()) == false)
- return false;
- }
- return true;
- }
-
- /**
- * A simple null and length check.
- *
- * @param typeNames
- * @param typeInfos
- * @return false if either argument is null or lengths differ, else true
- */
- protected static boolean simpleCheck(String[] typeNames, TypeInfo[] typeInfos)
- {
- if (typeNames == null || typeInfos == null)
- {
- return false;
- }
- return typeNames.length == typeInfos.length;
- }
-
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java (from rev 81413, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/joinpoint/plugins/Config.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/joinpoint/plugins/Config.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,461 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.joinpoint.plugins;
+
+import java.util.Arrays;
+
+import org.jboss.joinpoint.spi.ConstructorJoinpoint;
+import org.jboss.joinpoint.spi.FieldGetJoinpoint;
+import org.jboss.joinpoint.spi.FieldSetJoinpoint;
+import org.jboss.joinpoint.spi.JoinpointException;
+import org.jboss.joinpoint.spi.JoinpointFactory;
+import org.jboss.joinpoint.spi.MethodJoinpoint;
+import org.jboss.logging.Logger;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * Config utilities.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision$
+ */
+public class Config
+{
+ /** The log */
+ protected static final Logger log = Logger.getLogger(Config.class);
+
+ /** No parameter types */
+ private static final String[] NO_PARAMS_TYPES = new String[0];
+
+ /** No parameters */
+ private static final Object[] NO_PARAMS = new Object[0];
+
+ /**
+ * Instantiate an object
+ *
+ * @param jpf the join point factory
+ * @param paramTypes the parameter types
+ * @param params the parameters
+ * @return the instantiated object
+ * @throws Throwable for any error
+ */
+ public static Object instantiate(JoinpointFactory jpf, String[] paramTypes, Object[] params) throws Throwable
+ {
+ ConstructorJoinpoint joinpoint = getConstructorJoinpoint(jpf, paramTypes, params);
+ return joinpoint.dispatch();
+ }
+
+ /**
+ * Configure a field
+ *
+ * @param object the object to configure
+ * @param jpf the join point factory
+ * @param name the name of the field
+ * @param value the value
+ * @throws Throwable for any error
+ */
+ public static void configure(Object object, JoinpointFactory jpf, String name, Object value) throws Throwable
+ {
+ FieldSetJoinpoint joinpoint = getFieldSetJoinpoint(object, jpf, name, value);
+ joinpoint.dispatch();
+ }
+
+ /**
+ * Unconfigure a field
+ *
+ * @param object the object to unconfigure
+ * @param jpf the join point factory
+ * @param name the name of the field
+ * @throws Throwable for any error
+ */
+ public static void unconfigure(Object object, JoinpointFactory jpf, String name) throws Throwable
+ {
+ FieldSetJoinpoint joinpoint = getFieldSetJoinpoint(object, jpf, name, null);
+ joinpoint.dispatch();
+ }
+
+ /**
+ * Invoke a method
+ *
+ * @param object the object to invoke
+ * @param jpf the join point factory
+ * @param name the name of the method
+ * @param paramTypes the parameter types
+ * @param params the parameters
+ * @return the result of the invocation
+ * @throws Throwable for any error
+ */
+ public static Object invoke(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
+ {
+ MethodJoinpoint joinpoint = getMethodJoinpoint(object, jpf, name, paramTypes, params);
+ return joinpoint.dispatch();
+ }
+
+ /**
+ * Get a constructor Joinpoint
+ *
+ * @param jpf the join point factory
+ * @return the Joinpoint
+ * @throws Throwable for any error
+ */
+ public static ConstructorJoinpoint getConstructorJoinpoint(JoinpointFactory jpf) throws Throwable
+ {
+ return getConstructorJoinpoint(jpf, null, null);
+ }
+
+ /**
+ * Get a constructor Joinpoint
+ *
+ * @param jpf the join point factory
+ * @param paramTypes the parameter types
+ * @param params the parameters
+ * @return the Joinpoint
+ * @throws Throwable for any error
+ */
+ public static ConstructorJoinpoint getConstructorJoinpoint(JoinpointFactory jpf, String[] paramTypes, Object[] params) throws Throwable
+ {
+ if (paramTypes == null)
+ paramTypes = NO_PARAMS_TYPES;
+
+ if (params == null)
+ params = NO_PARAMS;
+
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Get constructor Joinpoint jpf=" + jpf + " paramTypes=" + Arrays.asList(paramTypes) + " params=" + Arrays.asList(params));
+
+ ConstructorInfo constructorInfo = findConstructorInfo(jpf.getClassInfo(), paramTypes);
+ ConstructorJoinpoint joinpoint = jpf.getConstructorJoinpoint(constructorInfo);
+ joinpoint.setArguments(params);
+ return joinpoint;
+ }
+
+ /**
+ * Get a field get joinpoint
+ *
+ * @param object the object to configure
+ * @param jpf the join point factory
+ * @param name the name of the field
+ * @return the Joinpoint
+ * @throws Throwable for any error
+ */
+ public static FieldGetJoinpoint getFieldGetJoinpoint(Object object, JoinpointFactory jpf, String name) throws Throwable
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Get field get Joinpoint jpf=" + jpf + " target=" + object + " name=" + name);
+
+ FieldInfo fieldInfo = findFieldInfo(jpf.getClassInfo(), name);
+ FieldGetJoinpoint joinpoint = jpf.getFieldGetJoinpoint(fieldInfo);
+ joinpoint.setTarget(object);
+ return joinpoint;
+ }
+
+ /**
+ * Get a field set joinpoint
+ *
+ * @param object the object to configure
+ * @param jpf the join point factory
+ * @param name the name of the field
+ * @param value the value
+ * @return the Joinpoint
+ * @throws Throwable for any error
+ */
+ public static FieldSetJoinpoint getFieldSetJoinpoint(Object object, JoinpointFactory jpf, String name, Object value) throws Throwable
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Get field set Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " value=" + value);
+
+ FieldInfo fieldInfo = findFieldInfo(jpf.getClassInfo(), name);
+ FieldSetJoinpoint joinpoint = jpf.getFieldSetJoinpoint(fieldInfo);
+ joinpoint.setTarget(object);
+ joinpoint.setValue(value);
+ return joinpoint;
+ }
+
+ /**
+ * Get a method joinpoint
+ *
+ * @param object the object to invoke
+ * @param jpf the join point factory
+ * @param name the name of the method
+ * @param paramTypes the parameter types
+ * @param params the parameters
+ * @return the join point
+ * @throws Throwable for any error
+ */
+ public static MethodJoinpoint getMethodJoinpoint(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ {
+ if (paramTypes != null)
+ log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
+ else
+ log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=()");
+ }
+
+ MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes);
+ MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
+ joinpoint.setTarget(object);
+ joinpoint.setArguments(params);
+ return joinpoint;
+ }
+
+ /**
+ * Get a static method joinpoint
+ *
+ * @param jpf the join point factory
+ * @param name the name of the method
+ * @param paramTypes the parameter types
+ * @param params the parameters
+ * @return the join point
+ * @throws Throwable for any error
+ */
+ public static MethodJoinpoint getStaticMethodJoinpoint(JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ {
+ if (paramTypes != null)
+ log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
+ else
+ log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=()");
+ }
+
+ MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes, true, true);
+ MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
+ joinpoint.setArguments(params);
+ return joinpoint;
+ }
+
+ /**
+ * Find constructor info
+ *
+ * @param classInfo the class info
+ * @param paramTypes the parameter types
+ * @return the constructor info
+ * @throws JoinpointException when no such constructor
+ */
+ public static ConstructorInfo findConstructorInfo(ClassInfo classInfo, String[] paramTypes) throws JoinpointException
+ {
+ ConstructorInfo[] constructors = classInfo.getDeclaredConstructors();
+ if (constructors != null)
+ {
+ for (ConstructorInfo constructor : constructors)
+ {
+ if (equals(paramTypes, constructor.getParameterTypes()))
+ return constructor;
+ }
+ throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " in " + Arrays.asList(constructors));
+ }
+ throw new JoinpointException("Constructor not found " + classInfo.getName() + Arrays.asList(paramTypes) + " no constructors");
+ }
+
+ /**
+ * Find field info
+ *
+ * @param classInfo the class info
+ * @param name the field name
+ * @return the field info
+ * @throws JoinpointException when no such field
+ */
+ public static FieldInfo findFieldInfo(ClassInfo classInfo, String name) throws JoinpointException
+ {
+ if (classInfo == null)
+ throw new IllegalArgumentException("ClassInfo cannot be null!");
+ ClassInfo current = classInfo;
+ while (current != null)
+ {
+ FieldInfo result = locateFieldInfo(current, name);
+ if (result != null)
+ return result;
+ current = current.getSuperclass();
+ }
+ throw new JoinpointException("Field not found '" + name + "' for class " + classInfo.getName());
+ }
+
+ /**
+ * Find field info
+ *
+ * @param classInfo the class info
+ * @param name the field name
+ * @return the field info or null if not found
+ */
+ private static FieldInfo locateFieldInfo(ClassInfo classInfo, String name)
+ {
+ FieldInfo[] fields = classInfo.getDeclaredFields();
+ if (fields != null)
+ {
+ for (FieldInfo field : fields)
+ {
+ if (name.equals(field.getName()))
+ return field;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Find method info
+ *
+ * @param classInfo the class info
+ * @param name the method name
+ * @param paramTypes the parameter types
+ * @return the method info
+ * @throws JoinpointException when no such method
+ */
+ public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes) throws JoinpointException
+ {
+ return findMethodInfo(classInfo, name, paramTypes, false, true);
+ }
+
+ /**
+ * Find method info
+ *
+ * @param classInfo the class info
+ * @param name the method name
+ * @param paramTypes the parameter types
+ * @param strict is strict about method modifiers
+ * @return the method info
+ * @throws JoinpointException when no such method
+ */
+ public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean strict) throws JoinpointException
+ {
+ return findMethodInfo(classInfo, name, paramTypes, false, true, strict);
+ }
+
+ /**
+ * Find method info
+ *
+ * @param classInfo the class info
+ * @param name the method name
+ * @param paramTypes the parameter types
+ * @param isStatic must the method be static
+ * @param isPublic must the method be public
+ * @return the method info
+ * @throws JoinpointException when no such method
+ */
+ public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic) throws JoinpointException
+ {
+ return findMethodInfo(classInfo, name, paramTypes, isStatic, isPublic, true);
+ }
+
+ /**
+ * Find method info
+ *
+ * @param classInfo the class info
+ * @param name the method name
+ * @param paramTypes the parameter types
+ * @param isStatic must the method be static
+ * @param isPublic must the method be public
+ * @param strict is strict about method modifiers
+ * @return the method info
+ * @throws JoinpointException when no such method
+ */
+ public static MethodInfo findMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict) throws JoinpointException
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+
+ if (classInfo == null)
+ throw new IllegalArgumentException("ClassInfo cannot be null!");
+
+ if (paramTypes == null)
+ paramTypes = NO_PARAMS_TYPES;
+
+ ClassInfo current = classInfo;
+ while (current != null)
+ {
+ MethodInfo result = locateMethodInfo(current, name, paramTypes, isStatic, isPublic, strict);
+ if (result != null)
+ return result;
+ current = current.getSuperclass();
+ }
+ throw new JoinpointException("Method not found " + name + Arrays.asList(paramTypes) + " for class " + classInfo.getName());
+ }
+
+ /**
+ * Find method info
+ *
+ * @param classInfo the class info
+ * @param name the method name
+ * @param paramTypes the parameter types
+ * @param isStatic must the method be static
+ * @param isPublic must the method be public
+ * @param strict is strict about method modifiers
+ * @return the method info or null if not found
+ */
+ private static MethodInfo locateMethodInfo(ClassInfo classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict)
+ {
+ MethodInfo[] methods = classInfo.getDeclaredMethods();
+ if (methods != null)
+ {
+ for (MethodInfo method : methods)
+ {
+ if (name.equals(method.getName()) &&
+ equals(paramTypes, method.getParameterTypes()) &&
+ (strict == false || (method.isStatic() == isStatic && method.isPublic() == isPublic)))
+ return method;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Test whether type names are equal to type infos
+ *
+ * @param typeNames the type names
+ * @param typeInfos the type infos
+ * @return true when they are equal
+ */
+ public static boolean equals(String[] typeNames, TypeInfo[] typeInfos)
+ {
+ if (simpleCheck(typeNames, typeInfos) == false)
+ return false;
+
+ for (int i = 0; i < typeNames.length; ++i)
+ {
+ if (typeNames[i] != null && typeNames[i].equals(typeInfos[i].getName()) == false)
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * A simple null and length check.
+ *
+ * @param typeNames the type names
+ * @param typeInfos the type infos
+ * @return false if either argument is null or lengths differ, else true
+ */
+ protected static boolean simpleCheck(String[] typeNames, TypeInfo[] typeInfos)
+ {
+ return typeNames != null && typeInfos != null && typeNames.length == typeInfos.length;
+ }
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,671 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.reflect.plugins;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.DelegateClassInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.InterfaceInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.PackageInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * Class info
- *
- * TODO JBMICROCONT-118 fix the introspection assumption
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- */
-public class ClassInfoImpl extends InheritableAnnotationHolder implements ClassInfo
-{
- /** serialVersionUID */
- private static final long serialVersionUID = 3545798779904340792L;
-
- /** Marker for generation */
- public static final ClassInfo UNKNOWN_CLASS = new DelegateClassInfo(null, true);
-
- /** Marker for generation */
- public static final ClassInfo[] UNKNOWN_CLASSES = new ClassInfo[0];
-
- /** Marker for generation */
- public static final TypeInfo UNKNOWN_TYPE = UNKNOWN_CLASS;
-
- /** Marker for generation */
- public static final TypeInfo[] UNKNOWN_TYPES = new TypeInfo[0];
-
- /** Marker for generation */
- public static final InterfaceInfo[] UNKNOWN_INTERFACES = new InterfaceInfo[0];
-
- /** Marker for generation */
- public static final ConstructorInfo[] UNKNOWN_CONSTRUCTORS = new ConstructorInfo[0];
-
- /** Marker for generation */
- public static final MethodInfo[] UNKNOWN_METHODS = new MethodInfo[0];
-
- /** Marker for generation */
- public static final FieldInfo[] UNKNOWN_FIELDS = new FieldInfo[0];
-
- /** The class name */
- protected String name;
-
- /** The class modifiers */
- protected int modifiers;
-
- /** The interfaces */
- protected InterfaceInfo[] interfaces = UNKNOWN_INTERFACES;
-
- /** The generic interfaces */
- protected InterfaceInfo[] genericInterfaces = UNKNOWN_INTERFACES;
-
- /** The methods */
- protected MethodInfo[] methods = UNKNOWN_METHODS;
-
- /** The fields */
- protected FieldInfo[] fields = UNKNOWN_FIELDS;
-
- /** Field map Map<String, FieldInfo> */
- protected HashMap<String, FieldInfo> fieldMap;
-
- /** The super class */
- protected ClassInfo superclass = UNKNOWN_CLASS;
-
- /** The generic super class */
- protected ClassInfo genericSuperclass = UNKNOWN_CLASS;
-
- /** The constructor info */
- protected ConstructorInfo[] constructors = UNKNOWN_CONSTRUCTORS;
-
- /** The package info */
- protected PackageInfo packageInfo;
-
- /** The component type */
- private transient TypeInfo componentType = ClassInfoImpl.UNKNOWN_TYPE;
-
- /** The key type */
- private transient TypeInfo keyType = ClassInfoImpl.UNKNOWN_TYPE;
-
- /** The key type */
- private transient TypeInfo valueType = ClassInfoImpl.UNKNOWN_TYPE;
-
- /** The class info helper */
- protected transient ClassInfoHelper classInfoHelper;
-
- /** The type info factory */
- protected transient TypeInfoFactory typeInfoFactory;
-
- /** The attachments */
- private transient TypeInfoAttachments attachments;
-
- /**
- * Create a new abstract ClassInfo.
- */
- public ClassInfoImpl()
- {
- }
-
- /**
- * Create a new class info
- *
- * @param name the class name
- */
- public ClassInfoImpl(String name)
- {
- this.name = name;
- }
-
- /**
- * Create a new abstract ClassInfo.
- *
- * @param name the class name
- * @param modifiers the class modifiers
- */
- public ClassInfoImpl(String name, int modifiers)
- {
- this.name = name;
- this.modifiers = modifiers;
- }
-
- /**
- * Create a new abstract ClassInfo.
- *
- * @param name the class name
- * @param modifiers the class modifiers
- * @param interfaces the interfaces
- * @param superclass the super class
- */
- public ClassInfoImpl(String name, int modifiers, InterfaceInfo[] interfaces,
- ClassInfoImpl superclass)
- {
- this.name = name;
- this.modifiers = modifiers;
- this.interfaces = interfaces;
- this.superclass = superclass;
- }
-
- public TypeInfoFactory getTypeInfoFactory()
- {
- return typeInfoFactory;
- }
-
- public void setTypeInfoFactory(TypeInfoFactory typeInfoFactory)
- {
- this.typeInfoFactory = typeInfoFactory;
- }
-
- public void setClassInfoHelper(ClassInfoHelper classInfoHelper)
- {
- this.classInfoHelper = classInfoHelper;
- }
-
- /**
- * Find a method
- *
- * @param methods the methods
- * @param name the name
- * @param parameters the parameters
- * @return the method info
- */
- public static MethodInfo findMethod(MethodInfo[] methods, String name, TypeInfo[] parameters)
- {
- if (methods == null) return null;
- for (int i = 0; i < methods.length; i++)
- {
- if (methods[i].getName().equals(name))
- {
- final int length = (parameters != null) ? parameters.length : 0;
- if (methods[i].getParameterTypes().length == length)
- {
- boolean ok = true;
- for (int j = 0; j < length; j++)
- {
- if (!parameters[j].equals(methods[i].getParameterTypes()[j]))
- {
- ok = false;
- break;
- }
- }
- if (ok) return methods[i];
- }
- }
- }
- return null;
- }
-
- /**
- * Find a constructor
- *
- * @param constructors the constructors
- * @param parameters the parameters
- * @return the constructor info
- */
- public static ConstructorInfo findConstructor(ConstructorInfo[] constructors, TypeInfo[] parameters)
- {
- if (constructors == null) return null;
- for (int i = 0; i < constructors.length; i++)
- {
- final int length = (parameters != null) ? parameters.length : 0;
- if (constructors[i].getParameterTypes().length == length)
- {
- boolean ok = true;
- for (int j = 0; j < length; j++)
- {
- if (!parameters[j].equals(constructors[i].getParameterTypes()[j]))
- {
- ok = false;
- break;
- }
- }
- if (ok) return constructors[i];
- }
- }
- return null;
- }
-
- /**
- * Get an array class
- *
- * @param clazz the class
- * @return the array class
- */
- public static Class<?> getArrayClass(Class<?> clazz)
- {
- return Array.newInstance(clazz, 0).getClass();
- }
-
- /**
- * Set the type
- *
- * @param type the class
- */
- public void setType(Class<?> type)
- {
- setAnnotatedElement(type);
- if (type != null)
- modifiers = type.getModifiers();
- }
-
- /**
- * Set the interfaces
- *
- * @param interfaces the interfaces
- */
- public void setInterfaces(InterfaceInfo[] interfaces)
- {
- this.interfaces = interfaces;
- }
-
- /**
- * Set the generic interfaces
- *
- * @param interfaces the interfaces
- */
- public void setGenericInterfaces(InterfaceInfo[] interfaces)
- {
- this.genericInterfaces = interfaces;
- }
-
- /**
- * Set the declared methods
- *
- * @param methods the methods
- */
- public void setDeclaredMethods(MethodInfoImpl[] methods)
- {
- this.methods = methods;
- if (methods != null)
- {
- for (int i = 0; i < methods.length; i++)
- methods[i].declaringClass = this;
- }
- }
-
- /**
- * Set the declared fields
- *
- * @param fields the fields
- */
- public void setDeclaredFields(FieldInfoImpl[] fields)
- {
- this.fields = fields;
- if (fields != null)
- {
- fieldMap = new HashMap<String, FieldInfo>();
- for (int i = 0; i < fields.length; ++i)
- {
- fields[i].declaringClass = this;
- fieldMap.put(fields[i].getName(), fields[i]);
- }
- }
- }
-
- /**
- * Set the declared constructors
- *
- * @param constructors the constructors
- */
- public void setDeclaredConstructors(ConstructorInfoImpl[] constructors)
- {
- this.constructors = constructors;
- if (constructors != null)
- {
- for (int i = 0; i < constructors.length; i++)
- constructors[i].declaringClass = this;
- }
- }
-
- /**
- * Set the super class
- *
- * @param superInfo the super class
- */
- public void setSuperclass(ClassInfoImpl superInfo)
- {
- this.superclass = superInfo;
- }
-
- /**
- * Set the generic super class
- *
- * @param superInfo the super class
- */
- public void setGenericSuperclass(ClassInfo superInfo)
- {
- this.genericSuperclass = superInfo;
- }
-
- public boolean isInterface()
- {
- return false;
- }
-
- public InterfaceInfo[] getInterfaces()
- {
- if (interfaces == UNKNOWN_INTERFACES)
- setInterfaces(classInfoHelper.getInterfaces(this));
- return interfaces;
- }
-
- public InterfaceInfo[] getGenericInterfaces()
- {
- if (genericInterfaces == UNKNOWN_INTERFACES)
- setGenericInterfaces(classInfoHelper.getGenericInterfaces(this));
- return genericInterfaces;
- }
-
- public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
- {
- if (methods == UNKNOWN_METHODS)
- setDeclaredMethods(classInfoHelper.getMethods(this));
- return findMethod(methods, name, parameters);
- }
-
- public MethodInfo[] getDeclaredMethods()
- {
- if (methods == UNKNOWN_METHODS)
- setDeclaredMethods(classInfoHelper.getMethods(this));
- return methods;
- }
-
- public FieldInfo getDeclaredField(String name)
- {
- if (fields == UNKNOWN_FIELDS)
- setDeclaredFields(classInfoHelper.getFields(this));
- if (fieldMap == null)
- return null;
- return fieldMap.get(name);
- }
-
- public FieldInfo[] getDeclaredFields()
- {
- if (fields == UNKNOWN_FIELDS)
- setDeclaredFields(classInfoHelper.getFields(this));
- return fields;
- }
-
- public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
- {
- if (methods == UNKNOWN_METHODS)
- setDeclaredConstructors(classInfoHelper.getConstructors(this));
- return findConstructor(constructors, parameters);
- }
-
- public ConstructorInfo[] getDeclaredConstructors()
- {
- if (constructors == UNKNOWN_CONSTRUCTORS)
- setDeclaredConstructors(classInfoHelper.getConstructors(this));
- return constructors;
- }
-
- public ClassInfo getSuperclass()
- {
- if (superclass == UNKNOWN_CLASS)
- setSuperclass(classInfoHelper.getSuperClass(this));
- return superclass;
- }
-
- public ClassInfo getGenericSuperclass()
- {
- if (genericSuperclass == UNKNOWN_CLASS)
- setGenericSuperclass(classInfoHelper.getGenericSuperClass(this));
- return genericSuperclass;
- }
-
- public int getModifiers()
- {
- return modifiers;
- }
-
- public boolean isStatic()
- {
- return Modifier.isStatic(modifiers);
- }
-
- public boolean isPublic()
- {
- return Modifier.isPublic(modifiers);
- }
-
- public boolean isVolatile()
- {
- return Modifier.isVolatile(modifiers);
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getSimpleName()
- {
- return getType().getSimpleName();
- }
-
- @Deprecated
- @SuppressWarnings("unchecked")
- public Class<? extends Object> getType()
- {
- return (Class<? extends Object>) annotatedElement;
- }
-
- public Object convertValue(Object value) throws Throwable
- {
- return ValueConvertor.convertValue(getType(), value);
- }
-
- public Object convertValue(Object value, boolean replaceProperties) throws Throwable
- {
- return ValueConvertor.convertValue(getType(), value, replaceProperties);
- }
-
- public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
- {
- return ValueConvertor.convertValue(getType(), value, replaceProperties, trim);
- }
-
- public boolean isArray()
- {
- return getType().isArray();
- }
-
- public boolean isCollection()
- {
- return Collection.class.isAssignableFrom(getType());
- }
-
- public boolean isMap()
- {
- return Map.class.isAssignableFrom(getType());
- }
-
- public boolean isAnnotation()
- {
- return getType().isAnnotation();
- }
-
- public boolean isEnum()
- {
- return getType().isEnum();
- }
-
- public boolean isPrimitive()
- {
- return false;
- }
-
- public TypeInfo getArrayType()
- {
- Class<?> arrayClass = getArrayClass(getType());
- return classInfoHelper.getTypeInfo(arrayClass);
- }
-
- @SuppressWarnings("deprecation")
- public Object newArrayInstance(int size) throws Throwable
- {
- if (isArray() == false)
- throw new ClassCastException(this + " is not an array.");
- return Array.newInstance(getComponentType().getType(), size);
- }
-
- @SuppressWarnings("deprecation")
- public boolean isAssignableFrom(TypeInfo info)
- {
- if (info == null)
- {
- throw new NullPointerException("Parameter info cannot be null!");
- }
- return getType().isAssignableFrom(info.getType());
- }
-
- public TypeInfo[] getActualTypeArguments()
- {
- return null;
- }
-
- public TypeInfo getOwnerType()
- {
- return null;
- }
-
- public ClassInfo getRawType()
- {
- return this;
- }
-
- public TypeInfo getComponentType()
- {
- if (componentType == UNKNOWN_TYPE)
- componentType = classInfoHelper.getComponentType(this);
- return componentType;
- }
-
- public TypeInfo getKeyType()
- {
- if (keyType == UNKNOWN_TYPE)
- keyType = classInfoHelper.getKeyType(this);
- return keyType;
- }
-
- public TypeInfo getValueType()
- {
- if (valueType == UNKNOWN_TYPE)
- valueType = classInfoHelper.getValueType(this);
- return valueType;
- }
-
- public PackageInfo getPackage()
- {
- if (packageInfo == null)
- packageInfo = classInfoHelper.getPackage(this);
- return packageInfo;
- }
-
- public void setAttachment(String name, Object attachment)
- {
- if (name == null)
- throw new IllegalArgumentException("Null name");
- synchronized (this)
- {
- if (attachments == null)
- {
- if (attachment == null)
- return;
- attachments = new TypeInfoAttachments();
- }
- }
- if (attachment == null)
- attachments.removeAttachment(name);
- else
- attachments.addAttachment(name, attachment);
- }
-
- public <T> T getAttachment(Class<T> expectedType)
- {
- if (expectedType == null)
- throw new IllegalArgumentException("Null expectedType");
- Object result = getAttachment(expectedType.getName());
- if (result == null)
- return null;
- return expectedType.cast(result);
- }
-
- public Object getAttachment(String name)
- {
- if (name == null)
- throw new IllegalArgumentException("Null name");
- synchronized (this)
- {
- if (attachments == null)
- return null;
- }
- return attachments.getAttachment(name);
- }
-
- @Override
- protected InheritableAnnotationHolder getSuperHolder()
- {
- return (ClassInfoImpl) getSuperclass();
- }
-
- @Override
- protected void toString(JBossStringBuilder buffer)
- {
- buffer.append("name=").append(getName());
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null || obj instanceof ClassInfo == false)
- return false;
-
- final ClassInfo other = (ClassInfo) obj;
-
- String name = getName();
- if (name != null ? name.equals(other.getName()) == false : other.getName() != null)
- return false;
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return (name != null ? name.hashCode() : 0);
- }
-
- Object readResolve()
- {
- TypeInfoFactory typeInfoFactory = SerializationHelper.getTypeInfoFactory();
- return typeInfoFactory.getTypeInfo(getType());
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,676 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Modifier;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.DelegateClassInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.PackageInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Class info
+ *
+ * TODO JBMICROCONT-118 fix the introspection assumption
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ */
+public class ClassInfoImpl extends InheritableAnnotationHolder implements ClassInfo
+{
+ /** serialVersionUID */
+ private static final long serialVersionUID = 3545798779904340792L;
+
+ /** Marker for generation */
+ public static final ClassInfo UNKNOWN_CLASS = new DelegateClassInfo(null, true);
+
+ /** Marker for generation */
+ public static final ClassInfo[] UNKNOWN_CLASSES = new ClassInfo[0];
+
+ /** Marker for generation */
+ public static final TypeInfo UNKNOWN_TYPE = UNKNOWN_CLASS;
+
+ /** Marker for generation */
+ public static final TypeInfo[] UNKNOWN_TYPES = new TypeInfo[0];
+
+ /** Marker for generation */
+ public static final InterfaceInfo[] UNKNOWN_INTERFACES = new InterfaceInfo[0];
+
+ /** Marker for generation */
+ public static final ConstructorInfo[] UNKNOWN_CONSTRUCTORS = new ConstructorInfo[0];
+
+ /** Marker for generation */
+ public static final MethodInfo[] UNKNOWN_METHODS = new MethodInfo[0];
+
+ /** Marker for generation */
+ public static final FieldInfo[] UNKNOWN_FIELDS = new FieldInfo[0];
+
+ /** The class name */
+ protected String name;
+
+ /** The class modifiers */
+ protected int modifiers;
+
+ /** The interfaces */
+ protected InterfaceInfo[] interfaces = UNKNOWN_INTERFACES;
+
+ /** The generic interfaces */
+ protected InterfaceInfo[] genericInterfaces = UNKNOWN_INTERFACES;
+
+ /** The methods */
+ protected MethodInfo[] methods = UNKNOWN_METHODS;
+
+ /** The fields */
+ protected FieldInfo[] fields = UNKNOWN_FIELDS;
+
+ /** Field map Map<String, FieldInfo> */
+ protected HashMap<String, FieldInfo> fieldMap;
+
+ /** The super class */
+ protected ClassInfo superclass = UNKNOWN_CLASS;
+
+ /** The generic super class */
+ protected ClassInfo genericSuperclass = UNKNOWN_CLASS;
+
+ /** The constructor info */
+ protected ConstructorInfo[] constructors = UNKNOWN_CONSTRUCTORS;
+
+ /** The package info */
+ protected PackageInfo packageInfo;
+
+ /** The component type */
+ private transient TypeInfo componentType = ClassInfoImpl.UNKNOWN_TYPE;
+
+ /** The key type */
+ private transient TypeInfo keyType = ClassInfoImpl.UNKNOWN_TYPE;
+
+ /** The key type */
+ private transient TypeInfo valueType = ClassInfoImpl.UNKNOWN_TYPE;
+
+ /** The class info helper */
+ protected transient ClassInfoHelper classInfoHelper;
+
+ /** The type info factory */
+ protected transient TypeInfoFactory typeInfoFactory;
+
+ /** The attachments */
+ private transient TypeInfoAttachments attachments;
+
+ /**
+ * Create a new abstract ClassInfo.
+ */
+ public ClassInfoImpl()
+ {
+ }
+
+ /**
+ * Create a new class info
+ *
+ * @param name the class name
+ */
+ public ClassInfoImpl(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Create a new abstract ClassInfo.
+ *
+ * @param name the class name
+ * @param modifiers the class modifiers
+ */
+ public ClassInfoImpl(String name, int modifiers)
+ {
+ this.name = name;
+ this.modifiers = modifiers;
+ }
+
+ /**
+ * Create a new abstract ClassInfo.
+ *
+ * @param name the class name
+ * @param modifiers the class modifiers
+ * @param interfaces the interfaces
+ * @param superclass the super class
+ */
+ public ClassInfoImpl(String name, int modifiers, InterfaceInfo[] interfaces,
+ ClassInfoImpl superclass)
+ {
+ this.name = name;
+ this.modifiers = modifiers;
+ this.interfaces = interfaces;
+ this.superclass = superclass;
+ }
+
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ return typeInfoFactory;
+ }
+
+ public void setTypeInfoFactory(TypeInfoFactory typeInfoFactory)
+ {
+ this.typeInfoFactory = typeInfoFactory;
+ }
+
+ public void setClassInfoHelper(ClassInfoHelper classInfoHelper)
+ {
+ this.classInfoHelper = classInfoHelper;
+ }
+
+ /**
+ * Find a method
+ *
+ * @param methods the methods
+ * @param name the name
+ * @param parameters the parameters
+ * @return the method info
+ */
+ public static MethodInfo findMethod(MethodInfo[] methods, String name, TypeInfo[] parameters)
+ {
+ if (methods == null) return null;
+ for (int i = 0; i < methods.length; i++)
+ {
+ if (methods[i].getName().equals(name))
+ {
+ final int length = (parameters != null) ? parameters.length : 0;
+ if (methods[i].getParameterTypes().length == length)
+ {
+ boolean ok = true;
+ for (int j = 0; j < length; j++)
+ {
+ if (!parameters[j].equals(methods[i].getParameterTypes()[j]))
+ {
+ ok = false;
+ break;
+ }
+ }
+ if (ok) return methods[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Find a constructor
+ *
+ * @param constructors the constructors
+ * @param parameters the parameters
+ * @return the constructor info
+ */
+ public static ConstructorInfo findConstructor(ConstructorInfo[] constructors, TypeInfo[] parameters)
+ {
+ if (constructors == null) return null;
+ for (int i = 0; i < constructors.length; i++)
+ {
+ final int length = (parameters != null) ? parameters.length : 0;
+ if (constructors[i].getParameterTypes().length == length)
+ {
+ boolean ok = true;
+ for (int j = 0; j < length; j++)
+ {
+ if (!parameters[j].equals(constructors[i].getParameterTypes()[j]))
+ {
+ ok = false;
+ break;
+ }
+ }
+ if (ok) return constructors[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get an array class
+ *
+ * @param clazz the class
+ * @return the array class
+ */
+ public static Class<?> getArrayClass(Class<?> clazz)
+ {
+ return Array.newInstance(clazz, 0).getClass();
+ }
+
+ /**
+ * Set the type
+ *
+ * @param type the class
+ */
+ public void setType(Class<?> type)
+ {
+ setAnnotatedElement(type);
+ if (type != null)
+ modifiers = type.getModifiers();
+ }
+
+ /**
+ * Set the interfaces
+ *
+ * @param interfaces the interfaces
+ */
+ public void setInterfaces(InterfaceInfo[] interfaces)
+ {
+ this.interfaces = interfaces;
+ }
+
+ /**
+ * Set the generic interfaces
+ *
+ * @param interfaces the interfaces
+ */
+ public void setGenericInterfaces(InterfaceInfo[] interfaces)
+ {
+ this.genericInterfaces = interfaces;
+ }
+
+ /**
+ * Set the declared methods
+ *
+ * @param methods the methods
+ */
+ public void setDeclaredMethods(MethodInfoImpl[] methods)
+ {
+ this.methods = methods;
+ if (methods != null)
+ {
+ for (int i = 0; i < methods.length; i++)
+ methods[i].declaringClass = this;
+ }
+ }
+
+ /**
+ * Set the declared fields
+ *
+ * @param fields the fields
+ */
+ public void setDeclaredFields(FieldInfoImpl[] fields)
+ {
+ this.fields = fields;
+ if (fields != null)
+ {
+ fieldMap = new HashMap<String, FieldInfo>();
+ for (int i = 0; i < fields.length; ++i)
+ {
+ fields[i].declaringClass = this;
+ fieldMap.put(fields[i].getName(), fields[i]);
+ }
+ }
+ }
+
+ /**
+ * Set the declared constructors
+ *
+ * @param constructors the constructors
+ */
+ public void setDeclaredConstructors(ConstructorInfoImpl[] constructors)
+ {
+ this.constructors = constructors;
+ if (constructors != null)
+ {
+ for (int i = 0; i < constructors.length; i++)
+ constructors[i].declaringClass = this;
+ }
+ }
+
+ /**
+ * Set the super class
+ *
+ * @param superInfo the super class
+ */
+ public void setSuperclass(ClassInfoImpl superInfo)
+ {
+ this.superclass = superInfo;
+ }
+
+ /**
+ * Set the generic super class
+ *
+ * @param superInfo the super class
+ */
+ public void setGenericSuperclass(ClassInfo superInfo)
+ {
+ this.genericSuperclass = superInfo;
+ }
+
+ public boolean isInterface()
+ {
+ return false;
+ }
+
+ public InterfaceInfo[] getInterfaces()
+ {
+ if (interfaces == UNKNOWN_INTERFACES)
+ setInterfaces(classInfoHelper.getInterfaces(this));
+ return interfaces;
+ }
+
+ public InterfaceInfo[] getGenericInterfaces()
+ {
+ if (genericInterfaces == UNKNOWN_INTERFACES)
+ setGenericInterfaces(classInfoHelper.getGenericInterfaces(this));
+ return genericInterfaces;
+ }
+
+ public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
+ {
+ if (methods == UNKNOWN_METHODS)
+ setDeclaredMethods(classInfoHelper.getMethods(this));
+ return findMethod(methods, name, parameters);
+ }
+
+ public MethodInfo[] getDeclaredMethods()
+ {
+ if (methods == UNKNOWN_METHODS)
+ setDeclaredMethods(classInfoHelper.getMethods(this));
+ return methods;
+ }
+
+ public FieldInfo getDeclaredField(String name)
+ {
+ if (fields == UNKNOWN_FIELDS)
+ setDeclaredFields(classInfoHelper.getFields(this));
+ if (fieldMap == null)
+ return null;
+ return fieldMap.get(name);
+ }
+
+ public FieldInfo[] getDeclaredFields()
+ {
+ if (fields == UNKNOWN_FIELDS)
+ setDeclaredFields(classInfoHelper.getFields(this));
+ return fields;
+ }
+
+ public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
+ {
+ if (methods == UNKNOWN_METHODS)
+ setDeclaredConstructors(classInfoHelper.getConstructors(this));
+ return findConstructor(constructors, parameters);
+ }
+
+ public ConstructorInfo[] getDeclaredConstructors()
+ {
+ if (constructors == UNKNOWN_CONSTRUCTORS)
+ setDeclaredConstructors(classInfoHelper.getConstructors(this));
+ return constructors;
+ }
+
+ public ClassInfo getSuperclass()
+ {
+ if (superclass == UNKNOWN_CLASS)
+ setSuperclass(classInfoHelper.getSuperClass(this));
+ return superclass;
+ }
+
+ public ClassInfo getGenericSuperclass()
+ {
+ if (genericSuperclass == UNKNOWN_CLASS)
+ setGenericSuperclass(classInfoHelper.getGenericSuperClass(this));
+ return genericSuperclass;
+ }
+
+ public int getModifiers()
+ {
+ return modifiers;
+ }
+
+ public boolean isStatic()
+ {
+ return Modifier.isStatic(modifiers);
+ }
+
+ public boolean isPublic()
+ {
+ return Modifier.isPublic(modifiers);
+ }
+
+ public boolean isVolatile()
+ {
+ return Modifier.isVolatile(modifiers);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getSimpleName()
+ {
+ return getType().getSimpleName();
+ }
+
+ @Deprecated
+ @SuppressWarnings("unchecked")
+ public Class<? extends Object> getType()
+ {
+ return (Class<? extends Object>) annotatedElement;
+ }
+
+ public Object convertValue(Object value) throws Throwable
+ {
+ return ValueConvertor.convertValue(getType(), value);
+ }
+
+ public Object convertValue(Object value, boolean replaceProperties) throws Throwable
+ {
+ return ValueConvertor.convertValue(getType(), value, replaceProperties);
+ }
+
+ public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
+ {
+ return ValueConvertor.convertValue(getType(), value, replaceProperties, trim);
+ }
+
+ public boolean isArray()
+ {
+ return getType().isArray();
+ }
+
+ public boolean isCollection()
+ {
+ return Collection.class.isAssignableFrom(getType());
+ }
+
+ public boolean isMap()
+ {
+ return Map.class.isAssignableFrom(getType());
+ }
+
+ public boolean isAnnotation()
+ {
+ return getType().isAnnotation();
+ }
+
+ public boolean isEnum()
+ {
+ return getType().isEnum();
+ }
+
+ public boolean isPrimitive()
+ {
+ return false;
+ }
+
+ public TypeInfo getArrayType()
+ {
+ Class<?> arrayClass = getArrayClass(getType());
+ return classInfoHelper.getTypeInfo(arrayClass);
+ }
+
+ @SuppressWarnings("deprecation")
+ public Object newArrayInstance(int size) throws Throwable
+ {
+ if (isArray() == false)
+ throw new ClassCastException(this + " is not an array.");
+ return Array.newInstance(getComponentType().getType(), size);
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean isAssignableFrom(TypeInfo info)
+ {
+ if (info == null)
+ throw new NullPointerException("Parameter info cannot be null!");
+
+ return getType().isAssignableFrom(info.getType());
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean isInstance(Object object)
+ {
+ return getType().isInstance(object);
+ }
+
+ public TypeInfo[] getActualTypeArguments()
+ {
+ return null;
+ }
+
+ public TypeInfo getOwnerType()
+ {
+ return null;
+ }
+
+ public ClassInfo getRawType()
+ {
+ return this;
+ }
+
+ public TypeInfo getComponentType()
+ {
+ if (componentType == UNKNOWN_TYPE)
+ componentType = classInfoHelper.getComponentType(this);
+ return componentType;
+ }
+
+ public TypeInfo getKeyType()
+ {
+ if (keyType == UNKNOWN_TYPE)
+ keyType = classInfoHelper.getKeyType(this);
+ return keyType;
+ }
+
+ public TypeInfo getValueType()
+ {
+ if (valueType == UNKNOWN_TYPE)
+ valueType = classInfoHelper.getValueType(this);
+ return valueType;
+ }
+
+ public PackageInfo getPackage()
+ {
+ if (packageInfo == null)
+ packageInfo = classInfoHelper.getPackage(this);
+ return packageInfo;
+ }
+
+ public void setAttachment(String name, Object attachment)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+ synchronized (this)
+ {
+ if (attachments == null)
+ {
+ if (attachment == null)
+ return;
+ attachments = new TypeInfoAttachments();
+ }
+ }
+ if (attachment == null)
+ attachments.removeAttachment(name);
+ else
+ attachments.addAttachment(name, attachment);
+ }
+
+ public <T> T getAttachment(Class<T> expectedType)
+ {
+ if (expectedType == null)
+ throw new IllegalArgumentException("Null expectedType");
+ Object result = getAttachment(expectedType.getName());
+ if (result == null)
+ return null;
+ return expectedType.cast(result);
+ }
+
+ public Object getAttachment(String name)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+ synchronized (this)
+ {
+ if (attachments == null)
+ return null;
+ }
+ return attachments.getAttachment(name);
+ }
+
+ @Override
+ protected InheritableAnnotationHolder getSuperHolder()
+ {
+ return (ClassInfoImpl) getSuperclass();
+ }
+
+ @Override
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("name=").append(getName());
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null || obj instanceof ClassInfo == false)
+ return false;
+
+ final ClassInfo other = (ClassInfo) obj;
+
+ String name = getName();
+ if (name != null ? name.equals(other.getName()) == false : other.getName() != null)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (name != null ? name.hashCode() : 0);
+ }
+
+ Object readResolve()
+ {
+ TypeInfoFactory typeInfoFactory = SerializationHelper.getTypeInfoFactory();
+ return typeInfoFactory.getTypeInfo(getType());
+ }
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,142 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.reflect.plugins.introspection;
-
-import java.lang.reflect.ParameterizedType;
-
-import org.jboss.reflect.plugins.ClassInfoImpl;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.DelegateClassInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * ParameterizedClassInfo.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class ParameterizedClassInfo extends DelegateClassInfo
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 2;
-
- /** The factory */
- protected transient IntrospectionTypeInfoFactoryImpl factory;
-
- /** The parameterized type */
- transient ParameterizedType parameterizedType;
-
- /** The owner type */
- private TypeInfo ownerType = ClassInfoImpl.UNKNOWN_TYPE;
-
- /** The type arguments */
- private TypeInfo[] typeArguments = ClassInfoImpl.UNKNOWN_TYPES;
-
- /** The component type */
- private transient TypeInfo componentType = ClassInfoImpl.UNKNOWN_TYPE;
-
- /** The key type */
- private transient TypeInfo keyType = ClassInfoImpl.UNKNOWN_TYPE;
-
- /** The key type */
- private transient TypeInfo valueType = ClassInfoImpl.UNKNOWN_TYPE;
-
- /**
- * Create a new ParameterizedClassInfo.
- *
- * @param factory the factory
- * @param delegate the raw array info
- * @param parameterizedType the parameterized type
- */
- public ParameterizedClassInfo(IntrospectionTypeInfoFactoryImpl factory, ClassInfo delegate, ParameterizedType parameterizedType)
- {
- super(delegate);
- this.factory = factory;
- this.delegate = delegate;
- this.parameterizedType = parameterizedType;
- }
-
- public TypeInfoFactory getTypeInfoFactory()
- {
- return factory;
- }
-
- @Override
- public TypeInfo[] getActualTypeArguments()
- {
- if (typeArguments == ClassInfoImpl.UNKNOWN_TYPES)
- typeArguments = factory.getActualTypeArguments(this);
- return typeArguments;
- }
-
- @Override
- public TypeInfo getOwnerType()
- {
- if (ownerType == ClassInfoImpl.UNKNOWN_TYPE)
- ownerType = factory.getOwnerType(this);
- return ownerType;
- }
-
- @Override
- public ClassInfo getRawType()
- {
- return delegate;
- }
-
- @Override
- public TypeInfo getComponentType()
- {
- if (componentType == ClassInfoImpl.UNKNOWN_TYPE)
- componentType = factory.getComponentType(this);
- return componentType;
- }
-
- @Override
- public TypeInfo getKeyType()
- {
- if (keyType == ClassInfoImpl.UNKNOWN_TYPE);
- keyType = factory.getKeyType(this);
- return keyType;
- }
-
- @Override
- public TypeInfo getValueType()
- {
- if (valueType == ClassInfoImpl.UNKNOWN_TYPE)
- valueType = factory.getValueType(this);
- return valueType;
- }
-
- @Override
- public void toShortString(JBossStringBuilder buffer)
- {
- buffer.append(parameterizedType);
- }
-
- @Override
- protected void toString(JBossStringBuilder buffer)
- {
- buffer.append(parameterizedType);
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,142 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.introspection;
+
+import java.lang.reflect.ParameterizedType;
+
+import org.jboss.reflect.plugins.ClassInfoImpl;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.DelegateClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * ParameterizedClassInfo.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParameterizedClassInfo extends DelegateClassInfo
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 2;
+
+ /** The factory */
+ protected transient IntrospectionTypeInfoFactoryImpl factory;
+
+ /** The parameterized type */
+ transient ParameterizedType parameterizedType;
+
+ /** The owner type */
+ private TypeInfo ownerType = ClassInfoImpl.UNKNOWN_TYPE;
+
+ /** The type arguments */
+ private TypeInfo[] typeArguments = ClassInfoImpl.UNKNOWN_TYPES;
+
+ /** The component type */
+ private transient TypeInfo componentType = ClassInfoImpl.UNKNOWN_TYPE;
+
+ /** The key type */
+ private transient TypeInfo keyType = ClassInfoImpl.UNKNOWN_TYPE;
+
+ /** The key type */
+ private transient TypeInfo valueType = ClassInfoImpl.UNKNOWN_TYPE;
+
+ /**
+ * Create a new ParameterizedClassInfo.
+ *
+ * @param factory the factory
+ * @param delegate the raw array info
+ * @param parameterizedType the parameterized type
+ */
+ public ParameterizedClassInfo(IntrospectionTypeInfoFactoryImpl factory, ClassInfo delegate, ParameterizedType parameterizedType)
+ {
+ super(delegate);
+ this.factory = factory;
+ this.delegate = delegate;
+ this.parameterizedType = parameterizedType;
+ }
+
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ return factory;
+ }
+
+ @Override
+ public TypeInfo[] getActualTypeArguments()
+ {
+ if (typeArguments == ClassInfoImpl.UNKNOWN_TYPES)
+ typeArguments = factory.getActualTypeArguments(this);
+ return typeArguments;
+ }
+
+ @Override
+ public TypeInfo getOwnerType()
+ {
+ if (ownerType == ClassInfoImpl.UNKNOWN_TYPE)
+ ownerType = factory.getOwnerType(this);
+ return ownerType;
+ }
+
+ @Override
+ public ClassInfo getRawType()
+ {
+ return delegate;
+ }
+
+ @Override
+ public TypeInfo getComponentType()
+ {
+ if (componentType == ClassInfoImpl.UNKNOWN_TYPE)
+ componentType = factory.getComponentType(this);
+ return componentType;
+ }
+
+ @Override
+ public TypeInfo getKeyType()
+ {
+ if (keyType == ClassInfoImpl.UNKNOWN_TYPE)
+ keyType = factory.getKeyType(this);
+ return keyType;
+ }
+
+ @Override
+ public TypeInfo getValueType()
+ {
+ if (valueType == ClassInfoImpl.UNKNOWN_TYPE)
+ valueType = factory.getValueType(this);
+ return valueType;
+ }
+
+ @Override
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(parameterizedType);
+ }
+
+ @Override
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append(parameterizedType);
+ }
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,698 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.reflect.plugins.javassist;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtField;
-import javassist.CtMethod;
-import javassist.NotFoundException;
-
-import org.jboss.reflect.plugins.PackageInfoImpl;
-import org.jboss.reflect.plugins.TypeInfoAttachments;
-import org.jboss.reflect.plugins.ValueConvertor;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.InterfaceInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.PackageInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * JavassistTypeInfo.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class JavassistTypeInfo extends JavassistInheritableAnnotationHolder implements ClassInfo, InterfaceInfo
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = -5072033691434335775L;
-
- /** The factory */
- private JavassistTypeInfoFactoryImpl factory;
-
- /** The name */
- private String name;
-
- /** The class */
- private Class<? extends Object> clazz;
-
- /** The constructors */
- private Map<SignatureKey, JavassistConstructorInfo> constructors = new ConcurrentHashMap<SignatureKey, JavassistConstructorInfo>();
-
- /** The constructors */
- private ConstructorInfo[] constructorArray;
-
- /** The fields */
- private Map<String, JavassistFieldInfo> fields = new ConcurrentHashMap<String, JavassistFieldInfo>();
-
- /** The fields */
- private FieldInfo[] fieldArray;
-
- /** The methods */
- private Map<SignatureKey, JavassistMethodInfo> methods = new ConcurrentHashMap<SignatureKey, JavassistMethodInfo>();
-
- /** The methods */
- private MethodInfo[] methodArray;
-
- /** The package info */
- private PackageInfo packageInfo;
-
- /** The attachments */
- private transient TypeInfoAttachments attachments;
-
- /**
- * Create a new JavassistTypeInfo.
- *
- * @param factory the factory
- * @param ctClass the ctClass
- * @param clazz the class
- */
- JavassistTypeInfo(JavassistTypeInfoFactoryImpl factory, CtClass ctClass, Class<? extends Object> clazz)
- {
- this(factory, ctClass.getName(), ctClass, clazz);
- }
-
- /**
- * Create a new JavassistTypeInfo.
- *
- * @param factory the factory
- * @param ctClass the ctClass
- * @param clazz the class
- * @param name the name
- */
- JavassistTypeInfo(JavassistTypeInfoFactoryImpl factory, String name, CtClass ctClass, Class<? extends Object> clazz)
- {
- super(ctClass, factory);
- this.factory = factory;
- this.clazz = clazz;
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public boolean isInterface()
- {
- return ctClass.isInterface();
- }
-
- public String getSimpleName()
- {
- return getType().getSimpleName();
- }
-
- public int getModifiers()
- {
- return ctClass.getModifiers();
- }
-
- public boolean isPublic()
- {
- return Modifier.isPublic(getModifiers());
- }
-
- public boolean isStatic()
- {
- return Modifier.isStatic(getModifiers());
- }
-
- public boolean isVolatile()
- {
- return Modifier.isVolatile(getModifiers());
- }
-
- @Deprecated
- public Class<? extends Object> getType()
- {
- return clazz;
- }
-
- public ClassInfo getSuperclass()
- {
- if (isInterface())
- return null;
- try
- {
- CtClass superclass = ctClass.getSuperclass();
- if (superclass == null)
- return null;
- return (ClassInfo) factory.getTypeInfo(superclass);
- }
- catch (NotFoundException e)
- {
- throw JavassistTypeInfoFactoryImpl.raiseClassNotFound(clazz.getSuperclass().getName(), e);
- }
- }
-
- public ClassInfo getGenericSuperclass()
- {
- // TODO JBMICROCONT-129 getGenericSuperclass
- throw new org.jboss.util.NotImplementedException("getGenericSuperclass");
- }
-
- public InterfaceInfo[] getInterfaces()
- {
- try
- {
- CtClass[] interfaces = ctClass.getInterfaces();
- if (interfaces == null || interfaces.length == 0)
- return null;
- InterfaceInfo[] result = new InterfaceInfo[interfaces.length];
- for (int i = 0; i < result.length; ++i)
- result[i] = (InterfaceInfo) factory.getTypeInfo(interfaces[i]);
- return result;
- }
- catch (NotFoundException e)
- {
- throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for interfaces of " + getName(), e);
- }
- }
-
- public InterfaceInfo[] getGenericInterfaces()
- {
- // TODO JBMICROCONT-129 getGenericInterfaces
- throw new org.jboss.util.NotImplementedException("getGenericInterfaces");
- }
-
- public ConstructorInfo[] getDeclaredConstructors()
- {
- if (constructorArray == null)
- {
- CtConstructor[] declaredConstructors = ctClass.getDeclaredConstructors();
- if (declaredConstructors == null || declaredConstructors.length == 0)
- constructorArray = new ConstructorInfo[0];
- else
- {
- synchronized (constructors)
- {
- for (int i = 0; i < declaredConstructors.length; ++i)
- generateConstructorInfo(declaredConstructors[i]);
- Collection<JavassistConstructorInfo> constructorCollection = constructors.values();
- constructorArray = constructorCollection.toArray(new ConstructorInfo[constructorCollection.size()]);
- }
- }
- }
- return constructorArray;
- }
-
- public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
- {
- SignatureKey key = new SignatureKey(null, parameters);
- synchronized (constructors)
- {
- ConstructorInfo constructor = constructors.get(key);
- if (constructor != null)
- return constructor;
- }
- if (constructorArray != null)
- return null;
- return generateConstructorInfo(key);
- }
-
- public FieldInfo getDeclaredField(String name)
- {
- synchronized (fields)
- {
- FieldInfo field = fields.get(name);
- if (field != null)
- return field;
- }
- if (fieldArray != null)
- return null;
- try
- {
- CtField field = ctClass.getDeclaredField(name);
- if (field == null)
- return null;
- return generateFieldInfo(field);
- }
- catch (NotFoundException e)
- {
- return null;
- }
- }
-
- public FieldInfo[] getDeclaredFields()
- {
- if (fieldArray == null)
- {
- CtField[] declaredFields = ctClass.getDeclaredFields();
- if (declaredFields == null || declaredFields.length == 0)
- fieldArray = new FieldInfo[0];
- else
- {
- synchronized (fields)
- {
- for (int i = 0; i < declaredFields.length; ++i)
- generateFieldInfo(declaredFields[i]);
- Collection<JavassistFieldInfo> fieldCollection = fields.values();
- fieldArray = fieldCollection.toArray(new FieldInfo[fieldCollection.size()]);
- }
- }
- }
- return fieldArray;
- }
-
- public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
- {
- SignatureKey key = new SignatureKey(name, parameters);
- synchronized (methods)
- {
- MethodInfo method = methods.get(key);
- if (method != null)
- return method;
- }
- if (methodArray != null)
- return null;
- return generateMethodInfo(key);
- }
-
- public MethodInfo[] getDeclaredMethods()
- {
- if (methodArray == null)
- {
- CtMethod[] declaredMethods = ctClass.getDeclaredMethods();
- if (declaredMethods == null || declaredMethods.length == 0)
- methodArray = new MethodInfo[0];
- else
- {
- synchronized (methods)
- {
- for (int i = 0; i < declaredMethods.length; ++i)
- generateMethodInfo(declaredMethods[i]);
- Collection<JavassistMethodInfo> methodCollection = methods.values();
- methodArray = methodCollection.toArray(new MethodInfo[methodCollection.size()]);
- }
- }
- }
- return methodArray;
- }
-
- public boolean isArray()
- {
- return getType().isArray();
- }
-
- public boolean isCollection()
- {
- return Collection.class.isAssignableFrom(getType());
- }
-
- public boolean isMap()
- {
- return Map.class.isAssignableFrom(getType());
- }
-
- public boolean isAnnotation()
- {
- return getType().isAnnotation();
- }
-
- public boolean isEnum()
- {
- return getType().isEnum();
- }
-
- public boolean isPrimitive()
- {
- return getType().isPrimitive();
- }
-
- /**
- * Get an array class
- *
- * @param clazz the class
- * @return the array class
- */
- public static Class<?> getArrayClass(Class<?> clazz)
- {
- return Array.newInstance(clazz, 0).getClass();
- }
-
- public TypeInfo getArrayType()
- {
- Class<?> arrayClass = getArrayClass(getType());
- return factory.getTypeInfo(arrayClass);
- }
-
- @SuppressWarnings("deprecation")
- public Object newArrayInstance(int size) throws Throwable
- {
- if (isArray() == false)
- throw new ClassCastException(this + " is not an array.");
- return Array.newInstance(getComponentType().getType(), size);
- }
-
- @SuppressWarnings("deprecation")
- public boolean isAssignableFrom(TypeInfo info)
- {
- if (info == null)
- {
- throw new NullPointerException("Parameter info cannot be null!");
- }
- return getType().isAssignableFrom(info.getType());
- }
-
- public TypeInfoFactory getTypeInfoFactory()
- {
- return factory;
- }
-
- public Object convertValue(Object value) throws Throwable
- {
- return ValueConvertor.convertValue(getType(), value);
- }
-
- public Object convertValue(Object value, boolean replaceProperties) throws Throwable
- {
- return ValueConvertor.convertValue(getType(), value, replaceProperties);
- }
-
- public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
- {
- return ValueConvertor.convertValue(getType(), value, replaceProperties, trim);
- }
-
- protected int getHashCode()
- {
- return getName().hashCode();
- }
-
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null || obj instanceof TypeInfo == false)
- return false;
-
- TypeInfo other = (TypeInfo) obj;
- return getName().equals(other.getName());
- }
-
- public void toShortString(JBossStringBuilder buffer)
- {
- buffer.append(getName());
- }
-
- protected void toString(JBossStringBuilder buffer)
- {
- buffer.append("name=").append(getName());
- super.toString(buffer);
- }
-
- /**
- * Get the factory
- *
- * @return the factory
- */
- protected JavassistTypeInfoFactoryImpl getFactory()
- {
- return factory;
- }
-
- /**
- * Generate constructor info
- *
- * @param constructor the constructor
- * @return the constructor info
- */
- protected ConstructorInfo generateConstructorInfo(CtConstructor constructor)
- {
- try
- {
- CtClass[] parameterTypes = constructor.getParameterTypes();
- String[] params = new String[parameterTypes.length];
- for (int i = 0; i < params.length; ++i)
- params[i] = parameterTypes[i].getName();
- SignatureKey key = new SignatureKey(null, params);
- JavassistConstructorInfo info = new JavassistConstructorInfo(factory, this, constructor);
- synchronized (constructors)
- {
- constructors.put(key, info);
- }
- return info;
- }
- catch (NotFoundException e)
- {
- throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for constructor of " + getName(), e);
- }
- }
-
- /**
- * Generate constructor info
- *
- * @param key the key
- * @return the constructor info
- */
- protected ConstructorInfo generateConstructorInfo(SignatureKey key)
- {
- CtClass[] params = getParameterTypes(key);
- try
- {
- CtConstructor ctConstructor = ctClass.getDeclaredConstructor(params);
- return generateConstructorInfo(ctConstructor);
- }
- catch (NotFoundException e)
- {
- throw JavassistTypeInfoFactoryImpl.raiseMethodNotFound("for constructor " + getName(), e);
- }
- }
-
- /**
- * Generate field info
- *
- * @param field the field
- * @return the field info
- */
- protected FieldInfo generateFieldInfo(CtField field)
- {
- JavassistFieldInfo info = new JavassistFieldInfo(factory, this, field);
- synchronized (fields)
- {
- fields.put(field.getName(), info);
- }
- return info;
- }
-
- /**
- * Generate method info
- *
- * @param key the key
- * @return the method info
- */
- protected MethodInfo generateMethodInfo(SignatureKey key)
- {
- CtClass[] params = getParameterTypes(key);
- try
- {
- CtMethod ctMethod = ctClass.getDeclaredMethod(key.name, params);
- return generateMethodInfo(key, ctMethod);
- }
- catch (NotFoundException e)
- {
- throw JavassistTypeInfoFactoryImpl.raiseMethodNotFound("for method " + key.name, e);
- }
- }
-
- /**
- * Generate method info
- *
- * @param method the method
- * @return the method info
- */
- protected MethodInfo generateMethodInfo(CtMethod method)
- {
- try
- {
- CtClass[] parameterTypes = method.getParameterTypes();
- String[] params = new String[parameterTypes.length];
- for (int i = 0; i < params.length; ++i)
- params[i] = parameterTypes[i].getName();
- SignatureKey key = new SignatureKey(method.getName(), params);
- return generateMethodInfo(key, method);
- }
- catch (NotFoundException e)
- {
- throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for method " + method.getName(), e);
- }
- }
-
- /**
- * Generate method info
- *
- * @param key the key
- * @param method the method
- * @return the method info
- */
- protected MethodInfo generateMethodInfo(SignatureKey key, CtMethod method)
- {
- JavassistMethodInfo info = new JavassistMethodInfo(factory, this, key, method);
- synchronized (methods)
- {
- methods.put(key, info);
- }
- return info;
- }
-
- /**
- * Get the parameter types
- *
- * @param key the key
- * @return the parameter types
- */
- protected CtClass[] getParameterTypes(SignatureKey key)
- {
- if (key.params == null)
- return null;
-
- CtClass[] result = new CtClass[key.params.length];
- for (int i = 0; i < key.params.length; ++i)
- result[i] = factory.getCtClass(key.params[i]);
-
- return result;
- }
-
- protected Object getAnnotatedTarget()
- {
- return ctClass;
- }
-
- public AnnotationValue[] getAnnotations()
- {
- return getAnnotations(ctClass);
- }
-
- @Override
- public JavassistInheritableAnnotationHolder getSuperHolder()
- {
- try
- {
- CtClass zuper = ctClass.getSuperclass();
- if (zuper == null)
- {
- return null;
- }
- return (JavassistTypeInfo)factory.getTypeInfo(zuper);
- }
- catch (NotFoundException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public TypeInfo[] getActualTypeArguments()
- {
- return null;
- }
-
- public TypeInfo getOwnerType()
- {
- return null;
- }
-
- public ClassInfo getRawType()
- {
- return this;
- }
-
- public TypeInfo getComponentType()
- {
- return null;
- }
-
- public TypeInfo getKeyType()
- {
- return null;
- }
-
- public TypeInfo getValueType()
- {
- return null;
- }
-
- public PackageInfo getPackage()
- {
- if (packageInfo == null)
- {
- String name = ctClass.getPackageName();
- if (name != null)
- packageInfo = new PackageInfoImpl(ctClass.getPackageName());
- }
- // TODO package annotations
- return packageInfo;
- }
-
- public void setAttachment(String name, Object attachment)
- {
- if (name == null)
- throw new IllegalArgumentException("Null name");
- synchronized (this)
- {
- if (attachments == null)
- {
- if (attachment == null)
- return;
- attachments = new TypeInfoAttachments();;
- }
- }
- if (attachment == null)
- attachments.removeAttachment(name);
- else
- attachments.addAttachment(name, attachment);
- }
-
- public <T> T getAttachment(Class<T> expectedType)
- {
- if (expectedType == null)
- throw new IllegalArgumentException("Null expectedType");
- Object result = getAttachment(expectedType.getName());
- if (result == null)
- return null;
- return expectedType.cast(result);
- }
-
- public Object getAttachment(String name)
- {
- if (name == null)
- throw new IllegalArgumentException("Null name");
- synchronized (this)
- {
- if (attachments == null)
- return null;
- }
- return attachments.getAttachment(name);
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,703 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.javassist;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Modifier;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.NotFoundException;
+
+import org.jboss.reflect.plugins.PackageInfoImpl;
+import org.jboss.reflect.plugins.TypeInfoAttachments;
+import org.jboss.reflect.plugins.ValueConvertor;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.PackageInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * JavassistTypeInfo.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
+public class JavassistTypeInfo extends JavassistInheritableAnnotationHolder implements ClassInfo, InterfaceInfo
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -5072033691434335775L;
+
+ /** The factory */
+ private JavassistTypeInfoFactoryImpl factory;
+
+ /** The name */
+ private String name;
+
+ /** The class */
+ private Class<? extends Object> clazz;
+
+ /** The constructors */
+ private Map<SignatureKey, JavassistConstructorInfo> constructors = new ConcurrentHashMap<SignatureKey, JavassistConstructorInfo>();
+
+ /** The constructors */
+ private ConstructorInfo[] constructorArray;
+
+ /** The fields */
+ private Map<String, JavassistFieldInfo> fields = new ConcurrentHashMap<String, JavassistFieldInfo>();
+
+ /** The fields */
+ private FieldInfo[] fieldArray;
+
+ /** The methods */
+ private Map<SignatureKey, JavassistMethodInfo> methods = new ConcurrentHashMap<SignatureKey, JavassistMethodInfo>();
+
+ /** The methods */
+ private MethodInfo[] methodArray;
+
+ /** The package info */
+ private PackageInfo packageInfo;
+
+ /** The attachments */
+ private transient TypeInfoAttachments attachments;
+
+ /**
+ * Create a new JavassistTypeInfo.
+ *
+ * @param factory the factory
+ * @param ctClass the ctClass
+ * @param clazz the class
+ */
+ JavassistTypeInfo(JavassistTypeInfoFactoryImpl factory, CtClass ctClass, Class<? extends Object> clazz)
+ {
+ this(factory, ctClass.getName(), ctClass, clazz);
+ }
+
+ /**
+ * Create a new JavassistTypeInfo.
+ *
+ * @param factory the factory
+ * @param ctClass the ctClass
+ * @param clazz the class
+ * @param name the name
+ */
+ JavassistTypeInfo(JavassistTypeInfoFactoryImpl factory, String name, CtClass ctClass, Class<? extends Object> clazz)
+ {
+ super(ctClass, factory);
+ this.factory = factory;
+ this.clazz = clazz;
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean isInterface()
+ {
+ return ctClass.isInterface();
+ }
+
+ public String getSimpleName()
+ {
+ return getType().getSimpleName();
+ }
+
+ public int getModifiers()
+ {
+ return ctClass.getModifiers();
+ }
+
+ public boolean isPublic()
+ {
+ return Modifier.isPublic(getModifiers());
+ }
+
+ public boolean isStatic()
+ {
+ return Modifier.isStatic(getModifiers());
+ }
+
+ public boolean isVolatile()
+ {
+ return Modifier.isVolatile(getModifiers());
+ }
+
+ @Deprecated
+ public Class<? extends Object> getType()
+ {
+ return clazz;
+ }
+
+ public ClassInfo getSuperclass()
+ {
+ if (isInterface())
+ return null;
+ try
+ {
+ CtClass superclass = ctClass.getSuperclass();
+ if (superclass == null)
+ return null;
+ return (ClassInfo) factory.getTypeInfo(superclass);
+ }
+ catch (NotFoundException e)
+ {
+ throw JavassistTypeInfoFactoryImpl.raiseClassNotFound(clazz.getSuperclass().getName(), e);
+ }
+ }
+
+ public ClassInfo getGenericSuperclass()
+ {
+ // TODO JBMICROCONT-129 getGenericSuperclass
+ throw new org.jboss.util.NotImplementedException("getGenericSuperclass");
+ }
+
+ public InterfaceInfo[] getInterfaces()
+ {
+ try
+ {
+ CtClass[] interfaces = ctClass.getInterfaces();
+ if (interfaces == null || interfaces.length == 0)
+ return null;
+ InterfaceInfo[] result = new InterfaceInfo[interfaces.length];
+ for (int i = 0; i < result.length; ++i)
+ result[i] = (InterfaceInfo) factory.getTypeInfo(interfaces[i]);
+ return result;
+ }
+ catch (NotFoundException e)
+ {
+ throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for interfaces of " + getName(), e);
+ }
+ }
+
+ public InterfaceInfo[] getGenericInterfaces()
+ {
+ // TODO JBMICROCONT-129 getGenericInterfaces
+ throw new org.jboss.util.NotImplementedException("getGenericInterfaces");
+ }
+
+ public ConstructorInfo[] getDeclaredConstructors()
+ {
+ if (constructorArray == null)
+ {
+ CtConstructor[] declaredConstructors = ctClass.getDeclaredConstructors();
+ if (declaredConstructors == null || declaredConstructors.length == 0)
+ constructorArray = new ConstructorInfo[0];
+ else
+ {
+ synchronized (constructors)
+ {
+ for (int i = 0; i < declaredConstructors.length; ++i)
+ generateConstructorInfo(declaredConstructors[i]);
+ Collection<JavassistConstructorInfo> constructorCollection = constructors.values();
+ constructorArray = constructorCollection.toArray(new ConstructorInfo[constructorCollection.size()]);
+ }
+ }
+ }
+ return constructorArray;
+ }
+
+ public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
+ {
+ SignatureKey key = new SignatureKey(null, parameters);
+ synchronized (constructors)
+ {
+ ConstructorInfo constructor = constructors.get(key);
+ if (constructor != null)
+ return constructor;
+ }
+ if (constructorArray != null)
+ return null;
+ return generateConstructorInfo(key);
+ }
+
+ public FieldInfo getDeclaredField(String name)
+ {
+ synchronized (fields)
+ {
+ FieldInfo field = fields.get(name);
+ if (field != null)
+ return field;
+ }
+ if (fieldArray != null)
+ return null;
+ try
+ {
+ CtField field = ctClass.getDeclaredField(name);
+ if (field == null)
+ return null;
+ return generateFieldInfo(field);
+ }
+ catch (NotFoundException e)
+ {
+ return null;
+ }
+ }
+
+ public FieldInfo[] getDeclaredFields()
+ {
+ if (fieldArray == null)
+ {
+ CtField[] declaredFields = ctClass.getDeclaredFields();
+ if (declaredFields == null || declaredFields.length == 0)
+ fieldArray = new FieldInfo[0];
+ else
+ {
+ synchronized (fields)
+ {
+ for (int i = 0; i < declaredFields.length; ++i)
+ generateFieldInfo(declaredFields[i]);
+ Collection<JavassistFieldInfo> fieldCollection = fields.values();
+ fieldArray = fieldCollection.toArray(new FieldInfo[fieldCollection.size()]);
+ }
+ }
+ }
+ return fieldArray;
+ }
+
+ public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
+ {
+ SignatureKey key = new SignatureKey(name, parameters);
+ synchronized (methods)
+ {
+ MethodInfo method = methods.get(key);
+ if (method != null)
+ return method;
+ }
+ if (methodArray != null)
+ return null;
+ return generateMethodInfo(key);
+ }
+
+ public MethodInfo[] getDeclaredMethods()
+ {
+ if (methodArray == null)
+ {
+ CtMethod[] declaredMethods = ctClass.getDeclaredMethods();
+ if (declaredMethods == null || declaredMethods.length == 0)
+ methodArray = new MethodInfo[0];
+ else
+ {
+ synchronized (methods)
+ {
+ for (int i = 0; i < declaredMethods.length; ++i)
+ generateMethodInfo(declaredMethods[i]);
+ Collection<JavassistMethodInfo> methodCollection = methods.values();
+ methodArray = methodCollection.toArray(new MethodInfo[methodCollection.size()]);
+ }
+ }
+ }
+ return methodArray;
+ }
+
+ public boolean isArray()
+ {
+ return getType().isArray();
+ }
+
+ public boolean isCollection()
+ {
+ return Collection.class.isAssignableFrom(getType());
+ }
+
+ public boolean isMap()
+ {
+ return Map.class.isAssignableFrom(getType());
+ }
+
+ public boolean isAnnotation()
+ {
+ return getType().isAnnotation();
+ }
+
+ public boolean isEnum()
+ {
+ return getType().isEnum();
+ }
+
+ public boolean isPrimitive()
+ {
+ return getType().isPrimitive();
+ }
+
+ /**
+ * Get an array class
+ *
+ * @param clazz the class
+ * @return the array class
+ */
+ public static Class<?> getArrayClass(Class<?> clazz)
+ {
+ return Array.newInstance(clazz, 0).getClass();
+ }
+
+ public TypeInfo getArrayType()
+ {
+ Class<?> arrayClass = getArrayClass(getType());
+ return factory.getTypeInfo(arrayClass);
+ }
+
+ @SuppressWarnings("deprecation")
+ public Object newArrayInstance(int size) throws Throwable
+ {
+ if (isArray() == false)
+ throw new ClassCastException(this + " is not an array.");
+ return Array.newInstance(getComponentType().getType(), size);
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean isAssignableFrom(TypeInfo info)
+ {
+ if (info == null)
+ throw new NullPointerException("Parameter info cannot be null!");
+
+ return getType().isAssignableFrom(info.getType());
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean isInstance(Object object)
+ {
+ return getType().isInstance(object);
+ }
+
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ return factory;
+ }
+
+ public Object convertValue(Object value) throws Throwable
+ {
+ return ValueConvertor.convertValue(getType(), value);
+ }
+
+ public Object convertValue(Object value, boolean replaceProperties) throws Throwable
+ {
+ return ValueConvertor.convertValue(getType(), value, replaceProperties);
+ }
+
+ public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
+ {
+ return ValueConvertor.convertValue(getType(), value, replaceProperties, trim);
+ }
+
+ protected int getHashCode()
+ {
+ return getName().hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (obj == null || obj instanceof TypeInfo == false)
+ return false;
+
+ TypeInfo other = (TypeInfo) obj;
+ return getName().equals(other.getName());
+ }
+
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(getName());
+ }
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("name=").append(getName());
+ super.toString(buffer);
+ }
+
+ /**
+ * Get the factory
+ *
+ * @return the factory
+ */
+ protected JavassistTypeInfoFactoryImpl getFactory()
+ {
+ return factory;
+ }
+
+ /**
+ * Generate constructor info
+ *
+ * @param constructor the constructor
+ * @return the constructor info
+ */
+ protected ConstructorInfo generateConstructorInfo(CtConstructor constructor)
+ {
+ try
+ {
+ CtClass[] parameterTypes = constructor.getParameterTypes();
+ String[] params = new String[parameterTypes.length];
+ for (int i = 0; i < params.length; ++i)
+ params[i] = parameterTypes[i].getName();
+ SignatureKey key = new SignatureKey(null, params);
+ JavassistConstructorInfo info = new JavassistConstructorInfo(factory, this, constructor);
+ synchronized (constructors)
+ {
+ constructors.put(key, info);
+ }
+ return info;
+ }
+ catch (NotFoundException e)
+ {
+ throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for constructor of " + getName(), e);
+ }
+ }
+
+ /**
+ * Generate constructor info
+ *
+ * @param key the key
+ * @return the constructor info
+ */
+ protected ConstructorInfo generateConstructorInfo(SignatureKey key)
+ {
+ CtClass[] params = getParameterTypes(key);
+ try
+ {
+ CtConstructor ctConstructor = ctClass.getDeclaredConstructor(params);
+ return generateConstructorInfo(ctConstructor);
+ }
+ catch (NotFoundException e)
+ {
+ throw JavassistTypeInfoFactoryImpl.raiseMethodNotFound("for constructor " + getName(), e);
+ }
+ }
+
+ /**
+ * Generate field info
+ *
+ * @param field the field
+ * @return the field info
+ */
+ protected FieldInfo generateFieldInfo(CtField field)
+ {
+ JavassistFieldInfo info = new JavassistFieldInfo(factory, this, field);
+ synchronized (fields)
+ {
+ fields.put(field.getName(), info);
+ }
+ return info;
+ }
+
+ /**
+ * Generate method info
+ *
+ * @param key the key
+ * @return the method info
+ */
+ protected MethodInfo generateMethodInfo(SignatureKey key)
+ {
+ CtClass[] params = getParameterTypes(key);
+ try
+ {
+ CtMethod ctMethod = ctClass.getDeclaredMethod(key.name, params);
+ return generateMethodInfo(key, ctMethod);
+ }
+ catch (NotFoundException e)
+ {
+ throw JavassistTypeInfoFactoryImpl.raiseMethodNotFound("for method " + key.name, e);
+ }
+ }
+
+ /**
+ * Generate method info
+ *
+ * @param method the method
+ * @return the method info
+ */
+ protected MethodInfo generateMethodInfo(CtMethod method)
+ {
+ try
+ {
+ CtClass[] parameterTypes = method.getParameterTypes();
+ String[] params = new String[parameterTypes.length];
+ for (int i = 0; i < params.length; ++i)
+ params[i] = parameterTypes[i].getName();
+ SignatureKey key = new SignatureKey(method.getName(), params);
+ return generateMethodInfo(key, method);
+ }
+ catch (NotFoundException e)
+ {
+ throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for method " + method.getName(), e);
+ }
+ }
+
+ /**
+ * Generate method info
+ *
+ * @param key the key
+ * @param method the method
+ * @return the method info
+ */
+ protected MethodInfo generateMethodInfo(SignatureKey key, CtMethod method)
+ {
+ JavassistMethodInfo info = new JavassistMethodInfo(factory, this, key, method);
+ synchronized (methods)
+ {
+ methods.put(key, info);
+ }
+ return info;
+ }
+
+ /**
+ * Get the parameter types
+ *
+ * @param key the key
+ * @return the parameter types
+ */
+ protected CtClass[] getParameterTypes(SignatureKey key)
+ {
+ if (key.params == null)
+ return null;
+
+ CtClass[] result = new CtClass[key.params.length];
+ for (int i = 0; i < key.params.length; ++i)
+ result[i] = factory.getCtClass(key.params[i]);
+
+ return result;
+ }
+
+ protected Object getAnnotatedTarget()
+ {
+ return ctClass;
+ }
+
+ public AnnotationValue[] getAnnotations()
+ {
+ return getAnnotations(ctClass);
+ }
+
+ @Override
+ public JavassistInheritableAnnotationHolder getSuperHolder()
+ {
+ try
+ {
+ CtClass zuper = ctClass.getSuperclass();
+ if (zuper == null)
+ {
+ return null;
+ }
+ return (JavassistTypeInfo)factory.getTypeInfo(zuper);
+ }
+ catch (NotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public TypeInfo[] getActualTypeArguments()
+ {
+ return null;
+ }
+
+ public TypeInfo getOwnerType()
+ {
+ return null;
+ }
+
+ public ClassInfo getRawType()
+ {
+ return this;
+ }
+
+ public TypeInfo getComponentType()
+ {
+ return null;
+ }
+
+ public TypeInfo getKeyType()
+ {
+ return null;
+ }
+
+ public TypeInfo getValueType()
+ {
+ return null;
+ }
+
+ public PackageInfo getPackage()
+ {
+ if (packageInfo == null)
+ {
+ String name = ctClass.getPackageName();
+ if (name != null)
+ packageInfo = new PackageInfoImpl(ctClass.getPackageName());
+ }
+ // TODO package annotations
+ return packageInfo;
+ }
+
+ public void setAttachment(String name, Object attachment)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+ synchronized (this)
+ {
+ if (attachments == null)
+ {
+ if (attachment == null)
+ return;
+ attachments = new TypeInfoAttachments();;
+ }
+ }
+ if (attachment == null)
+ attachments.removeAttachment(name);
+ else
+ attachments.addAttachment(name, attachment);
+ }
+
+ public <T> T getAttachment(Class<T> expectedType)
+ {
+ if (expectedType == null)
+ throw new IllegalArgumentException("Null expectedType");
+ Object result = getAttachment(expectedType.getName());
+ if (result == null)
+ return null;
+ return expectedType.cast(result);
+ }
+
+ public Object getAttachment(String name)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+ synchronized (this)
+ {
+ if (attachments == null)
+ return null;
+ }
+ return attachments.getAttachment(name);
+ }
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,379 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.reflect.spi;
-
-import java.lang.annotation.Annotation;
-
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * Delegate ClassInfo
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class DelegateClassInfo extends AbstractTypeInfo implements ClassInfo, InterfaceInfo
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 6830276668550581673L;
-
- /** The delegate */
- protected ClassInfo delegate;
-
- /**
- * Create delegate class info
- *
- * @param delegate the raw array info
- * @throws IllegalArgumentException for a null delegate
- */
- public DelegateClassInfo(ClassInfo delegate)
- {
- this(delegate, false);
- }
-
- /**
- * Create delegate class info
- *
- * @param delegate the raw array info
- * @param allowNull whether to allow a null delegate
- */
- public DelegateClassInfo(ClassInfo delegate, boolean allowNull)
- {
- if (delegate == null && allowNull == false)
- throw new IllegalArgumentException("Null delegate");
- this.delegate = delegate;
- }
-
- /**
- * Whether the delegate is initialized
- *
- * @return true when there is a delegate
- */
- public boolean isInitialized()
- {
- return (delegate != null);
- }
-
- /**
- * Set the delegate
- *
- * @param delegate the delegate
- * @throws IllegalArgumentException for a null delegate or it is not a ClassInfo
- */
- public void setDelegate(TypeInfo delegate)
- {
- if (delegate == null)
- throw new IllegalArgumentException("Null delegate");
- if (delegate instanceof ClassInfo == false)
- throw new IllegalArgumentException("Delegate is not a ClassInfo " + delegate.getClass().getName());
- this.delegate = (ClassInfo) delegate;
- }
-
- /**
- * Set the delegate
- *
- * @param delegate the delegate
- * @throws IllegalArgumentException for a null delegate
- */
- public void setDelegate(ClassInfo delegate)
- {
- if (delegate == null)
- throw new IllegalArgumentException("Null delegate");
- this.delegate = delegate;
- }
-
- public TypeInfoFactory getTypeInfoFactory()
- {
- return delegate.getTypeInfoFactory();
- }
-
- public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
- {
- return delegate.getDeclaredConstructor(parameters);
- }
-
- public ConstructorInfo[] getDeclaredConstructors()
- {
- return delegate.getDeclaredConstructors();
- }
-
- public FieldInfo getDeclaredField(String name)
- {
- return delegate.getDeclaredField(name);
- }
-
- public FieldInfo[] getDeclaredFields()
- {
- return delegate.getDeclaredFields();
- }
-
- public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
- {
- return delegate.getDeclaredMethod(name, parameters);
- }
-
- public MethodInfo[] getDeclaredMethods()
- {
- return delegate.getDeclaredMethods();
- }
-
- public InterfaceInfo[] getGenericInterfaces()
- {
- return delegate.getGenericInterfaces();
- }
-
- public ClassInfo getGenericSuperclass()
- {
- return delegate.getGenericSuperclass();
- }
-
- public InterfaceInfo[] getInterfaces()
- {
- return delegate.getInterfaces();
- }
-
- public String getName()
- {
- return delegate.getName();
- }
-
- public String getSimpleName()
- {
- return delegate.getSimpleName();
- }
-
- public ClassInfo getSuperclass()
- {
- return delegate.getSuperclass();
- }
-
- public boolean isInterface()
- {
- return delegate.isInterface();
- }
-
- public AnnotationValue getAnnotation(String name)
- {
- return delegate.getAnnotation(name);
- }
-
- public AnnotationValue[] getAnnotations()
- {
- return delegate.getAnnotations();
- }
-
- public boolean isAnnotationPresent(String name)
- {
- return delegate.isAnnotationPresent(name);
- }
-
- public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
- {
- return delegate.getUnderlyingAnnotation(annotationType);
- }
-
- public Annotation[] getUnderlyingAnnotations()
- {
- return delegate.getUnderlyingAnnotations();
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return delegate.isAnnotationPresent(annotationType);
- }
-
- public int getModifiers()
- {
- return delegate.getModifiers();
- }
-
- public boolean isPublic()
- {
- return delegate.isPublic();
- }
-
- public boolean isStatic()
- {
- return delegate.isStatic();
- }
-
- public boolean isVolatile()
- {
- return delegate.isVolatile();
- }
-
- public Object convertValue(Object value) throws Throwable
- {
- return delegate.convertValue(value);
- }
-
- public Object convertValue(Object value, boolean replaceProperties) throws Throwable
- {
- return delegate.convertValue(value, replaceProperties);
- }
-
- public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
- {
- return delegate.convertValue(value, replaceProperties, trim);
- }
-
- public TypeInfo getArrayType()
- {
- return delegate.getArrayType();
- }
-
- @Deprecated
- public Class<?> getType()
- {
- return delegate.getType();
- }
-
- public boolean isAnnotation()
- {
- return delegate.isAnnotation();
- }
-
- public boolean isCollection()
- {
- return delegate.isCollection();
- }
-
- public boolean isMap()
- {
- return delegate.isMap();
- }
-
- @Override
- public boolean isArray()
- {
- return delegate.isArray();
- }
-
- @Override
- public boolean isEnum()
- {
- return delegate.isEnum();
- }
-
- @Override
- public boolean isPrimitive()
- {
- return delegate.isPrimitive();
- }
-
- public Object newArrayInstance(int size) throws Throwable
- {
- return delegate.newArrayInstance(size);
- }
-
- public boolean isAssignableFrom(TypeInfo info)
- {
- return delegate.isAssignableFrom(info);
- }
-
- public TypeInfo[] getActualTypeArguments()
- {
- return delegate.getActualTypeArguments();
- }
-
- public TypeInfo getOwnerType()
- {
- return delegate.getOwnerType();
- }
-
- public ClassInfo getRawType()
- {
- return delegate.getRawType();
- }
-
- public TypeInfo getComponentType()
- {
- return delegate.getComponentType();
- }
-
- public TypeInfo getKeyType()
- {
- return delegate.getKeyType();
- }
-
- public TypeInfo getValueType()
- {
- return delegate.getValueType();
- }
-
- public PackageInfo getPackage()
- {
- return delegate.getPackage();
- }
-
- @Override
- protected int getHashCode()
- {
- return delegate.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
-
- if (obj == null || obj instanceof ClassInfo == false)
- return false;
-
- ClassInfo other = (ClassInfo) obj;
- ClassInfo otherDelegate = other;
- if (other instanceof DelegateClassInfo)
- otherDelegate = ((DelegateClassInfo) other).delegate;
-
- if (delegate.equals(otherDelegate) == false)
- return false;
-
- // We are equal to the raw type (seems hacky?)
- if (other instanceof DelegateClassInfo == false)
- return true;
-
- TypeInfo[] typeArguments = getActualTypeArguments();
- TypeInfo[] otherTypeArguments = other.getActualTypeArguments();
- if (typeArguments.length != otherTypeArguments.length)
- return false;
-
- for (int i = 0; i < typeArguments.length; ++i)
- {
- if (typeArguments[i].equals(otherTypeArguments[i]) == false)
- return false;
- }
- return true;
- }
-
- @Override
- public void toShortString(JBossStringBuilder buffer)
- {
- delegate.toShortString(buffer);
- }
-
- @Override
- protected void toString(JBossStringBuilder buffer)
- {
- delegate.toShortString(buffer);
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/DelegateClassInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,384 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.spi;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Delegate ClassInfo
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DelegateClassInfo extends AbstractTypeInfo implements ClassInfo, InterfaceInfo
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 6830276668550581673L;
+
+ /** The delegate */
+ protected ClassInfo delegate;
+
+ /**
+ * Create delegate class info
+ *
+ * @param delegate the raw array info
+ * @throws IllegalArgumentException for a null delegate
+ */
+ public DelegateClassInfo(ClassInfo delegate)
+ {
+ this(delegate, false);
+ }
+
+ /**
+ * Create delegate class info
+ *
+ * @param delegate the raw array info
+ * @param allowNull whether to allow a null delegate
+ */
+ public DelegateClassInfo(ClassInfo delegate, boolean allowNull)
+ {
+ if (delegate == null && allowNull == false)
+ throw new IllegalArgumentException("Null delegate");
+ this.delegate = delegate;
+ }
+
+ /**
+ * Whether the delegate is initialized
+ *
+ * @return true when there is a delegate
+ */
+ public boolean isInitialized()
+ {
+ return (delegate != null);
+ }
+
+ /**
+ * Set the delegate
+ *
+ * @param delegate the delegate
+ * @throws IllegalArgumentException for a null delegate or it is not a ClassInfo
+ */
+ public void setDelegate(TypeInfo delegate)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate");
+ if (delegate instanceof ClassInfo == false)
+ throw new IllegalArgumentException("Delegate is not a ClassInfo " + delegate.getClass().getName());
+ this.delegate = (ClassInfo) delegate;
+ }
+
+ /**
+ * Set the delegate
+ *
+ * @param delegate the delegate
+ * @throws IllegalArgumentException for a null delegate
+ */
+ public void setDelegate(ClassInfo delegate)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate");
+ this.delegate = delegate;
+ }
+
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ return delegate.getTypeInfoFactory();
+ }
+
+ public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
+ {
+ return delegate.getDeclaredConstructor(parameters);
+ }
+
+ public ConstructorInfo[] getDeclaredConstructors()
+ {
+ return delegate.getDeclaredConstructors();
+ }
+
+ public FieldInfo getDeclaredField(String name)
+ {
+ return delegate.getDeclaredField(name);
+ }
+
+ public FieldInfo[] getDeclaredFields()
+ {
+ return delegate.getDeclaredFields();
+ }
+
+ public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
+ {
+ return delegate.getDeclaredMethod(name, parameters);
+ }
+
+ public MethodInfo[] getDeclaredMethods()
+ {
+ return delegate.getDeclaredMethods();
+ }
+
+ public InterfaceInfo[] getGenericInterfaces()
+ {
+ return delegate.getGenericInterfaces();
+ }
+
+ public ClassInfo getGenericSuperclass()
+ {
+ return delegate.getGenericSuperclass();
+ }
+
+ public InterfaceInfo[] getInterfaces()
+ {
+ return delegate.getInterfaces();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public String getSimpleName()
+ {
+ return delegate.getSimpleName();
+ }
+
+ public ClassInfo getSuperclass()
+ {
+ return delegate.getSuperclass();
+ }
+
+ public boolean isInterface()
+ {
+ return delegate.isInterface();
+ }
+
+ public AnnotationValue getAnnotation(String name)
+ {
+ return delegate.getAnnotation(name);
+ }
+
+ public AnnotationValue[] getAnnotations()
+ {
+ return delegate.getAnnotations();
+ }
+
+ public boolean isAnnotationPresent(String name)
+ {
+ return delegate.isAnnotationPresent(name);
+ }
+
+ public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
+ {
+ return delegate.getUnderlyingAnnotation(annotationType);
+ }
+
+ public Annotation[] getUnderlyingAnnotations()
+ {
+ return delegate.getUnderlyingAnnotations();
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return delegate.isAnnotationPresent(annotationType);
+ }
+
+ public int getModifiers()
+ {
+ return delegate.getModifiers();
+ }
+
+ public boolean isPublic()
+ {
+ return delegate.isPublic();
+ }
+
+ public boolean isStatic()
+ {
+ return delegate.isStatic();
+ }
+
+ public boolean isVolatile()
+ {
+ return delegate.isVolatile();
+ }
+
+ public Object convertValue(Object value) throws Throwable
+ {
+ return delegate.convertValue(value);
+ }
+
+ public Object convertValue(Object value, boolean replaceProperties) throws Throwable
+ {
+ return delegate.convertValue(value, replaceProperties);
+ }
+
+ public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
+ {
+ return delegate.convertValue(value, replaceProperties, trim);
+ }
+
+ public TypeInfo getArrayType()
+ {
+ return delegate.getArrayType();
+ }
+
+ @Deprecated
+ public Class<?> getType()
+ {
+ return delegate.getType();
+ }
+
+ public boolean isAnnotation()
+ {
+ return delegate.isAnnotation();
+ }
+
+ public boolean isCollection()
+ {
+ return delegate.isCollection();
+ }
+
+ public boolean isMap()
+ {
+ return delegate.isMap();
+ }
+
+ @Override
+ public boolean isArray()
+ {
+ return delegate.isArray();
+ }
+
+ @Override
+ public boolean isEnum()
+ {
+ return delegate.isEnum();
+ }
+
+ @Override
+ public boolean isPrimitive()
+ {
+ return delegate.isPrimitive();
+ }
+
+ public Object newArrayInstance(int size) throws Throwable
+ {
+ return delegate.newArrayInstance(size);
+ }
+
+ public boolean isAssignableFrom(TypeInfo info)
+ {
+ return delegate.isAssignableFrom(info);
+ }
+
+ public boolean isInstance(Object object)
+ {
+ return delegate.isInstance(object);
+ }
+
+ public TypeInfo[] getActualTypeArguments()
+ {
+ return delegate.getActualTypeArguments();
+ }
+
+ public TypeInfo getOwnerType()
+ {
+ return delegate.getOwnerType();
+ }
+
+ public ClassInfo getRawType()
+ {
+ return delegate.getRawType();
+ }
+
+ public TypeInfo getComponentType()
+ {
+ return delegate.getComponentType();
+ }
+
+ public TypeInfo getKeyType()
+ {
+ return delegate.getKeyType();
+ }
+
+ public TypeInfo getValueType()
+ {
+ return delegate.getValueType();
+ }
+
+ public PackageInfo getPackage()
+ {
+ return delegate.getPackage();
+ }
+
+ @Override
+ protected int getHashCode()
+ {
+ return delegate.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+
+ if (obj == null || obj instanceof ClassInfo == false)
+ return false;
+
+ ClassInfo other = (ClassInfo) obj;
+ ClassInfo otherDelegate = other;
+ if (other instanceof DelegateClassInfo)
+ otherDelegate = ((DelegateClassInfo) other).delegate;
+
+ if (delegate.equals(otherDelegate) == false)
+ return false;
+
+ // We are equal to the raw type (seems hacky?)
+ if (other instanceof DelegateClassInfo == false)
+ return true;
+
+ TypeInfo[] typeArguments = getActualTypeArguments();
+ TypeInfo[] otherTypeArguments = other.getActualTypeArguments();
+ if (typeArguments.length != otherTypeArguments.length)
+ return false;
+
+ for (int i = 0; i < typeArguments.length; ++i)
+ {
+ if (typeArguments[i].equals(otherTypeArguments[i]) == false)
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ delegate.toShortString(buffer);
+ }
+
+ @Override
+ protected void toString(JBossStringBuilder buffer)
+ {
+ delegate.toShortString(buffer);
+ }
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/NumberInfo.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/spi/NumberInfo.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/NumberInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,347 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.reflect.spi;
-
-import java.io.ObjectStreamException;
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * Number info
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class NumberInfo extends PrimitiveInfo implements ClassInfo
-{
- /**
- * The phase enum
- */
- public enum Phase
- {
- INSTANTIATED,
- INITIALIZING,
- COMPLETE
- }
-
- /** serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- /** The byte info */
- public static final NumberInfo BYTE_OBJECT = new NumberInfo(0, Byte.class);
-
- /** The double info */
- public static final NumberInfo DOUBLE_OBJECT = new NumberInfo(1, Double.class);
-
- /** The float info */
- public static final NumberInfo FLOAT_OBJECT = new NumberInfo(2, Float.class);
-
- /** The int info */
- public static final NumberInfo INT_OBJECT = new NumberInfo(3, Integer.class);
-
- /** The long info */
- public static final NumberInfo LONG_OBJECT = new NumberInfo(4, Long.class);
-
- /** The short info */
- public static final NumberInfo SHORT_OBJECT = new NumberInfo(5, Short.class);
-
- /** The atomic int info */
- public static final NumberInfo ATOMIC_INT = new NumberInfo(6, AtomicInteger.class);
-
- /** The atomic long info */
- public static final NumberInfo ATOMIC_LONG = new NumberInfo(7, AtomicLong.class);
-
- /** The primitives */
- private static final NumberInfo[] values = {
- BYTE_OBJECT,
- DOUBLE_OBJECT,
- FLOAT_OBJECT,
- INT_OBJECT,
- LONG_OBJECT,
- SHORT_OBJECT,
- ATOMIC_INT,
- ATOMIC_LONG
- };
-
- /** The primitives */
- private static final HashMap<String, NumberInfo> map = new HashMap<String, NumberInfo>();
-
- static
- {
- map.put(Byte.class.getName(), NumberInfo.BYTE_OBJECT);
- map.put(Double.class.getName(), NumberInfo.DOUBLE_OBJECT);
- map.put(Float.class.getName(), NumberInfo.FLOAT_OBJECT);
- map.put(Integer.class.getName(), NumberInfo.INT_OBJECT);
- map.put(Long.class.getName(), NumberInfo.LONG_OBJECT);
- map.put(Short.class.getName(), NumberInfo.SHORT_OBJECT);
- map.put(AtomicInteger.class.getName(), NumberInfo.ATOMIC_INT);
- map.put(AtomicLong.class.getName(), NumberInfo.ATOMIC_LONG);
- }
-
- private transient ClassInfo delegate;
-
- private transient Phase phase;
-
- /**
- * Get the primitive info for a type
- *
- * @param name the name
- * @return the info
- */
- public static NumberInfo valueOf(String name)
- {
- return map.get(name);
- }
-
- /**
- * Create a new number info
- *
- * @param ordinal the oridinal
- * @param type the class
- */
- protected NumberInfo(int ordinal, Class<? extends Object> type)
- {
- super(type.getName(), ordinal, type);
- phase = Phase.INSTANTIATED;
- }
-
- /**
- * Set the delegate
- *
- * @param info the delegate info
- * @throws IllegalArgumentException if the delegate is null or not a class info
- */
- public void setDelegate(TypeInfo info)
- {
- if (info == null)
- throw new IllegalArgumentException("Null info");
- if (info instanceof ClassInfo == false)
- throw new IllegalArgumentException("Should be of ClassInfo instance: " + info.getClass().getName());
- if (info instanceof NumberInfo)
- throw new IllegalArgumentException("Cannot be delegate to itself: " + info);
-
- delegate = (ClassInfo) info;
- phase = Phase.COMPLETE;
- }
-
- /**
- * Get the phase.
- *
- * @return the current phase
- */
- public Phase getPhase()
- {
- return phase;
- }
-
- /**
- * Are we currently initializing delegate.
- */
- public void initializing()
- {
- phase = Phase.INITIALIZING;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof NumberInfo))
- return false;
- NumberInfo other = (NumberInfo) obj;
- return other.ordinal == this.ordinal;
- }
-
- Object readResolve() throws ObjectStreamException
- {
- return values[ordinal];
- }
-
- // --- delegate
-
- public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
- {
- return delegate.getDeclaredConstructor(parameters);
- }
-
- public ConstructorInfo[] getDeclaredConstructors()
- {
- return delegate.getDeclaredConstructors();
- }
-
- public FieldInfo getDeclaredField(String name)
- {
- return delegate.getDeclaredField(name);
- }
-
- public FieldInfo[] getDeclaredFields()
- {
- return delegate.getDeclaredFields();
- }
-
- public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
- {
- return delegate.getDeclaredMethod(name, parameters);
- }
-
- public MethodInfo[] getDeclaredMethods()
- {
- return delegate.getDeclaredMethods();
- }
-
- public InterfaceInfo[] getGenericInterfaces()
- {
- return delegate.getGenericInterfaces();
- }
-
- public ClassInfo getGenericSuperclass()
- {
- return delegate.getGenericSuperclass();
- }
-
- public InterfaceInfo[] getInterfaces()
- {
- return delegate.getInterfaces();
- }
-
- public ClassInfo getSuperclass()
- {
- return delegate.getSuperclass();
- }
-
- public boolean isInterface()
- {
- return delegate.isInterface();
- }
-
- public AnnotationValue getAnnotation(String name)
- {
- return delegate.getAnnotation(name);
- }
-
- public AnnotationValue[] getAnnotations()
- {
- return delegate.getAnnotations();
- }
-
- public boolean isAnnotationPresent(String name)
- {
- return delegate.isAnnotationPresent(name);
- }
-
- public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
- {
- return delegate.getUnderlyingAnnotation(annotationType);
- }
-
- public Annotation[] getUnderlyingAnnotations()
- {
- return delegate.getUnderlyingAnnotations();
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return delegate.isAnnotationPresent(annotationType);
- }
-
- public int getModifiers()
- {
- return delegate.getModifiers();
- }
-
- public boolean isPublic()
- {
- return delegate.isPublic();
- }
-
- public boolean isStatic()
- {
- return delegate.isStatic();
- }
-
- public boolean isVolatile()
- {
- return delegate.isVolatile();
- }
-
- public boolean isPrimitive()
- {
- return delegate.isPrimitive();
- }
-
- public TypeInfo[] getActualTypeArguments()
- {
- return delegate.getActualTypeArguments();
- }
-
- public TypeInfo getOwnerType()
- {
- return delegate.getOwnerType();
- }
-
- public ClassInfo getRawType()
- {
- return delegate;
- }
-
- public TypeInfo getComponentType()
- {
- return delegate.getComponentType();
- }
-
- public TypeInfo getKeyType()
- {
- return delegate.getKeyType();
- }
-
- public TypeInfo getValueType()
- {
- return delegate.getValueType();
- }
-
- public PackageInfo getPackage()
- {
- return delegate.getPackage();
- }
-
- @Override
- public Object clone()
- {
- return this;
- }
-
- public String toShortString()
- {
- return name;
- }
-
- public void toShortString(JBossStringBuilder buffer)
- {
- buffer.append(name);
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/NumberInfo.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/spi/NumberInfo.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/NumberInfo.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/NumberInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,348 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.spi;
+
+import java.io.ObjectStreamException;
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Number info
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class NumberInfo extends PrimitiveInfo implements ClassInfo
+{
+ /**
+ * The phase enum
+ */
+ public enum Phase
+ {
+ INSTANTIATED,
+ INITIALIZING,
+ COMPLETE
+ }
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ /** The byte info */
+ public static final NumberInfo BYTE_OBJECT = new NumberInfo(0, Byte.class);
+
+ /** The double info */
+ public static final NumberInfo DOUBLE_OBJECT = new NumberInfo(1, Double.class);
+
+ /** The float info */
+ public static final NumberInfo FLOAT_OBJECT = new NumberInfo(2, Float.class);
+
+ /** The int info */
+ public static final NumberInfo INT_OBJECT = new NumberInfo(3, Integer.class);
+
+ /** The long info */
+ public static final NumberInfo LONG_OBJECT = new NumberInfo(4, Long.class);
+
+ /** The short info */
+ public static final NumberInfo SHORT_OBJECT = new NumberInfo(5, Short.class);
+
+ /** The atomic int info */
+ public static final NumberInfo ATOMIC_INT = new NumberInfo(6, AtomicInteger.class);
+
+ /** The atomic long info */
+ public static final NumberInfo ATOMIC_LONG = new NumberInfo(7, AtomicLong.class);
+
+ /** The primitives */
+ private static final NumberInfo[] values = {
+ BYTE_OBJECT,
+ DOUBLE_OBJECT,
+ FLOAT_OBJECT,
+ INT_OBJECT,
+ LONG_OBJECT,
+ SHORT_OBJECT,
+ ATOMIC_INT,
+ ATOMIC_LONG
+ };
+
+ /** The primitives */
+ private static final HashMap<String, NumberInfo> map = new HashMap<String, NumberInfo>();
+
+ static
+ {
+ map.put(Byte.class.getName(), NumberInfo.BYTE_OBJECT);
+ map.put(Double.class.getName(), NumberInfo.DOUBLE_OBJECT);
+ map.put(Float.class.getName(), NumberInfo.FLOAT_OBJECT);
+ map.put(Integer.class.getName(), NumberInfo.INT_OBJECT);
+ map.put(Long.class.getName(), NumberInfo.LONG_OBJECT);
+ map.put(Short.class.getName(), NumberInfo.SHORT_OBJECT);
+ map.put(AtomicInteger.class.getName(), NumberInfo.ATOMIC_INT);
+ map.put(AtomicLong.class.getName(), NumberInfo.ATOMIC_LONG);
+ }
+
+ private transient ClassInfo delegate;
+
+ private transient Phase phase;
+
+ /**
+ * Get the primitive info for a type
+ *
+ * @param name the name
+ * @return the info
+ */
+ public static NumberInfo valueOf(String name)
+ {
+ return map.get(name);
+ }
+
+ /**
+ * Create a new number info
+ *
+ * @param ordinal the oridinal
+ * @param type the class
+ */
+ protected NumberInfo(int ordinal, Class<? extends Object> type)
+ {
+ super(type.getName(), ordinal, type);
+ phase = Phase.INSTANTIATED;
+ }
+
+ /**
+ * Set the delegate
+ *
+ * @param info the delegate info
+ * @throws IllegalArgumentException if the delegate is null or not a class info
+ */
+ public void setDelegate(TypeInfo info)
+ {
+ if (info == null)
+ throw new IllegalArgumentException("Null info");
+ if (info instanceof ClassInfo == false)
+ throw new IllegalArgumentException("Should be of ClassInfo instance: " + info.getClass().getName());
+ if (info instanceof NumberInfo)
+ throw new IllegalArgumentException("Cannot be delegate to itself: " + info);
+
+ delegate = (ClassInfo) info;
+ phase = Phase.COMPLETE;
+ }
+
+ /**
+ * Get the phase.
+ *
+ * @return the current phase
+ */
+ public Phase getPhase()
+ {
+ return phase;
+ }
+
+ /**
+ * Are we currently initializing delegate.
+ */
+ public void initializing()
+ {
+ phase = Phase.INITIALIZING;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof NumberInfo))
+ return false;
+ NumberInfo other = (NumberInfo) obj;
+ return other.ordinal == this.ordinal;
+ }
+
+ Object readResolve() throws ObjectStreamException
+ {
+ return values[ordinal];
+ }
+
+ // --- delegate
+
+ public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
+ {
+ return delegate.getDeclaredConstructor(parameters);
+ }
+
+ public ConstructorInfo[] getDeclaredConstructors()
+ {
+ return delegate.getDeclaredConstructors();
+ }
+
+ public FieldInfo getDeclaredField(String name)
+ {
+ return delegate.getDeclaredField(name);
+ }
+
+ public FieldInfo[] getDeclaredFields()
+ {
+ return delegate.getDeclaredFields();
+ }
+
+ public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
+ {
+ return delegate.getDeclaredMethod(name, parameters);
+ }
+
+ public MethodInfo[] getDeclaredMethods()
+ {
+ return delegate.getDeclaredMethods();
+ }
+
+ public InterfaceInfo[] getGenericInterfaces()
+ {
+ return delegate.getGenericInterfaces();
+ }
+
+ public ClassInfo getGenericSuperclass()
+ {
+ return delegate.getGenericSuperclass();
+ }
+
+ public InterfaceInfo[] getInterfaces()
+ {
+ return delegate.getInterfaces();
+ }
+
+ public ClassInfo getSuperclass()
+ {
+ return delegate.getSuperclass();
+ }
+
+ public boolean isInterface()
+ {
+ return delegate.isInterface();
+ }
+
+ public AnnotationValue getAnnotation(String name)
+ {
+ return delegate.getAnnotation(name);
+ }
+
+ public AnnotationValue[] getAnnotations()
+ {
+ return delegate.getAnnotations();
+ }
+
+ public boolean isAnnotationPresent(String name)
+ {
+ return delegate.isAnnotationPresent(name);
+ }
+
+ public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
+ {
+ return delegate.getUnderlyingAnnotation(annotationType);
+ }
+
+ public Annotation[] getUnderlyingAnnotations()
+ {
+ return delegate.getUnderlyingAnnotations();
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return delegate.isAnnotationPresent(annotationType);
+ }
+
+ public int getModifiers()
+ {
+ return delegate.getModifiers();
+ }
+
+ public boolean isPublic()
+ {
+ return delegate.isPublic();
+ }
+
+ public boolean isStatic()
+ {
+ return delegate.isStatic();
+ }
+
+ public boolean isVolatile()
+ {
+ return delegate.isVolatile();
+ }
+
+ public boolean isPrimitive()
+ {
+ return delegate.isPrimitive();
+ }
+
+ public TypeInfo[] getActualTypeArguments()
+ {
+ return delegate.getActualTypeArguments();
+ }
+
+ public TypeInfo getOwnerType()
+ {
+ return delegate.getOwnerType();
+ }
+
+ public ClassInfo getRawType()
+ {
+ return delegate;
+ }
+
+ public TypeInfo getComponentType()
+ {
+ return delegate.getComponentType();
+ }
+
+ public TypeInfo getKeyType()
+ {
+ return delegate.getKeyType();
+ }
+
+ public TypeInfo getValueType()
+ {
+ return delegate.getValueType();
+ }
+
+ public PackageInfo getPackage()
+ {
+ return delegate.getPackage();
+ }
+
+ @Override
+ public Object clone()
+ {
+ return this;
+ }
+
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(name);
+ }
+
+ @Override
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append(name);
+ }
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,328 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.reflect.spi;
-
-import java.io.ObjectStreamException;
-import java.util.HashMap;
-
-import org.jboss.reflect.plugins.ClassInfoImpl;
-import org.jboss.reflect.plugins.ValueConvertor;
-import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
-
-/**
- * Primitive info
- *
- * TODO JBMICROCONT-118 fix the introspection assumption
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- */
-public class PrimitiveInfo extends AbstractTypeInfo
-{
- /** serialVersionUID */
- private static final long serialVersionUID = 3256718498443835449L;
-
- /** The boolean info */
- public static final PrimitiveInfo BOOLEAN = new PrimitiveInfo("boolean", 0, Boolean.TYPE);
-
- /** The byte info */
- public static final PrimitiveInfo BYTE = new PrimitiveInfo("byte", 1, Byte.TYPE);
-
- /** The char info */
- public static final PrimitiveInfo CHAR = new PrimitiveInfo("char", 2, Character.TYPE);
-
- /** The double info */
- public static final PrimitiveInfo DOUBLE = new PrimitiveInfo("double", 3, Double.TYPE);
-
- /** The float info */
- public static final PrimitiveInfo FLOAT = new PrimitiveInfo("float", 4, Float.TYPE);
-
- /** The int info */
- public static final PrimitiveInfo INT = new PrimitiveInfo("int", 5, Integer.TYPE);
-
- /** The long info */
- public static final PrimitiveInfo LONG = new PrimitiveInfo("long", 6, Long.TYPE);
-
- /** The short info */
- public static final PrimitiveInfo SHORT = new PrimitiveInfo("short", 7, Short.TYPE);
-
- /** The void info */
- public static final PrimitiveInfo VOID = new PrimitiveInfo("void", 8, Void.TYPE);
-
- /** The primitives */
- private static final PrimitiveInfo[] values = {BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT, VOID};
-
- /** The type info factory */
- protected static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
-
- /** The name */
- protected final transient String name;
-
- /** The ordinal */
- protected final int ordinal;
-
- /** The type */
- protected final transient Class<? extends Object> type;
-
- /** The primitive types indexed by name */
- private static final HashMap<String, Class<?>> primitiveTypes = new HashMap<String, Class<?>>();
-
- /** The primitive array types indexed by name */
- private static final HashMap<String, String> primitiveArrayTypes = new HashMap<String, String>();
-
- /** The primitive array classes indexed by name */
- private static final HashMap<String, Class<?>> primitiveArrayTypesClassMap = new HashMap<String, Class<?>>();
-
- /** The primitives */
- private static final HashMap<String, PrimitiveInfo> map = new HashMap<String, PrimitiveInfo>();
-
- static
- {
- map.put("boolean", BOOLEAN);
- map.put("byte", BYTE);
- map.put("char", CHAR);
- map.put("double", DOUBLE);
- map.put("float", FLOAT);
- map.put("int", INT);
- map.put("long", LONG);
- map.put("short", SHORT);
- map.put("void", VOID);
-
- primitiveTypes.put(Byte.TYPE.getName(), Byte.TYPE);
- primitiveTypes.put(Boolean.TYPE.getName(), Boolean.TYPE);
- primitiveTypes.put(Character.TYPE.getName(), Character.TYPE);
- primitiveTypes.put(Double.TYPE.getName(), Double.TYPE);
- primitiveTypes.put(Float.TYPE.getName(), Float.TYPE);
- primitiveTypes.put(Integer.TYPE.getName(), Integer.TYPE);
- primitiveTypes.put(Long.TYPE.getName(), Long.TYPE);
- primitiveTypes.put(Short.TYPE.getName(), Short.TYPE);
-
- primitiveArrayTypes.put(Byte.TYPE.getName(), "B");
- primitiveArrayTypes.put(Boolean.TYPE.getName(), "Z");
- primitiveArrayTypes.put(Character.TYPE.getName(), "C");
- primitiveArrayTypes.put(Double.TYPE.getName(), "D");
- primitiveArrayTypes.put(Float.TYPE.getName(), "F");
- primitiveArrayTypes.put(Integer.TYPE.getName(), "I");
- primitiveArrayTypes.put(Long.TYPE.getName(), "J");
- primitiveArrayTypes.put(Short.TYPE.getName(), "S");
-
- primitiveArrayTypesClassMap.put("B", Byte.TYPE);
- primitiveArrayTypesClassMap.put("Z", Boolean.TYPE);
- primitiveArrayTypesClassMap.put("C", Character.TYPE);
- primitiveArrayTypesClassMap.put("D", Double.TYPE);
- primitiveArrayTypesClassMap.put("F", Float.TYPE);
- primitiveArrayTypesClassMap.put("I", Integer.TYPE);
- primitiveArrayTypesClassMap.put("J", Long.TYPE);
- primitiveArrayTypesClassMap.put("S", Short.TYPE);
- }
-
- /**
- * Get the primitive info for a type
- *
- * @param name the name
- * @return the info
- */
- public static PrimitiveInfo valueOf(String name)
- {
- return map.get(name);
- }
-
- /**
- * Get a primtive array type
- *
- * @param name the primtive type name
- * @return the array type or null if not found
- */
- public static String getPrimativeArrayType(String name)
- {
- return primitiveArrayTypes.get(name);
- }
-
- /**
- * Get the primtive type for a name
- *
- * @param name the primtive type name
- * @return the primitive type
- */
- public static Class<?> getPrimativeType(String name)
- {
- return primitiveTypes.get(name);
- }
-
- /**
- * Get the primtive array type class map for a name
- *
- * @param name the array type name
- * @return the component type
- */
- public static Class<?> getPrimativeArrayComponentType(String name)
- {
- return primitiveArrayTypesClassMap.get(name);
- }
-
- /**
- * Create a new primitive info
- *
- * @param name the name
- * @param ordinal the oridinal
- * @param type the class
- */
- protected PrimitiveInfo(String name, int ordinal, Class<? extends Object> type)
- {
- this.name = name;
- this.ordinal = ordinal;
- this.type = type;
- }
-
- /**
- * Get the ordinal
- *
- * @return the oridinal
- */
- public int ordinal()
- {
- return ordinal;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getSimpleName()
- {
- return type.getSimpleName();
- }
-
- @Deprecated
- public Class<?> getType()
- {
- return type;
- }
-
- public Object convertValue(Object value) throws Throwable
- {
- Object progressResult = ValueConvertor.progressValue(type, value);
- if (progressResult != null)
- {
- return progressResult;
- }
- return ValueConvertor.convertValue(type, value);
- }
-
- public Object convertValue(Object value, boolean replaceProperties) throws Throwable
- {
- Object progressResult = ValueConvertor.progressValue(type, value);
- if (progressResult != null)
- {
- return progressResult;
- }
- return ValueConvertor.convertValue(type, value, replaceProperties);
- }
-
- public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
- {
- Object progressResult = ValueConvertor.progressValue(type, value);
- if (progressResult != null)
- {
- return progressResult;
- }
- return ValueConvertor.convertValue(type, value, replaceProperties, trim);
- }
-
- @Override
- public boolean isPrimitive()
- {
- return true;
- }
-
- public TypeInfo getArrayType()
- {
- Class<?> arrayClass = ClassInfoImpl.getArrayClass(getType());
- return typeInfoFactory.getTypeInfo(arrayClass);
- }
-
- public Object newArrayInstance(int size) throws Throwable
- {
- throw new UnsupportedOperationException("Not an array " + name);
- }
-
- @SuppressWarnings({"unchecked", "deprecation"})
- public boolean isAssignableFrom(TypeInfo info)
- {
- if (info == this)
- return true;
-
- try
- {
- ProgressionConvertor pc = ProgressionConvertorFactory.getInstance().getConvertor();
- return pc.canProgress(getType(), info.getType());
- }
- catch (Throwable throwable)
- {
- return false;
- }
- }
-
- public TypeInfoFactory getTypeInfoFactory()
- {
- // FIXME - fix this once you fix the top TODO
- return typeInfoFactory;
- }
-
- @Override
- public String toString()
- {
- return name;
- }
-
- @Override
- public String toShortString()
- {
- return name;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof PrimitiveInfo))
- return false;
- if (!obj.getClass().equals(this.getClass()))
- return false;
- PrimitiveInfo other = (PrimitiveInfo) obj;
- return other.ordinal == this.ordinal;
- }
-
- @Override
- public int hashCode()
- {
- return name.hashCode();
- }
-
- Object readResolve() throws ObjectStreamException
- {
- return values[ordinal];
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/PrimitiveInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,348 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.spi;
+
+import java.io.ObjectStreamException;
+import java.util.HashMap;
+
+import org.jboss.reflect.plugins.ClassInfoImpl;
+import org.jboss.reflect.plugins.ValueConvertor;
+import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
+
+/**
+ * Primitive info
+ *
+ * TODO JBMICROCONT-118 fix the introspection assumption
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ */
+public class PrimitiveInfo extends AbstractTypeInfo
+{
+ /** serialVersionUID */
+ private static final long serialVersionUID = 3256718498443835449L;
+
+ /** The boolean info */
+ public static final PrimitiveInfo BOOLEAN = new PrimitiveInfo("boolean", 0, Boolean.TYPE);
+
+ /** The byte info */
+ public static final PrimitiveInfo BYTE = new PrimitiveInfo("byte", 1, Byte.TYPE);
+
+ /** The char info */
+ public static final PrimitiveInfo CHAR = new PrimitiveInfo("char", 2, Character.TYPE);
+
+ /** The double info */
+ public static final PrimitiveInfo DOUBLE = new PrimitiveInfo("double", 3, Double.TYPE);
+
+ /** The float info */
+ public static final PrimitiveInfo FLOAT = new PrimitiveInfo("float", 4, Float.TYPE);
+
+ /** The int info */
+ public static final PrimitiveInfo INT = new PrimitiveInfo("int", 5, Integer.TYPE);
+
+ /** The long info */
+ public static final PrimitiveInfo LONG = new PrimitiveInfo("long", 6, Long.TYPE);
+
+ /** The short info */
+ public static final PrimitiveInfo SHORT = new PrimitiveInfo("short", 7, Short.TYPE);
+
+ /** The void info */
+ public static final PrimitiveInfo VOID = new PrimitiveInfo("void", 8, Void.TYPE);
+
+ /** The primitives */
+ private static final PrimitiveInfo[] values = {BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT, VOID};
+
+ /** The type info factory */
+ protected static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
+
+ /** The name */
+ protected final transient String name;
+
+ /** The ordinal */
+ protected final int ordinal;
+
+ /** The type */
+ protected final transient Class<? extends Object> type;
+
+ /** The primitive types indexed by name */
+ private static final HashMap<String, Class<?>> primitiveTypes = new HashMap<String, Class<?>>();
+
+ /** The primitive array types indexed by name */
+ private static final HashMap<String, String> primitiveArrayTypes = new HashMap<String, String>();
+
+ /** The primitive array classes indexed by name */
+ private static final HashMap<String, Class<?>> primitiveArrayTypesClassMap = new HashMap<String, Class<?>>();
+
+ /** The primitives */
+ private static final HashMap<String, PrimitiveInfo> map = new HashMap<String, PrimitiveInfo>();
+
+ static
+ {
+ map.put("boolean", BOOLEAN);
+ map.put("byte", BYTE);
+ map.put("char", CHAR);
+ map.put("double", DOUBLE);
+ map.put("float", FLOAT);
+ map.put("int", INT);
+ map.put("long", LONG);
+ map.put("short", SHORT);
+ map.put("void", VOID);
+
+ primitiveTypes.put(Byte.TYPE.getName(), Byte.TYPE);
+ primitiveTypes.put(Boolean.TYPE.getName(), Boolean.TYPE);
+ primitiveTypes.put(Character.TYPE.getName(), Character.TYPE);
+ primitiveTypes.put(Double.TYPE.getName(), Double.TYPE);
+ primitiveTypes.put(Float.TYPE.getName(), Float.TYPE);
+ primitiveTypes.put(Integer.TYPE.getName(), Integer.TYPE);
+ primitiveTypes.put(Long.TYPE.getName(), Long.TYPE);
+ primitiveTypes.put(Short.TYPE.getName(), Short.TYPE);
+
+ primitiveArrayTypes.put(Byte.TYPE.getName(), "B");
+ primitiveArrayTypes.put(Boolean.TYPE.getName(), "Z");
+ primitiveArrayTypes.put(Character.TYPE.getName(), "C");
+ primitiveArrayTypes.put(Double.TYPE.getName(), "D");
+ primitiveArrayTypes.put(Float.TYPE.getName(), "F");
+ primitiveArrayTypes.put(Integer.TYPE.getName(), "I");
+ primitiveArrayTypes.put(Long.TYPE.getName(), "J");
+ primitiveArrayTypes.put(Short.TYPE.getName(), "S");
+
+ primitiveArrayTypesClassMap.put("B", Byte.TYPE);
+ primitiveArrayTypesClassMap.put("Z", Boolean.TYPE);
+ primitiveArrayTypesClassMap.put("C", Character.TYPE);
+ primitiveArrayTypesClassMap.put("D", Double.TYPE);
+ primitiveArrayTypesClassMap.put("F", Float.TYPE);
+ primitiveArrayTypesClassMap.put("I", Integer.TYPE);
+ primitiveArrayTypesClassMap.put("J", Long.TYPE);
+ primitiveArrayTypesClassMap.put("S", Short.TYPE);
+ }
+
+ /**
+ * Get the primitive info for a type
+ *
+ * @param name the name
+ * @return the info
+ */
+ public static PrimitiveInfo valueOf(String name)
+ {
+ return map.get(name);
+ }
+
+ /**
+ * Get a primtive array type
+ *
+ * @param name the primtive type name
+ * @return the array type or null if not found
+ */
+ public static String getPrimativeArrayType(String name)
+ {
+ return primitiveArrayTypes.get(name);
+ }
+
+ /**
+ * Get the primtive type for a name
+ *
+ * @param name the primtive type name
+ * @return the primitive type
+ */
+ public static Class<?> getPrimativeType(String name)
+ {
+ return primitiveTypes.get(name);
+ }
+
+ /**
+ * Get the primtive array type class map for a name
+ *
+ * @param name the array type name
+ * @return the component type
+ */
+ public static Class<?> getPrimativeArrayComponentType(String name)
+ {
+ return primitiveArrayTypesClassMap.get(name);
+ }
+
+ /**
+ * Create a new primitive info
+ *
+ * @param name the name
+ * @param ordinal the oridinal
+ * @param type the class
+ */
+ protected PrimitiveInfo(String name, int ordinal, Class<? extends Object> type)
+ {
+ this.name = name;
+ this.ordinal = ordinal;
+ this.type = type;
+ }
+
+ /**
+ * Get the ordinal
+ *
+ * @return the oridinal
+ */
+ public int ordinal()
+ {
+ return ordinal;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getSimpleName()
+ {
+ return type.getSimpleName();
+ }
+
+ @Deprecated
+ public Class<?> getType()
+ {
+ return type;
+ }
+
+ public Object convertValue(Object value) throws Throwable
+ {
+ Object progressResult = ValueConvertor.progressValue(type, value);
+ if (progressResult != null)
+ {
+ return progressResult;
+ }
+ return ValueConvertor.convertValue(type, value);
+ }
+
+ public Object convertValue(Object value, boolean replaceProperties) throws Throwable
+ {
+ Object progressResult = ValueConvertor.progressValue(type, value);
+ if (progressResult != null)
+ {
+ return progressResult;
+ }
+ return ValueConvertor.convertValue(type, value, replaceProperties);
+ }
+
+ public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
+ {
+ Object progressResult = ValueConvertor.progressValue(type, value);
+ if (progressResult != null)
+ {
+ return progressResult;
+ }
+ return ValueConvertor.convertValue(type, value, replaceProperties, trim);
+ }
+
+ @Override
+ public boolean isPrimitive()
+ {
+ return true;
+ }
+
+ public TypeInfo getArrayType()
+ {
+ Class<?> arrayClass = ClassInfoImpl.getArrayClass(getType());
+ return typeInfoFactory.getTypeInfo(arrayClass);
+ }
+
+ public Object newArrayInstance(int size) throws Throwable
+ {
+ throw new UnsupportedOperationException("Not an array " + name);
+ }
+
+ @SuppressWarnings({"unchecked", "deprecation"})
+ public boolean isAssignableFrom(TypeInfo info)
+ {
+ if (info == null)
+ throw new NullPointerException("Parameter info cannot be null!");
+
+ if (info == this)
+ return true;
+
+ return canProgress(info.getType());
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean isInstance(Object object)
+ {
+ return object != null && canProgress(object.getClass());
+ }
+
+ /**
+ * Can we progress class param to this type info.
+ *
+ * @param clazz the class to progress
+ * @return true if we can progress, false otherwise
+ */
+ protected boolean canProgress(Class<?> clazz)
+ {
+ try
+ {
+ ProgressionConvertor pc = ProgressionConvertorFactory.getInstance().getConvertor();
+ return pc.canProgress(getType(), clazz);
+ }
+ catch (Throwable throwable)
+ {
+ return false;
+ }
+ }
+
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ // FIXME - fix this once you fix the top TODO
+ return typeInfoFactory;
+ }
+
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+
+ @Override
+ public String toShortString()
+ {
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof PrimitiveInfo))
+ return false;
+ if (!obj.getClass().equals(this.getClass()))
+ return false;
+ PrimitiveInfo other = (PrimitiveInfo) obj;
+ return other.ordinal == this.ordinal;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ Object readResolve() throws ObjectStreamException
+ {
+ return values[ordinal];
+ }
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/TypeInfo.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/spi/TypeInfo.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/TypeInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,199 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.reflect.spi;
-
-import java.io.Serializable;
-
-/**
- * A type info
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- */
-public interface TypeInfo extends Serializable
-{
- /**
- * Get the type name
- *
- * @return the name
- */
- String getName();
-
- /**
- * Get the simple name
- *
- * @return the simple name
- */
- String getSimpleName();
-
- /**
- * Get the class
- *
- * @deprecated I'm not sure this should be here?
- * @return the class
- */
- Class<?> getType();
-
- /**
- * Convert a value
- *
- * @param value the original value
- * @return the converted value
- * @throws Throwable for any error
- */
- Object convertValue(Object value) throws Throwable;
-
- /**
- * Convert a value
- *
- * @param value the original value
- * @param replaceProperties whether to replace properties
- * @return the converted value
- * @throws Throwable for any error
- */
- Object convertValue(Object value, boolean replaceProperties) throws Throwable;
-
- /**
- * Convert a value
- *
- * @param value the original value
- * @param replaceProperties whether to replace properties
- * @param trim do we trim before conversion
- * @return the converted value
- * @throws Throwable for any error
- */
- Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable;
-
- /**
- * Whether this type is an array
- *
- * @return true when an array
- */
- boolean isArray();
-
- /**
- * Whether this type is a collection
- *
- * @return true when a collection
- */
- boolean isCollection();
-
- /**
- * Whether this type is a map
- *
- * @return true when a map
- */
- boolean isMap();
-
- /**
- * Whether this type is an annotation
- *
- * @return true when an annotation
- */
- boolean isAnnotation();
-
- /**
- * Whether this type is an enum
- *
- * @return true when an enum
- */
- boolean isEnum();
-
- /**
- * Whether this type is a primitive
- *
- * @return true when a primtive
- */
- boolean isPrimitive();
-
- /**
- * Get an array type
- *
- * @return the array type
- */
- TypeInfo getArrayType();
-
- /**
- * Create a new array
- *
- * @param size the size
- * @return the converted value
- * @throws Throwable for any error
- */
- Object newArrayInstance(int size) throws Throwable;
-
- /**
- * Mostly using
- * @see java.lang.Class#isAssignableFrom
- * NumberInfo tests for progression
- *
- * @param info type info
- * @return the boolean value indicating whether objects of the
- * TypeInfo info can be assigned to objects of this TypeInfo
- * @exception NullPointerException if the specified TypeInfo parameter is
- * null.
- */
- boolean isAssignableFrom(TypeInfo info);
-
- /**
- * Get the TypeInfoFactory that created this type info
- *
- * @return type info factory
- */
- TypeInfoFactory getTypeInfoFactory();
-
- /**
- * Get an attachment from the type
- *
- * @param name the name
- * @return the attachment
- */
- Object getAttachment(String name);
-
- /**
- * Get an attachment from the type,
- * uses the expected type as both the name
- * and to cast the resulting object.
- *
- * @param <T> the expected type
- * @param expectedType the expected type
- * @return the attachment
- * @throws ClassCastException when the object is not of the expected type
- */
- <T> T getAttachment(Class<T> expectedType);
-
- /**
- * Set an attachment against the type.
- * This is useful for caching information against a type.<p>
- *
- * If you add a future object, subsequent gets will wait for the result<p>
- *
- * WARNING: Be careful about what you put in here. Don't create
- * references across classloaders, if you are not sure add a WeakReference
- * to the information.
- *
- * @param name the name
- * @param attachment the attachment, pass null to remove an attachment
- * @throws IllegalArgumentException for a null name
- */
- void setAttachment(String name, Object attachment);
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/TypeInfo.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/main/java/org/jboss/reflect/spi/TypeInfo.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/TypeInfo.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/main/java/org/jboss/reflect/spi/TypeInfo.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,209 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.spi;
+
+import java.io.Serializable;
+
+/**
+ * A type info
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ */
+public interface TypeInfo extends Serializable
+{
+ /**
+ * Get the type name
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Get the simple name
+ *
+ * @return the simple name
+ */
+ String getSimpleName();
+
+ /**
+ * Get the class
+ *
+ * @deprecated I'm not sure this should be here?
+ * @return the class
+ */
+ Class<?> getType();
+
+ /**
+ * Convert a value
+ *
+ * @param value the original value
+ * @return the converted value
+ * @throws Throwable for any error
+ */
+ Object convertValue(Object value) throws Throwable;
+
+ /**
+ * Convert a value
+ *
+ * @param value the original value
+ * @param replaceProperties whether to replace properties
+ * @return the converted value
+ * @throws Throwable for any error
+ */
+ Object convertValue(Object value, boolean replaceProperties) throws Throwable;
+
+ /**
+ * Convert a value
+ *
+ * @param value the original value
+ * @param replaceProperties whether to replace properties
+ * @param trim do we trim before conversion
+ * @return the converted value
+ * @throws Throwable for any error
+ */
+ Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable;
+
+ /**
+ * Whether this type is an array
+ *
+ * @return true when an array
+ */
+ boolean isArray();
+
+ /**
+ * Whether this type is a collection
+ *
+ * @return true when a collection
+ */
+ boolean isCollection();
+
+ /**
+ * Whether this type is a map
+ *
+ * @return true when a map
+ */
+ boolean isMap();
+
+ /**
+ * Whether this type is an annotation
+ *
+ * @return true when an annotation
+ */
+ boolean isAnnotation();
+
+ /**
+ * Whether this type is an enum
+ *
+ * @return true when an enum
+ */
+ boolean isEnum();
+
+ /**
+ * Whether this type is a primitive
+ *
+ * @return true when a primtive
+ */
+ boolean isPrimitive();
+
+ /**
+ * Get an array type
+ *
+ * @return the array type
+ */
+ TypeInfo getArrayType();
+
+ /**
+ * Create a new array
+ *
+ * @param size the size
+ * @return the converted value
+ * @throws Throwable for any error
+ */
+ Object newArrayInstance(int size) throws Throwable;
+
+ /**
+ * Mostly using
+ * @see java.lang.Class#isAssignableFrom
+ * PrimitiveInfo tests for progression
+ *
+ * @param info type info
+ * @return the boolean value indicating whether objects of the
+ * TypeInfo info can be assigned to objects of this TypeInfo
+ * @exception NullPointerException if the specified TypeInfo parameter is
+ * null.
+ */
+ boolean isAssignableFrom(TypeInfo info);
+
+ /**
+ * Is object instance of this type info.
+ * @see Class#isInstance(Object)
+ * PrimitiveInfo tests for progression
+ *
+ * @param object the object to check
+ * @return true if <code>object</code> is an instance of this class
+ */
+ boolean isInstance(Object object);
+
+ /**
+ * Get the TypeInfoFactory that created this type info
+ *
+ * @return type info factory
+ */
+ TypeInfoFactory getTypeInfoFactory();
+
+ /**
+ * Get an attachment from the type
+ *
+ * @param name the name
+ * @return the attachment
+ */
+ Object getAttachment(String name);
+
+ /**
+ * Get an attachment from the type,
+ * uses the expected type as both the name
+ * and to cast the resulting object.
+ *
+ * @param <T> the expected type
+ * @param expectedType the expected type
+ * @return the attachment
+ * @throws ClassCastException when the object is not of the expected type
+ */
+ <T> T getAttachment(Class<T> expectedType);
+
+ /**
+ * Set an attachment against the type.
+ * This is useful for caching information against a type.<p>
+ *
+ * If you add a future object, subsequent gets will wait for the result<p>
+ *
+ * WARNING: Be careful about what you put in here. Don't create
+ * references across classloaders, if you are not sure add a WeakReference
+ * to the information.
+ *
+ * @param name the name
+ * @param attachment the attachment, pass null to remove an attachment
+ * @throws IllegalArgumentException for a null name
+ */
+ void setAttachment(String name, Object attachment);
+}
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/ContainerAllTestSuite.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/ContainerAllTestSuite.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/ContainerAllTestSuite.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,54 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-import org.jboss.test.beaninfo.test.BeanInfoTestSuite;
-import org.jboss.test.classinfo.test.ClassInfoTestSuite;
-import org.jboss.test.joinpoint.test.JoinpointTestSuite;
-
-/**
- * All Test Suite.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class ContainerAllTestSuite extends TestSuite
-{
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("All Tests");
-
- suite.addTest(ClassInfoTestSuite.suite());
- suite.addTest(JoinpointTestSuite.suite());
- suite.addTest(BeanInfoTestSuite.suite());
-
- return suite;
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/ContainerAllTestSuite.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/ContainerAllTestSuite.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/ContainerAllTestSuite.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/ContainerAllTestSuite.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.beaninfo.test.BeanInfoTestSuite;
+import org.jboss.test.classinfo.test.ClassInfoTestSuite;
+import org.jboss.test.joinpoint.test.JoinpointTestSuite;
+import org.jboss.test.typeinfo.test.TypeInfoTestSuite;
+
+/**
+ * All Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
+public class ContainerAllTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("All Tests");
+
+ suite.addTest(TypeInfoTestSuite.suite());
+ suite.addTest(ClassInfoTestSuite.suite());
+ suite.addTest(JoinpointTestSuite.suite());
+ suite.addTest(BeanInfoTestSuite.suite());
+
+ return suite;
+ }
+}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCache.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCache.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCache.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCache.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,31 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfoCache.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoCache
+{
+}
\ No newline at end of file
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,186 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.test;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.config.spi.Configuration;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.test.beaninfo.support.BeanInfoAnnotation;
+import org.jboss.test.beaninfo.support.BeanInfoEmpty;
+import org.jboss.test.beaninfo.support.BeanInfoGenericInterface;
+
+/**
+ * BeanInfoCache Test Case.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoCacheTestCase extends AbstractBeanInfoTest
+{
+ public static Test suite()
+ {
+ return suite(BeanInfoCacheTestCase.class);
+ }
+
+ public BeanInfoCacheTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testBeanInfoCaching() throws Exception
+ {
+ assertBeanInfoCaching("Integer", List.class);
+ assertBeanInfoCaching("String", List.class);
+ assertBeanInfoCaching("Integer", Set.class);
+ assertBeanInfoCaching("String", Set.class);
+ assertBeanInfoCaching("Integer", BeanInfoGenericInterface.class);
+ assertBeanInfoCaching("String", BeanInfoGenericInterface.class);
+ assertBeanInfoCaching("", String.class);
+ assertBeanInfoCaching("", BeanInfoAnnotation.class);
+ assertBeanInfoCaching("", BeanInfoEmpty.class);
+ }
+
+ public void testClassLoaderCaching() throws Throwable
+ {
+ String className = BeanInfoEmpty.class.getName();
+ Class<?> clazz = Class.forName(className);
+ URL url1 = clazz.getProtectionDomain().getCodeSource().getLocation();
+ URL[] urls = {url1};
+ ClassLoader cl1 = new URLClassLoader(urls, null);
+
+ clazz = Class.forName(ClassInfo.class.getName());
+ URL url2 = clazz.getProtectionDomain().getCodeSource().getLocation();
+ urls = new URL[]{url1, url2};
+ ClassLoader cl2 = new URLClassLoader(urls, null);
+
+ Configuration configuration = getConfiguration();
+
+ ClassInfo ci1 = configuration.getClassInfo(className, cl1);
+ ClassInfo ci2 = configuration.getClassInfo(className, cl2);
+ assertEquals(ci1, ci2);
+
+ className = "org.jboss.test.beaninfo.support.BeanInfoCache";
+ BeanInfo bi1 = configuration.getBeanInfo(className, cl1);
+ BeanInfo bi2 = configuration.getBeanInfo(className, cl2);
+ assertFalse(bi1.equals(bi2));
+ }
+
+ private void assertBeanInfoCaching(String string, Class<?> clazz) throws Exception
+ {
+ Type type = getType(string, clazz);
+ assertBeanInfoCaching(type);
+ }
+
+ private void assertBeanInfoCaching(Type type) throws Exception
+ {
+ assertClassInfo(type);
+ TypeInfo typeInfo = getConfiguration().getTypeInfo(type);
+ ClassInfo classInfo = assertInstanceOf(typeInfo, ClassInfo.class);
+ assertClassInfo(classInfo);
+ if (type instanceof Class)
+ {
+ Class<?> clazz = Class.class.cast(type);
+ assertClassInfo(classInfo, clazz.getName(), clazz.getClassLoader());
+ }
+ }
+
+ private void assertClassInfo(Type type)
+ {
+ TypeInfo typeInfo = getConfiguration().getTypeInfo(type);
+ ClassInfo classInfo = assertInstanceOf(typeInfo, ClassInfo.class);
+ assertClassInfo(classInfo);
+ }
+
+ private void assertClassInfo(ClassInfo typeInfo)
+ {
+ BeanInfo beanInfo = getConfiguration().getBeanInfo(typeInfo);
+ ClassInfo typeInfo2 = beanInfo.getClassInfo();
+ assertSame(typeInfo, typeInfo2);
+ }
+
+ private void assertClassInfo(ClassInfo typeInfo, String className, ClassLoader cl) throws Exception
+ {
+ BeanInfo beanInfo = getConfiguration().getBeanInfo(className, cl);
+ ClassInfo typeInfo2 = beanInfo.getClassInfo();
+ assertSame(typeInfo, typeInfo2);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Type getType(String type, Class<?> clazz) throws Exception
+ {
+ Method method = getClass().getDeclaredMethod("get" + type + clazz.getSimpleName());
+ return method.getGenericReturnType();
+ }
+
+ public List<Integer> getIntegerList()
+ {
+ return null;
+ }
+
+ public Set<Integer> getIntegerSet()
+ {
+ return null;
+ }
+
+ public List<String> getStringList()
+ {
+ return null;
+ }
+
+ public Set<String> getStringSet()
+ {
+ return null;
+ }
+
+ public BeanInfoGenericInterface<Integer> getIntegerBeanInfoGenericInterface()
+ {
+ return null;
+ }
+
+ public BeanInfoGenericInterface<String> getStringBeanInfoGenericInterface()
+ {
+ return null;
+ }
+
+ public String getString()
+ {
+ return null;
+ }
+
+ public BeanInfoAnnotation getBeanInfoAnnotation()
+ {
+ return null;
+ }
+
+ public BeanInfoEmpty getBeanInfoEmpty()
+ {
+ return null;
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java
===================================================================
--- projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java 2008-11-21 09:56:15 UTC (rev 81411)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -1,52 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.beaninfo.test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * BeanInfo Test Suite.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 58838 $
- */
-public class BeanInfoTestSuite extends TestSuite
-{
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("BeanInfo Tests");
-
- suite.addTest(BeanInfoUnitTestCase.suite());
- suite.addTest(BeanInfoUtilTestCase.suite());
- suite.addTest(FieldAccessRestrictionTestCase.suite());
- suite.addTest(MethodAccessRestrictionTestCase.suite());
-
- return suite;
- }
-}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java (from rev 81413, projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java)
===================================================================
--- projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java (rev 0)
+++ projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/beaninfo/test/BeanInfoTestSuite.java 2008-11-25 13:34:08 UTC (rev 81547)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * BeanInfo Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 58838 $
+ */
+public class BeanInfoTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("BeanInfo Tests");
+
+ suite.addTest(BeanInfoUnitTestCase.suite());
+ suite.addTest(BeanInfoUtilTestCase.suite());
+ suite.addTest(BeanInfoCacheTestCase.suite());
+ suite.addTest(FieldAccessRestrictionTestCase.suite());
+ suite.addTest(MethodAccessRestrictionTestCase.suite());
+
+ return suite;
+ }
+}
Copied: projects/jboss-reflect/tags/2.0.2.GA/src/test/java/org/jboss/test/typeinfo (from rev 81545, projects/jboss-reflect/branches/Branch_2_0/src/test/java/org/jboss/test/typeinfo)
More information about the jboss-cvs-commits
mailing list