You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/10/01 22:06:12 UTC

svn commit: r1392562 [5/5] - in /maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils: ./ cli/ cli/shell/ introspection/ io/ reflection/ xml/

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java Mon Oct  1 20:06:11 2012
@@ -23,7 +23,6 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-
 import java.util.HashMap;
 import java.util.Map;
 
@@ -41,7 +40,9 @@ public final class Reflector
 
     private HashMap classMaps = new HashMap();
 
-    /** Ensure no instances of Reflector are created...this is a utility. */
+    /**
+     * Ensure no instances of Reflector are created...this is a utility.
+     */
     public Reflector()
     {
     }
@@ -51,13 +52,10 @@ public final class Reflector
      * constructor caching to find a constructor that matches the parameter
      * types, either specifically (first choice) or abstractly...
      *
-     * @param theClass
-     *            The class to instantiate
-     * @param params
-     *            The parameters to pass to the constructor
+     * @param theClass The class to instantiate
+     * @param params   The parameters to pass to the constructor
      * @return The instantiated object
-     * @throws ReflectorException
-     *             In case anything goes wrong here...
+     * @throws ReflectorException In case anything goes wrong here...
      */
     public Object newInstance( Class theClass, Object[] params )
         throws ReflectorException
@@ -118,13 +116,10 @@ public final class Reflector
      * parameters... Uses constructor caching to find a constructor that matches
      * the parameter types, either specifically (first choice) or abstractly...
      *
-     * @param theClass
-     *            The class to retrieve the singleton of
-     * @param initParams
-     *            The parameters to pass to the constructor
+     * @param theClass   The class to retrieve the singleton of
+     * @param initParams The parameters to pass to the constructor
      * @return The singleton object
-     * @throws ReflectorException
-     *             In case anything goes wrong here...
+     * @throws ReflectorException In case anything goes wrong here...
      */
     public Object getSingleton( Class theClass, Object[] initParams )
         throws ReflectorException
@@ -156,15 +151,11 @@ public final class Reflector
      * Invoke the specified method on the specified target with the specified
      * params...
      *
-     * @param target
-     *            The target of the invocation
-     * @param methodName
-     *            The method name to invoke
-     * @param params
-     *            The parameters to pass to the method invocation
+     * @param target     The target of the invocation
+     * @param methodName The method name to invoke
+     * @param params     The parameters to pass to the method invocation
      * @return The result of the method call
-     * @throws ReflectorException
-     *             In case of an error looking up or invoking the method.
+     * @throws ReflectorException In case of an error looking up or invoking the method.
      */
     public Object invoke( Object target, String methodName, Object[] params )
         throws ReflectorException
