[webbeans-commits] Webbeans SVN: r382 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: util and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Sat Nov 29 17:34:32 EST 2008


Author: nickarls
Date: 2008-11-29 17:34:31 -0500 (Sat, 29 Nov 2008)
New Revision: 382

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/Location.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NameResolutionLocation.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NotAScopeException.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Types.java
Log:
javadocs/comments

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/Location.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/Location.java	2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/Location.java	2008-11-29 22:34:31 UTC (rev 382)
@@ -1,14 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.exceptions;
 
+/**
+ * Helper superclass for exception information
+ * 
+ * @author Pete Muir
+ */
 public class Location
 {
-   
+   // The category of the exception 
    private String type;
-   
+   // The bean the exception occurred in
    private String bean;
-   
+   // The element the exception occurred in
    private String element;
 
+   /**
+    * Constructor
+    * 
+    * @param type The category
+    * @param bean The bean
+    * @param element The element
+    */
    public Location(String type, String bean, String element)
    {
       super();
@@ -17,36 +46,71 @@
       this.element = element;
    }
 
+   /**
+    * Gets the type of the exception
+    * 
+    * @return The type
+    */
    public String getType()
    {
       return type;
    }
 
+   /**
+    * Sets the type of the exception
+    * 
+    * @param type The type
+    */
    public void setType(String type)
    {
       this.type = type;
    }
 
+   /**
+    * Gets the bean the exception occurred in
+    * 
+    * @return The bean
+    */
    public String getBean()
    {
       return bean;
    }
 
+   /**
+    * Sets the bean the exception occurred in
+    * 
+    * @param bean The bean
+    */
    public void setBean(String bean)
    {
       this.bean = bean;
    }
 
+   /**
+    * Gets the element the exception occurred in
+    * 
+    * @return The element
+    */
    public String getElement()
    {
       return element;
    }
 
+   /**
+    * Sets the element the exception occurred in
+    * 
+    * @param element The element
+    */
    public void setElement(String element)
    {
       this.element = element;
    }
    
+   /**
+    * Gets the summarizing message
+    * 
+    * @return The message
+    */
    protected String getMessage()
    {
       String location = "";

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NameResolutionLocation.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NameResolutionLocation.java	2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NameResolutionLocation.java	2008-11-29 22:34:31 UTC (rev 382)
@@ -1,26 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.exceptions;
 
+/**
+ * Exception location info for name resolution exceptions
+ * 
+ * @author Pete Muir
+ */
 public class NameResolutionLocation extends Location
 {
-   
+   // The target of the failure
    private String target;
    
+   /**
+    * Constructor
+    * 
+    * @param target The target of the failure 
+    */
    public NameResolutionLocation(String target)
    {
       super("Named Based Resolution", null, null);
       
    }
    
+   /**
+    * Gets the target
+    * 
+    * @return The target
+    */
    public String getTarget()
    {
       return target;
    }
    
+   /** 
+    * Sets the target
+    * 
+    * @param target The target
+    */
    public void setTarget(String target)
    {
       this.target = target;
    }
    
+   /**
+    * Gets the exception message
+    * 
+    * @return The message
+    */
    @Override
    protected String getMessage()
    {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NotAScopeException.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NotAScopeException.java	2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NotAScopeException.java	2008-11-29 22:34:31 UTC (rev 382)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.exceptions;
 
 import javax.webbeans.DefinitionException;
@@ -2,5 +19,14 @@
 
+/**
+ * Exception for incorrect scope usage
+ * 
+ * @author Pete Muir
+ */
 public class NotAScopeException extends DefinitionException
 {
+   private static final long serialVersionUID = 1L;
 
+   /**
+    * Constructor
+    */
    public NotAScopeException()
@@ -10,19 +36,35 @@
       super();
    }
 
+   /**
+    * Constructor
+    * 
+    * @param message The exception message
+    * @param throwable The root exception
+    */
    public NotAScopeException(String message, Throwable throwable)
    {
       super(message, throwable);
    }
 
+   /**
+    * Constructor
+    * 
+    * @param message The exception message
+    */
    public NotAScopeException(String message)
    {
       super(message);
    }
 
+   /**
+    * Constructor
+    * 
+    * @param throwable The root exception
+    */
    public NotAScopeException(Throwable throwable)
    {
       super(throwable);
    }
-   
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java	2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java	2008-11-29 22:34:31 UTC (rev 382)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.util;
 
 import java.lang.reflect.Method;
@@ -11,33 +28,90 @@
 import org.jboss.webbeans.bean.XmlSimpleBean;
 import org.jboss.webbeans.introspector.AnnotatedMethod;
 
+/**
+ * Utility class for creating Web Beans
+ * 
+ * @author Pete Muir
+ */
 public class BeanFactory
 {
+   /**
+    * Creates a simple, annotation defined Web Bean
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param manager The Web Beans manager
+    * @return A Web Bean
+    */
    public static <T> SimpleBean<T> createSimpleBean(Class<T> clazz, ManagerImpl manager)
    {
       return new SimpleBean<T>(clazz, manager);
    }
 
+   /**
+    * Creates a simple, XML defined Web Bean
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param manager The Web Beans manager
+    * @return A Web Bean
+    */
    public static <T> XmlSimpleBean<T> createXmlSimpleBean(Class<T> clazz, ManagerImpl manager)
    {
       return new XmlSimpleBean<T>(clazz, manager);
    }
 
+   /**
+    * Creates a simple, annotation defined Enterprise Web Bean
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param manager The Web Beans manager
+    * @return An Enterprise Web Bean
+    */
    public static <T> EnterpriseBean<T> createEnterpriseBean(Class<T> clazz, ManagerImpl manager)
    {
       return new EnterpriseBean<T>(clazz, manager);
    }
 
+   /**
+    * Creates a simple, XML defined Enterprise Web Bean
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param manager The Web Beans manager
+    * @return An Enterprise Web Bean
+    */
    public static <T> XmlEnterpriseBean<T> createXmlEnterpriseBean(Class<T> clazz, ManagerImpl manager)
    {
       return new XmlEnterpriseBean<T>(clazz, manager);
    }
 
+   /**
+    * Creates a producer method Web Bean
+    * 
+    * @param <T> The type
+    * @param type The class
+    * @param method The underlying method
+    * @param manager The Web Beans manager
+    * @param declaringBean The declaring bean abstraction
+    * @return A producer Web Bean
+    */
    public static <T> ProducerMethodBean<T> createProducerMethodBean(Class<T> type, Method method, ManagerImpl manager, AbstractClassBean<?> declaringBean)
    {
       return new ProducerMethodBean<T>(method, declaringBean, manager);
    }
-   
+
+   /**
+    * Creates a producer method Web Bean
+    * 
+    * @param <T> The type
+    * @param type The class
+    * @param method The underlying method
+    * @param manager The Web Beans manager
+    * @param declaringBean The declaring bean abstraction
+    * @return A producer Web Bean
+    */
    public static <T> ProducerMethodBean<T> createProducerMethodBean(Class<T> type, AnnotatedMethod<T> method, ManagerImpl manager, AbstractClassBean<?> declaringBean)
    {
       return new ProducerMethodBean<T>(method, declaringBean, manager);

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java	2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java	2008-11-29 22:34:31 UTC (rev 382)
@@ -1,14 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.util;
 
-
+/**
+ * Provides JNDI access abstraction
+ * 
+ * @author Pete Muir
+ */
 public class JNDI
 {
 
+   /**
+    * Looks up a object in JNDI
+    * 
+    * @param name The JNDI name
+    * @return The object
+    */
    public static Object lookup(String name)
    {
       return lookup(name, Object.class);
    }
    
+   /**
+    * Typed JNDI lookup
+    * 
+    * @param <T> The type
+    * @param name The JNDI name
+    * @param expectedType The excpected type
+    * @return The object
+    */
    public static <T> T lookup(String name, Class<? extends T> expectedType)
    {
       return null;

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java	2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java	2008-11-29 22:34:31 UTC (rev 382)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.util;
 
 import java.beans.Introspector;
@@ -18,9 +35,22 @@
 
 import javax.webbeans.ExecutionException;
 
+/**
+ * Utility class for static reflection-type operations
+ * 
+ * @author Pete Muir
+ * 
+ */
 public class Reflections
 {
 
+   /**
+    * Creates an instance from a class name
+    * 
+    * @param name The class name
+    * @return The instance
+    * @throws ClassNotFoundException If the class if not found
+    */
    public static Class<?> classForName(String name) throws ClassNotFoundException
    {
       try
@@ -33,6 +63,13 @@
       }
    }
 
+   /**
+    * Gets the property name from a getter method
+    * 
+    * @param method The getter method
+    * @return The name of the property. Returns null if method wasn't JavaBean
+    *         getter-styled
+    */
    public static String getPropertyName(Method method)
    {
       String methodName = method.getName();
@@ -51,16 +88,34 @@
 
    }
 
+   /**
+    * Checks if class is final
+    * 
+    * @param clazz The class to check
+    * @return True if final, false otherwise
+    */
    public static boolean isFinal(Class<?> clazz)
    {
       return Modifier.isFinal(clazz.getModifiers());
    }
 
+   /**
+    * Checks if member is final
+    * 
+    * @param member The member to check
+    * @return True if final, false otherwise
+    */
    public static boolean isFinal(Member member)
    {
       return Modifier.isFinal(member.getModifiers());
    }
 
+   /**
+    * Checks if type or member is final
+    * 
+    * @param type Type or member
+    * @return True if final, false otherwise
+    */
    public static boolean isTypeOrAnyMethodFinal(Class<?> type)
    {
       if (isFinal(type))
@@ -77,36 +132,80 @@
       return false;
    }
 
+   /**
+    * Checks if type is primitive
+    * 
+    * @param type Type to check
+    * @return True if primitive, false otherwise
+    */
    public static boolean isPrimitive(Class<?> type)
    {
       return type.isPrimitive();
    }
 
+   /**
+    * Checks if type is static
+    * 
+    * @param type Type to check
+    * @return True if static, false otherwise
+    */
    public static boolean isStatic(Class<?> type)
    {
       return Modifier.isStatic(type.getModifiers());
    }
 
+   /**
+    * Checks if member is static
+    * 
+    * @param member Member to check
+    * @return True if static, false otherwise
+    */
    public static boolean isStatic(Member member)
    {
       return Modifier.isStatic(member.getModifiers());
    }
 
+   /**
+    * Checks if clazz is abstract
+    * 
+    * @param clazz Class to check
+    * @return True if abstract, false otherwise
+    */
    public static boolean isAbstract(Class<?> clazz)
    {
       return Modifier.isAbstract(clazz.getModifiers());
    }
 
+   /**
+    * Checks if class is a static inner one
+    * 
+    * @param clazz Class to check
+    * @return True if static, false otherwise
+    */
    public static boolean isStaticInnerClass(Class<?> clazz)
    {
       return clazz.isMemberClass() && isStatic(clazz);
    }
 
+   /**
+    * Checks if class is a non-static inner one
+    * 
+    * @param clazz Class to Check
+    * @return True if static, false otherwise
+    */
    public static boolean isNonStaticInnerClass(Class<?> clazz)
    {
       return clazz.isMemberClass() && !isStatic(clazz);
    }
 
+   /**
+    * Gets a constructor with matching parameter types
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param parameterTypes The parameter types
+    * @return The matching constructor. Null is returned if none is found
+    */
    public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... parameterTypes)
    {
       try
@@ -123,6 +222,14 @@
       }
    }
 
+   /**
+    * Gets all methods with a given annotation
+    * 
+    * @param clazz The class the examine
+    * @param annotationType The annotation type to search for
+    * @return A list of matching methods. An empty list is returned if no
+    *         matches are found
+    */
    public static List<Method> getMethods(Class<?> clazz, Class<? extends Annotation> annotationType)
    {
       List<Method> methods = new ArrayList<Method>();
@@ -136,6 +243,15 @@
       return methods;
    }
 
+   /**
+    * Gets all constructors with a given annotation
+    * 
+    * @param <T> The type of the class
+    * @param clazz The class
+    * @param annotationType The annotation type
+    * @return A list of matching constructors. An empty list is returned if no
+    *         matches are found
+    */
    @SuppressWarnings("unchecked")
    public static <T> List<Constructor<T>> getAnnotatedConstructors(Class<? extends T> clazz, Class<? extends Annotation> annotationType)
    {
@@ -150,6 +266,15 @@
       return constructors;
    }
 
+   /**
+    * Gets constructors with a given annotated parameter
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param parameterAnnotationType The parameter annotation type
+    * @return A list of matching constructors. An empty list is returned if no
+    *         matches are found
+    */
    @SuppressWarnings("unchecked")
    public static <T> List<Constructor<T>> getConstructorsForAnnotatedParameter(Class<? extends T> clazz, Class<? extends Annotation> parameterAnnotationType)
    {
@@ -170,6 +295,15 @@
       return constructors;
    }
 
+   /**
+    * Gets constructors with a given meta-annotated parameter
+    * 
+    * @param <T> The type
+    * @param clazz The class
+    * @param metaAnnotationType The parameter meta-annotation type
+    * @return A list of matching constructors. An empty list is returned if no
+    *         matches are found
+    */
    @SuppressWarnings("unchecked")
    public static <T> List<Constructor<T>> getConstructorsForMetaAnnotatedParameter(Class<? extends T> clazz, Class<? extends Annotation> metaAnnotationType)
    {
@@ -190,6 +324,13 @@
       return constructors;
    }
 
+   /**
+    * Checks if all annotations types are in a given set of annotations
+    * 
+    * @param annotations The annotation set
+    * @param annotationTypes The annotation types to match
+    * @return True if match, false otherwise
+    */
    public static boolean annotationTypeSetMatches(Set<Class<? extends Annotation>> annotations, Class<? extends Annotation>... annotationTypes)
    {
       List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
@@ -208,6 +349,13 @@
       return annotationTypeList.size() == 0;
    }
 
+   /**
+    * Checks if all annotations are in a given set of annotations
+    * 
+    * @param annotations The annotation set
+    * @param annotationTypes The annotations to match
+    * @return True if match, false otherwise
+    */
    public static boolean annotationSetMatches(Set<Annotation> annotations, Class<? extends Annotation>... annotationTypes)
    {
       List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
@@ -226,6 +374,12 @@
       return annotationTypeList.size() == 0;
    }
 
+   /**
+    * Gets the actual type arguments of a class
+    * 
+    * @param clazz The class to examine
+    * @return The type arguments
+    */
    public static Type[] getActualTypeArguments(Class<?> clazz)
    {
       if (clazz.getGenericSuperclass() instanceof ParameterizedType)
@@ -238,16 +392,36 @@
       }
    }
 
+   /**
+    * Checks if raw type is array type
+    * 
+    * @param rawType The raw type to check
+    * @return True if array, false otherwise
+    */
    public static boolean isArrayType(Class<?> rawType)
    {
       return rawType.isArray();
    }
 
+   /**
+    * Checks if type is parameterized type
+    * 
+    * @param type The type to check
+    * @return True if parameterized, false otherwise
+    */
    public static boolean isParameterizedType(Class<?> type)
    {
       return type.getTypeParameters().length > 0;
    }
 
+   /**
+    * Invokes a method and wraps exceptions
+    * 
+    * @param method The method to invoke
+    * @param instance The instance to invoke on
+    * @param parameters The parameters
+    * @return The return value
+    */
    public static Object invokeAndWrap(Method method, Object instance, Object... parameters)
    {
       try
@@ -268,6 +442,13 @@
       }
    }
 
+   /**
+    * Sets value of a field and wraps exceptions
+    * 
+    * @param field The field to set on
+    * @param target The instance to set on
+    * @param value The value to set
+    */
    public static void setAndWrap(Field field, Object target, Object value)
    {
       try
@@ -284,6 +465,13 @@
       }
    }
 
+   /**
+    * Looks up a method in the type hierarchy of an instance
+    * 
+    * @param method The method to look for
+    * @param instance The instance to start from
+    * @return The method found, or an NoSuchMethodException if it is not found
+    */
    public static Method lookupMethod(Method method, Object instance)
    {
       for (Class<? extends Object> clazz = instance.getClass(); clazz != Object.class; clazz = clazz.getSuperclass())
@@ -305,6 +493,12 @@
       throw new IllegalArgumentException("Method " + method.getName() + " not implemented by instance");
    }
 
+   /**
+    * Indicates if an instance is a Javassist proxy
+    * 
+    * @param instance The instance to examine
+    * @return True if proxy, false otherwise
+    */
    public static boolean isProxy(Object instance)
    {
       return instance.getClass().getName().indexOf("_$$_javassist_") > 0;

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java	2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java	2008-11-29 22:34:31 UTC (rev 382)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.util;
 
 import java.beans.Introspector;
@@ -7,14 +24,33 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
+/**
+ * String utilities
+ * 
+ * @author Pete Muir
+ * 
+ */
 public class Strings
 {
 
+   /**
+    * Decapitalizes a String
+    * 
+    * @param camelCase The String
+    * @return The decapitalized result
+    */
    public static String decapitalize(String camelCase)
    {
       return Introspector.decapitalize(camelCase);
    }
 
+   /**
+    * Split a string into parts
+    * 
+    * @param strings The sources
+    * @param delims The delimeter
+    * @return The parts
+    */
    public static String[] split(String strings, String delims)
    {
       if (strings == null)
@@ -34,6 +70,13 @@
       }
    }
 
+   /**
+    * Returns a textual representation of a map for debug purposes
+    * 
+    * @param header The description of the map
+    * @param map The map
+    * @return A textual representation
+    */
    public static String mapToString(String header, Map<?, ?> map)
    {
       StringBuffer buffer = new StringBuffer();
@@ -48,7 +91,7 @@
             buffer.append("\n");
             for (Object subValue : (Iterable<?>) value)
             {
-                buffer.append("    " + subValue.toString() + "\n");
+               buffer.append("    " + subValue.toString() + "\n");
             }
          }
          else
@@ -59,15 +102,18 @@
       return buffer.toString();
    }
 
-   public static void main(String[] args) {
-     Map map = new HashMap<String, Collection<?>>();
-     Collection a = new ArrayList<String>();
-     a.add("1"); a.add("2");
-     map.put("foo", a);
-     Collection b = new ArrayList<String>();
-     b.add("3"); b.add("4");
-     map.put("bar", b);
-     System.out.println(mapToString("Header: ", map));
+   public static void main(String[] args)
+   {
+      Map map = new HashMap<String, Collection<?>>();
+      Collection a = new ArrayList<String>();
+      a.add("1");
+      a.add("2");
+      map.put("foo", a);
+      Collection b = new ArrayList<String>();
+      b.add("3");
+      b.add("4");
+      map.put("bar", b);
+      System.out.println(mapToString("Header: ", map));
    }
-   
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Types.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Types.java	2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Types.java	2008-11-29 22:34:31 UTC (rev 382)
@@ -1,8 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.util;
 
+/**
+ * Utility class for Types
+ * 
+ * @author Pete Muir
+ */
 public class Types
 {
-   
+
+   /**
+    * Gets the boxed type of a class
+    * 
+    * @param type The type
+    * @return The boxed type
+    */
    public static Class<?> boxedType(Class<?> type)
    {
       if (type.isPrimitive())
@@ -39,7 +67,7 @@
          {
             return Double.class;
          }
-         else 
+         else
          {
             throw new IllegalStateException("Some weird type!!!");
          }
@@ -49,5 +77,5 @@
          return type;
       }
    }
-   
+
 }




More information about the weld-commits mailing list