@@ -189,8 +180,8 @@ public final class Reflector
             {
                 StringBuffer buffer = new StringBuffer();
 
-                buffer.append( "Singleton-producing method named '" ).append( methodName )
-                      .append( "' not found with specified parameter classes: " );
+                buffer.append( "Singleton-producing method named '" ).append( methodName ).append(
+                    "' not found with specified parameter classes: " );
 
                 for ( int i = 0; i < paramTypes.length; i++ )
                 {
@@ -281,7 +272,9 @@ public final class Reflector
             catch ( NoSuchFieldException e )
             {
                 if ( targetClass == Object.class )
+                {
                     throw new ReflectorException( e );
+                }
                 targetClass = targetClass.getSuperclass();
             }
             catch ( IllegalAccessException e )
@@ -296,15 +289,11 @@ public final class Reflector
     /**
      * Invoke the specified static method with the specified params...
      *
-     * @param targetClass
-     *            The target class of the invocation
-     * @param methodName
-     *            The method name to invoke
-     * @param params
-     *            The parameters to pass to the method invocation
+     * @param targetClass The target class of the invocation
+     * @param methodName  The method name to invoke
+     * @param params      The parameters to pass to the method invocation
      * @return The result of the method call
-     * @throws ReflectorException
-     *             In case of an error looking up or invoking the method.
+     * @throws ReflectorException In case of an error looking up or invoking the method.
      */
     public Object invokeStatic( Class targetClass, String methodName, Object[] params )
         throws ReflectorException
@@ -330,7 +319,7 @@ public final class Reflector
                 StringBuffer buffer = new StringBuffer();
 
                 buffer.append( "Singleton-producing method named \'" + methodName
-                    + "\' not found with specified parameter classes: " );
+                                   + "\' not found with specified parameter classes: " );
 
                 for ( int i = 0; i < paramTypes.length; i++ )
                 {
@@ -359,14 +348,11 @@ public final class Reflector
      * Return the constructor, checking the cache first and storing in cache if
      * not already there..
      *
-     * @param targetClass
-     *            The class to get the constructor from
-     * @param params
-     *            The classes of the parameters which the constructor should
-     *            match.
+     * @param targetClass The class to get the constructor from
+     * @param params      The classes of the parameters which the constructor should
+     *                    match.
      * @return the Constructor object that matches.
-     * @throws ReflectorException
-     *             In case we can't retrieve the proper constructor.
+     * @throws ReflectorException In case we can't retrieve the proper constructor.
      */
     public Constructor getConstructor( Class targetClass, Class[] params )
         throws ReflectorException
@@ -428,8 +414,8 @@ public final class Reflector
 
         if ( constructor == null )
         {
-            throw new ReflectorException( "Error retrieving constructor object for: " + targetClass.getName()
-                + paramKey );
+            throw new ReflectorException(
+                "Error retrieving constructor object for: " + targetClass.getName() + paramKey );
         }
 
         return constructor;
@@ -452,7 +438,7 @@ public final class Reflector
         }
 
         Class targetClass = target.getClass();
-        Class[] emptyParams = {};
+        Class[] emptyParams = { };
 
         Method method = _getMethod( targetClass, beanAccessor, emptyParams );
         if ( method == null )
@@ -463,17 +449,17 @@ public final class Reflector
         {
             try
             {
-                returnValue = method.invoke( target, new Object[] {} );
+                returnValue = method.invoke( target, new Object[]{ } );
             }
             catch ( IllegalAccessException e )
             {
-                throw new ReflectorException( "Error retrieving property \'" + propertyName + "\' from \'"
-                    + targetClass + "\'", e );
+                throw new ReflectorException(
+                    "Error retrieving property \'" + propertyName + "\' from \'" + targetClass + "\'", e );
             }
             catch ( InvocationTargetException e )
             {
-                throw new ReflectorException( "Error retrieving property \'" + propertyName + "\' from \'"
-                    + targetClass + "\'", e );
+                throw new ReflectorException(
+                    "Error retrieving property \'" + propertyName + "\' from \'" + targetClass + "\'", e );
             }
         }
 
@@ -481,17 +467,17 @@ public final class Reflector
         {
             try
             {
-                returnValue = method.invoke( target, new Object[] {} );
+                returnValue = method.invoke( target, new Object[]{ } );
             }
             catch ( IllegalAccessException e )
             {
-                throw new ReflectorException( "Error retrieving property \'" + propertyName + "\' from \'"
-                    + targetClass + "\'", e );
+                throw new ReflectorException(
+                    "Error retrieving property \'" + propertyName + "\' from \'" + targetClass + "\'", e );
             }
             catch ( InvocationTargetException e )
             {
-                throw new ReflectorException( "Error retrieving property \'" + propertyName + "\' from \'"
-                    + targetClass + "\'", e );
+                throw new ReflectorException(
+                    "Error retrieving property \'" + propertyName + "\' from \'" + targetClass + "\'", e );
             }
         }
         else
@@ -500,9 +486,10 @@ public final class Reflector
             if ( method == null && returnValue == null )
             {
                 // TODO: Check if exception is the right action! Field exists, but contains null
-                throw new ReflectorException( "Neither method: \'" + propertyName + "\' nor bean accessor: \'"
-                    + beanAccessor + "\' can be found for class: \'" + targetClass
-                    + "\', and retrieval of field: \'" + propertyName + "\' returned null as value." );
+                throw new ReflectorException(
+                    "Neither method: \'" + propertyName + "\' nor bean accessor: \'" + beanAccessor
+                        + "\' can be found for class: \'" + targetClass + "\', and retrieval of field: \'"
+                        + propertyName + "\' returned null as value." );
             }
         }
 
@@ -513,13 +500,10 @@ public final class Reflector
      * Return the method, checking the cache first and storing in cache if not
      * already there..
      *
-     * @param targetClass
-     *            The class to get the method from
-     * @param params
-     *            The classes of the parameters which the method should match.
+     * @param targetClass The class to get the method from
+     * @param params      The classes of the parameters which the method should match.
      * @return the Method object that matches.
-     * @throws ReflectorException
-     *             In case we can't retrieve the proper method.
+     * @throws ReflectorException In case we can't retrieve the proper method.
      */
     public Method getMethod( Class targetClass, String methodName, Class[] params )
         throws ReflectorException
@@ -528,8 +512,8 @@ public final class Reflector
 
         if ( method == null )
         {
-            throw new ReflectorException( "Method: \'" + methodName + "\' not found in class: \'" + targetClass
-                + "\'" );
+            throw new ReflectorException(
+                "Method: \'" + methodName + "\' not found in class: \'" + targetClass + "\'" );
         }
 
         return method;
@@ -601,11 +585,9 @@ public final class Reflector
     /**
      * Retrieve the cache of constructors for the specified class.
      *
-     * @param theClass
-     *            the class to lookup.
+     * @param theClass the class to lookup.
      * @return The cache of constructors.
-     * @throws ReflectorException
-     *             in case of a lookup error.
+     * @throws ReflectorException in case of a lookup error.
      */
     private Map getConstructorMap( Class theClass )
         throws ReflectorException
@@ -616,13 +598,10 @@ public final class Reflector
     /**
      * Retrieve the cache of methods for the specified class and method name.
      *
-     * @param theClass
-     *            the class to lookup.
-     * @param methodName
-     *            The name of the method to lookup.
+     * @param theClass   the class to lookup.
+     * @param methodName The name of the method to lookup.
      * @return The cache of constructors.
-     * @throws ReflectorException
-     *             in case of a lookup error.
+     * @throws ReflectorException in case of a lookup error.
      */
     private Map getMethodMap( Class theClass, String methodName )
         throws ReflectorException

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java Mon Oct  1 20:06:11 2012
@@ -39,8 +39,7 @@ public class ReflectorException
     /**
      * Create a new ReflectorException with the specified message.
      *
-     * @param msg
-     *            The message.
+     * @param msg The message.
      */
     public ReflectorException( String msg )
     {
@@ -50,8 +49,7 @@ public class ReflectorException
     /**
      * Create a new ReflectorException with the specified root cause.
      *
-     * @param root
-     *            The root cause.
+     * @param root The root cause.
      */
     public ReflectorException( Throwable root )
     {
@@ -62,10 +60,8 @@ public class ReflectorException
      * Create a new ReflectorException with the specified message and root
      * cause.
      *
-     * @param msg
-     *            The message.
-     * @param root
-     *            The root cause.
+     * @param msg  The message.
+     * @param root The root cause.
      */
     public ReflectorException( String msg, Throwable root )
     {

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReader.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReader.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReader.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReader.java Mon Oct  1 20:06:11 2012
@@ -87,10 +87,10 @@ public class XmlReader
     public XmlReader( InputStream is, String httpContentType, boolean lenient, String defaultEncoding )
         throws IOException, XmlStreamReaderException
     {
-        reader =
-            new org.apache.commons.io.input.XmlStreamReader( is, httpContentType, lenient,
-                                                             ( defaultEncoding == null ) ? _staticDefaultEncoding
-                                                                             : defaultEncoding );
+        reader = new org.apache.commons.io.input.XmlStreamReader( is, httpContentType, lenient,
+                                                                  ( defaultEncoding == null )
+                                                                      ? _staticDefaultEncoding
+                                                                      : defaultEncoding );
     }
 
     public XmlReader( InputStream is, String httpContentType, boolean lenient )

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReaderException.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReaderException.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReaderException.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReaderException.java Mon Oct  1 20:06:11 2012
@@ -16,21 +16,22 @@
  */
 package org.apache.maven.shared.utils.xml;
 
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * The XmlReaderException is thrown by the XmlReader constructors if the charset encoding can not be determined
  * according to the XML 1.0 specification and RFC 3023.
- * <p>
+ * <p/>
  * The exception returns the unconsumed InputStream to allow the application to do an alternate processing with the
  * stream. Note that the original InputStream given to the XmlReader cannot be used as that one has been already read.
- * <p>
+ * <p/>
  *
  * @author Alejandro Abdelnur
  * @version revision 1.1 taken on 26/06/2007 from Rome (see https://rome.dev.java.net/source/browse/rome/src/java/com/sun/syndication/io/XmlReaderException.java)
  */
-public class XmlReaderException extends IOException
+public class XmlReaderException
+    extends IOException
 {
     private String _bomEncoding;
 
@@ -46,21 +47,15 @@ public class XmlReaderException extends 
 
     /**
      * Creates an exception instance if the charset encoding could not be determined.
-     * <p>
+     * <p/>
      * Instances of this exception are thrown by the XmlReader.
-     * <p>
-     *
-     * @param msg
-     *            message describing the reason for the exception.
-     * @param bomEnc
-     *            BOM encoding.
-     * @param xmlGuessEnc
-     *            XML guess encoding.
-     * @param xmlEnc
-     *            XML prolog encoding.
-     * @param is
-     *            the unconsumed InputStream.
+     * <p/>
      *
+     * @param msg         message describing the reason for the exception.
+     * @param bomEnc      BOM encoding.
+     * @param xmlGuessEnc XML guess encoding.
+     * @param xmlEnc      XML prolog encoding.
+     * @param is          the unconsumed InputStream.
      */
     public XmlReaderException( String msg, String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is )
     {
@@ -69,25 +64,17 @@ public class XmlReaderException extends 
 
     /**
      * Creates an exception instance if the charset encoding could not be determined.
-     * <p>
+     * <p/>
      * Instances of this exception are thrown by the XmlReader.
-     * <p>
-     *
-     * @param msg
-     *            message describing the reason for the exception.
-     * @param ctMime
-     *            MIME type in the content-type.
-     * @param ctEnc
-     *            encoding in the content-type.
-     * @param bomEnc
-     *            BOM encoding.
-     * @param xmlGuessEnc
-     *            XML guess encoding.
-     * @param xmlEnc
-     *            XML prolog encoding.
-     * @param is
-     *            the unconsumed InputStream.
+     * <p/>
      *
+     * @param msg         message describing the reason for the exception.
+     * @param ctMime      MIME type in the content-type.
+     * @param ctEnc       encoding in the content-type.
+     * @param bomEnc      BOM encoding.
+     * @param xmlGuessEnc XML guess encoding.
+     * @param xmlEnc      XML prolog encoding.
+     * @param is          the unconsumed InputStream.
      */
     public XmlReaderException( String msg, String ctMime, String ctEnc, String bomEnc, String xmlGuessEnc,
                                String xmlEnc, InputStream is )
@@ -103,10 +90,9 @@ public class XmlReaderException extends 
 
     /**
      * Returns the BOM encoding found in the InputStream.
-     * <p>
+     * <p/>
      *
      * @return the BOM encoding, null if none.
-     *
      */
     public String getBomEncoding()
     {
@@ -115,10 +101,9 @@ public class XmlReaderException extends 
 
     /**
      * Returns the encoding guess based on the first bytes of the InputStream.
-     * <p>
+     * <p/>
      *
      * @return the encoding guess, null if it couldn't be guessed.
-     *
      */
     public String getXmlGuessEncoding()
     {
@@ -127,10 +112,9 @@ public class XmlReaderException extends 
 
     /**
      * Returns the encoding found in the XML prolog of the InputStream.
-     * <p>
+     * <p/>
      *
      * @return the encoding of the XML prolog, null if none.
-     *
      */
     public String getXmlEncoding()
     {
@@ -139,11 +123,10 @@ public class XmlReaderException extends 
 
     /**
      * Returns the MIME type in the content-type used to attempt determining the encoding.
-     * <p>
+     * <p/>
      *
      * @return the MIME type in the content-type, null if there was not content-type or the encoding detection did not
      *         involve HTTP.
-     *
      */
     public String getContentTypeMime()
     {
@@ -152,11 +135,10 @@ public class XmlReaderException extends 
 
     /**
      * Returns the encoding in the content-type used to attempt determining the encoding.
-     * <p>
+     * <p/>
      *
      * @return the encoding in the content-type, null if there was not content-type, no encoding in it or the encoding
      *         detection did not involve HTTP.
-     *
      */
     public String getContentTypeEncoding()
     {
@@ -166,10 +148,9 @@ public class XmlReaderException extends 
     /**
      * Returns the unconsumed InputStream to allow the application to do an alternate encoding detection on the
      * InputStream.
-     * <p>
+     * <p/>
      *
      * @return the unconsumed InputStream.
-     *
      */
     public InputStream getInputStream()
     {

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlStreamReaderException.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlStreamReaderException.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlStreamReaderException.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlStreamReaderException.java Mon Oct  1 20:06:11 2012
@@ -21,33 +21,28 @@ import java.io.InputStream;
 /**
  * The XmlStreamReaderException is thrown by the XmlStreamReader constructors if the charset encoding can not be determined
  * according to the XML 1.0 specification and RFC 3023.
- * <p>
+ * <p/>
  * The exception returns the unconsumed InputStream to allow the application to do an alternate processing with the
  * stream. Note that the original InputStream given to the XmlStreamReader cannot be used as that one has been already read.
- * <p>
+ * <p/>
  *
  * @author Alejandro Abdelnur
  * @version revision 1.1 taken on 26/06/2007 from Rome (see https://rome.dev.java.net/source/browse/rome/src/java/com/sun/syndication/io/XmlReaderException.java)
  */
-public class XmlStreamReaderException extends XmlReaderException
+public class XmlStreamReaderException
+    extends XmlReaderException
 {
     /**
      * Creates an exception instance if the charset encoding could not be determined.
-     * <p>
+     * <p/>
      * Instances of this exception are thrown by the XmlReader.
-     * <p>
-     *
-     * @param msg
-     *            message describing the reason for the exception.
-     * @param bomEnc
-     *            BOM encoding.
-     * @param xmlGuessEnc
-     *            XML guess encoding.
-     * @param xmlEnc
-     *            XML prolog encoding.
-     * @param is
-     *            the unconsumed InputStream.
+     * <p/>
      *
+     * @param msg         message describing the reason for the exception.
+     * @param bomEnc      BOM encoding.
+     * @param xmlGuessEnc XML guess encoding.
+     * @param xmlEnc      XML prolog encoding.
+     * @param is          the unconsumed InputStream.
      */
     public XmlStreamReaderException( String msg, String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is )
     {
@@ -56,28 +51,20 @@ public class XmlStreamReaderException ex
 
     /**
      * Creates an exception instance if the charset encoding could not be determined.
-     * <p>
+     * <p/>
      * Instances of this exception are thrown by the XmlReader.
-     * <p>
-     *
-     * @param msg
-     *            message describing the reason for the exception.
-     * @param ctMime
-     *            MIME type in the content-type.
-     * @param ctEnc
-     *            encoding in the content-type.
-     * @param bomEnc
-     *            BOM encoding.
-     * @param xmlGuessEnc
-     *            XML guess encoding.
-     * @param xmlEnc
-     *            XML prolog encoding.
-     * @param is
-     *            the unconsumed InputStream.
+     * <p/>
      *
+     * @param msg         message describing the reason for the exception.
+     * @param ctMime      MIME type in the content-type.
+     * @param ctEnc       encoding in the content-type.
+     * @param bomEnc      BOM encoding.
+     * @param xmlGuessEnc XML guess encoding.
+     * @param xmlEnc      XML prolog encoding.
+     * @param is          the unconsumed InputStream.
      */
     public XmlStreamReaderException( String msg, String ctMime, String ctEnc, String bomEnc, String xmlGuessEnc,
-                               String xmlEnc, InputStream is )
+                                     String xmlEnc, InputStream is )
     {
         super( msg, ctMime, ctEnc, bomEnc, xmlGuessEnc, xmlEnc, is );
     }