Author: khmarbaise Date: Sun Oct 4 17:35:19 2015 New Revision: 1706704 URL: http://svn.apache.org/viewvc?rev=1706704&view=rev Log: Cleaned up checkstyle reported issues.
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/StringUtils.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Arg.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineCallable.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineException.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineTimeOutException.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/ShutdownHookUtils.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java Sun Oct 4 17:35:19 2015 @@ -36,13 +36,16 @@ import org.apache.maven.shared.utils.io. public class PropertyUtils { + /** + * The constructor. + */ public PropertyUtils() { // should throw new IllegalAccessError( "Utility class" ); } /** - * @param url + * @param url The URL which should be used to load the properties. * @return The loaded properties. */ public static java.util.Properties loadProperties( @Nonnull java.net.URL url ) @@ -59,7 +62,7 @@ public class PropertyUtils } /** - * @param file + * @param file The file from which the properties will be loaded. * @return The loaded properties. */ public static Properties loadProperties( @Nonnull File file ) Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/StringUtils.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/StringUtils.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/StringUtils.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/StringUtils.java Sun Oct 4 17:35:19 2015 @@ -517,6 +517,9 @@ public class StringUtils } /** + * @param text The text to be split. + * @param separator The separator at which the text will be split. + * @return The resulting array. * @see #split(String, String, int) */ @Nonnull public static String[] split( @Nonnull String text, @Nullable String separator ) @@ -1981,8 +1984,10 @@ public class StringUtils * Else abbreviate it to (substring(str, 0, max-3) + "..."). * If maxWidth is less than 3, throw an IllegalArgumentException. * In no case will it return a string of length greater than maxWidth. - * + * + * @param s The string to be abbreviated. * @param maxWidth maximum length of result string + * @return The abbreviated string. */ @Nonnull public static String abbreviate( @Nonnull String s, int maxWidth ) { @@ -2001,6 +2006,7 @@ public class StringUtils * @param s String to abbreviate. * @param offset left edge of source string * @param maxWidth maximum length of result string + * @return The abbreviated string. */ @Nonnull public static String abbreviate( @Nonnull String s, int offset, int maxWidth ) { @@ -2045,6 +2051,8 @@ public class StringUtils * <p/> * E.g. strdiff("i am a machine", "i am a robot") -> "robot" * + * @param s1 The first string. + * @param s2 The second string. * @return the portion of s2 where it differs from s1; returns the empty string ("") if they are equal */ public static String difference( @Nonnull String s1, @Nonnull String s2 ) @@ -2063,6 +2071,8 @@ public class StringUtils * E.g. strdiff("i am a machine", "i am a robot") -> 7 * </p> * + * @param s1 The first string. + * @param s2 The second string. * @return the index where s2 and s1 begin to differ; -1 if they are equal */ public static int differenceAt( @Nonnull String s1, @Nonnull String s2 ) @@ -2087,8 +2097,8 @@ public class StringUtils * Any text looking like '${key}' will get replaced by the value stored * in the namespace map under the 'key'. * - * @param text - * @param namespace + * @param text The text where replacements will be searched for. + * @param namespace The namespace which contains the replacements. * @return the interpolated text. */ public static String interpolate( String text, @Nonnull Map<?, ?> namespace ) @@ -2125,8 +2135,8 @@ public class StringUtils * </pre> * will become 'ThisIsIt'. * - * @param data - * @param replaceThis + * @param data The data. + * @param replaceThis The things which should be replaced. * @return humped String */ @Nonnull public static String removeAndHump( @Nonnull String data, @Nonnull String replaceThis ) @@ -2203,7 +2213,7 @@ public class StringUtils * <p/> * 'ThisIsIt' will become 'this-is-it'. * - * @param view + * @param view The view. * @return deHumped String */ @Nonnull public static String addAndDeHump( @Nonnull String view ) @@ -2234,8 +2244,8 @@ public class StringUtils * StringUtils.quoteAndEscape("a\"bc", '\'') = 'a\"bc' * </pre> * - * @param source - * @param quoteChar + * @param source The source. + * @param quoteChar The quote character. * @return the String quoted and escaped * @see #quoteAndEscape(String, char, char[], char[], char, boolean) * @see #quoteAndEscape(String, char, char[], char[], char, boolean) @@ -2249,9 +2259,9 @@ public class StringUtils /** * <p>Quote and escape a String with the given character, handling <code>null</code>.</p> * - * @param source - * @param quoteChar - * @param quotingTriggers + * @param source The source. + * @param quoteChar The quote character. + * @param quotingTriggers The quoting trigger. * @return the String quoted and escaped * @see #quoteAndEscape(String, char, char[], char[], char, boolean) * @@ -2262,11 +2272,11 @@ public class StringUtils } /** - * @param source - * @param quoteChar - * @param escapedChars - * @param escapeChar - * @param force + * @param source The source. + * @param quoteChar The quote character. + * @param escapedChars The escaped characters. + * @param escapeChar The escape character. + * @param force true/false. * @return the String quoted and escaped * @see #quoteAndEscape(String, char, char[], char[], char, boolean) * @@ -2278,12 +2288,12 @@ public class StringUtils } /** - * @param source - * @param quoteChar - * @param escapedChars - * @param quotingTriggers - * @param escapeChar - * @param force + * @param source The source. + * @param quoteChar The quote character. + * @param escapedChars The escaped characters. + * @param quotingTriggers The quoting trigger. + * @param escapeChar The escape character. + * @param force true/false. * @return the String quoted and escaped */ public static String quoteAndEscape( @Nullable String source, char quoteChar, @Nonnull final char[] escapedChars, @@ -2332,9 +2342,9 @@ public class StringUtils } /** - * @param source - * @param escapedChars - * @param escapeChar + * @param source The source. + * @param escapedChars escape characters. + * @param escapeChar escape character. * @return the String escaped */ public static String escape( @Nullable String source, @Nonnull final char[] escapedChars, char escapeChar ) Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Arg.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Arg.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Arg.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Arg.java Sun Oct 4 17:35:19 2015 @@ -32,12 +32,12 @@ public interface Arg void setValue( String value ); /** - * @param line + * @param line The line of arguments. */ void setLine( String line ); /** - * @param value + * @param value The file to be set. */ void setFile( File value ); Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineCallable.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineCallable.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineCallable.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineCallable.java Sun Oct 4 17:35:19 2015 @@ -29,8 +29,8 @@ import java.util.concurrent.Callable; public interface CommandLineCallable extends Callable<Integer> { - /* (non-Javadoc) - * @see java.util.concurrent.Callable#call() + /** + * {@inheritDoc} */ Integer call() throws CommandLineException; Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineException.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineException.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineException.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineException.java Sun Oct 4 17:35:19 2015 @@ -32,7 +32,7 @@ public class CommandLineException private static final long serialVersionUID = 1344773066470228441L; /** - * @param message + * @param message The message of the exception. */ public CommandLineException( String message ) { @@ -40,8 +40,8 @@ public class CommandLineException } /** - * @param message - * @param cause + * @param message The message of the exception. + * @param cause The problem which caused the exception. */ public CommandLineException( String message, Throwable cause ) { Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineTimeOutException.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineTimeOutException.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineTimeOutException.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineTimeOutException.java Sun Oct 4 17:35:19 2015 @@ -34,8 +34,8 @@ public class CommandLineTimeOutException private static final long serialVersionUID = 7322428741683224481L; /** - * @param message - * @param cause + * @param message The message of the exception. + * @param cause The cause of the exception. */ public CommandLineTimeOutException( String message, Throwable cause ) { Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java Sun Oct 4 17:35:19 2015 @@ -51,11 +51,15 @@ public abstract class CommandLineUtils private static final String LS = System.getProperty( "line.separator" ); + /** {@inheritDoc} */ public void consumeLine( String line ) { string.append( line ).append( LS ); } + /** + * @return The output. + */ public String getOutput() { return string.toString(); @@ -74,6 +78,7 @@ public abstract class CommandLineUtils this.setContextClassLoader( null ); } + /** {@inheritDoc} */ public void run() { process.destroy(); @@ -81,12 +86,27 @@ public abstract class CommandLineUtils } + /** + * @param cl The command line {@link Commandline} + * @param systemOut {@link StreamConsumer} + * @param systemErr {@link StreamConsumer} + * @return return code. + * @throws CommandLineException in case of a problem. + */ public static int executeCommandLine( @Nonnull Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr ) throws CommandLineException { return executeCommandLine( cl, null, systemOut, systemErr, 0 ); } + /** + * @param cl The command line {@link Commandline} + * @param systemOut {@link StreamConsumer} + * @param systemErr {@link StreamConsumer} + * @param timeoutInSeconds The timeout. + * @return return code. + * @throws CommandLineException in case of a problem. + */ public static int executeCommandLine( @Nonnull Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds ) throws CommandLineException @@ -94,6 +114,14 @@ public abstract class CommandLineUtils return executeCommandLine( cl, null, systemOut, systemErr, timeoutInSeconds ); } + /** + * @param cl The command line {@link Commandline} + * @param systemIn {@link StreamConsumer} + * @param systemOut {@link StreamConsumer} + * @param systemErr {@link StreamConsumer} + * @return return code. + * @throws CommandLineException in case of a problem. + */ public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr ) throws CommandLineException @@ -109,7 +137,6 @@ public abstract class CommandLineUtils * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout. * @return A return value, see {@link Process#exitValue()} * @throws CommandLineException or CommandLineTimeOutException if time out occurs - * @noinspection ThrowableResultOfMethodCallIgnored */ public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds ) @@ -128,7 +155,6 @@ public abstract class CommandLineUtils * exceeded, but before waiting on the stream feeder and pumpers to finish. * @return A return value, see {@link Process#exitValue()} * @throws CommandLineException or CommandLineTimeOutException if time out occurs - * @noinspection ThrowableResultOfMethodCallIgnored */ public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds, @@ -150,7 +176,6 @@ public abstract class CommandLineUtils * @param streamCharset Charset to use for reading streams * @return A return value, see {@link Process#exitValue()} * @throws CommandLineException or CommandLineTimeOutException if time out occurs - * @noinspection ThrowableResultOfMethodCallIgnored */ public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds, @@ -177,7 +202,6 @@ public abstract class CommandLineUtils * must be called on this to be sure the forked process has terminated, no guarantees is made about * any internal state before after the completion of the call statements * @throws CommandLineException or CommandLineTimeOutException if time out occurs - * @noinspection ThrowableResultOfMethodCallIgnored */ public static CommandLineCallable executeCommandLineAsCallable( @Nonnull final Commandline cl, @Nullable final InputStream systemIn, @@ -205,7 +229,6 @@ public abstract class CommandLineUtils * must be called on this to be sure the forked process has terminated, no guarantees is made about * any internal state before after the completion of the call statements * @throws CommandLineException or CommandLineTimeOutException if time out occurs - * @noinspection ThrowableResultOfMethodCallIgnored */ public static CommandLineCallable executeCommandLineAsCallable( @Nonnull final Commandline cl, @Nullable final InputStream systemIn, @@ -384,8 +407,12 @@ public abstract class CommandLineUtils } } - public static String[] translateCommandline( String toProcess ) - throws Exception + /** + * @param toProcess The command line to translate. + * @return The array of translated parts. + * @throws CommandLineException in case of unbalanced quotes. + */ + public static String[] translateCommandline( String toProcess ) throws CommandLineException { if ( ( toProcess == null ) || ( toProcess.length() == 0 ) ) { @@ -465,6 +492,10 @@ public abstract class CommandLineUtils return tokens.toArray( new String[tokens.size()] ); } + /** + * @param line The line + * @return The concatenate lines. + */ public static String toString( String... line ) { // empty path return empty string Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java Sun Oct 4 17:35:19 2015 @@ -79,6 +79,7 @@ public class Commandline /** * Create a new command line object. * Shell is autodetected from operating system + * @param shell The shell instance. */ public Commandline( Shell shell ) { @@ -168,6 +169,7 @@ public class Commandline * * @param insertAtStart if true, the argument is inserted at the * beginning of the list of args, otherwise it is appended. + * @return The arguments. */ public Arg createArg( boolean insertAtStart ) { @@ -185,18 +187,25 @@ public class Commandline /** * Sets the executable to run. + * @param executable The executable. */ public void setExecutable( String executable ) { shell.setExecutable( executable ); } + /** + * @return The executable. + */ public String getExecutable() { return shell.getExecutable(); } + /** + * @param line The arguments. + */ public void addArguments( String... line ) { for ( String aLine : line ) @@ -207,6 +216,8 @@ public class Commandline /** * Add an environment variable + * @param name The name of the environment variable. + * @param value The appropriate value. */ public void addEnvironment( String name, String value ) { @@ -233,6 +244,7 @@ public class Commandline /** * Return the list of environment variables + * @return an array of all environment variables. */ public String[] getEnvironmentVariables() { @@ -250,6 +262,7 @@ public class Commandline /** * Returns the executable and all defined arguments. + * @return an array of all arguments incl. executable. */ public String[] getCommandline() { @@ -288,6 +301,7 @@ public class Commandline /** * Returns all arguments defined by <code>addLine</code>, * <code>addValue</code> or the argument object. + * @return an array of arguments. */ public String[] getArguments() { @@ -299,6 +313,7 @@ public class Commandline * <code>addValue</code> or the argument object. * * @param mask flag to mask any arguments (having his {@code mask} field to {@code true}). + * @return an array of arguments. */ public String[] getArguments( boolean mask ) { @@ -328,12 +343,16 @@ public class Commandline return result.toArray( new String[result.size()] ); } + /** {@inheritDoc} + */ public String toString() { return StringUtils.join( getShellCommandline( true ), " " ); } + /** {@inheritDoc} + */ public Object clone() { throw new RuntimeException( "Do we ever clone a commandline?" ); @@ -343,7 +362,8 @@ public class Commandline } /** - * Sets execution directory. + * Sets working directory. + * @param path The to be set as working directory. */ public void setWorkingDirectory( String path ) { @@ -352,12 +372,16 @@ public class Commandline /** * Sets execution directory. + * @param workingDirectory The working directory. */ public void setWorkingDirectory( File workingDirectory ) { shell.setWorkingDirectory( workingDirectory ); } + /** + * @return The working directory. + */ public File getWorkingDirectory() { return shell.getWorkingDirectory(); @@ -373,6 +397,8 @@ public class Commandline /** * Executes the command. + * @return The process. + * @throws CommandLineException in case of errors. */ public Process execute() throws CommandLineException @@ -427,6 +453,7 @@ public class Commandline /** * Get the shell to be used in this command line. + * @return the shell. */ public Shell getShell() { @@ -489,11 +516,17 @@ public class Commandline this.mask = mask; } + /** + * @return The parts. + */ private String[] getParts() { return parts; } + /** + * @return true/false + */ public boolean isMask() { return mask; Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java Sun Oct 4 17:35:19 2015 @@ -26,6 +26,7 @@ package org.apache.maven.shared.utils.cl public class DefaultConsumer implements StreamConsumer { + /** {@inheritDoc} */ public void consumeLine( String line ) { System.out.println( line ); Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/ShutdownHookUtils.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/ShutdownHookUtils.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/ShutdownHookUtils.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/ShutdownHookUtils.java Sun Oct 4 17:35:19 2015 @@ -32,6 +32,9 @@ import java.security.AccessControlExcept public class ShutdownHookUtils { + /** + * @param hook The thread hook. + */ public static void addShutDownHook( Thread hook ) { try @@ -48,6 +51,9 @@ public class ShutdownHookUtils } } + /** + * @param hook The hook which should be removed. + */ public static void removeShutdownHook( Thread hook ) { try Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java Sun Oct 4 17:35:19 2015 @@ -34,6 +34,7 @@ public interface StreamConsumer { /** * Called when the StreamPumper pumps a line from the Stream. + * @param line The line to be consumed. */ void consumeLine( String line ); } Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java Sun Oct 4 17:35:19 2015 @@ -32,12 +32,10 @@ import javax.annotation.Nullable; import org.apache.maven.shared.utils.io.IOUtil; /** - * Class to pump the error stream during Process's runtime. Copied from the Ant - * built-in task. + * Class to pump the error stream during Process's runtime. Copied from the Ant built-in task. * * @author <a href="mailto:fvan...@maxiq.com">Florin Vancea </a> * @author <a href="mailto:p...@thoughtworks.com">Paul Julius </a> - * */ public class StreamPumper extends AbstractStreamHandler @@ -52,16 +50,30 @@ public class StreamPumper private static final int SIZE = 1024; + /** + * @param in {@link InputStream} + * @param consumer {@link StreamConsumer} + */ public StreamPumper( InputStream in, StreamConsumer consumer ) { this( new InputStreamReader( in ), null, consumer ); } - public StreamPumper( InputStream in, StreamConsumer consumer, @Nullable Charset charset ) + /** + * @param in {@link InputStream} + * @param consumer {@link StreamConsumer} + * @param charset {@link Charset} + */ + public StreamPumper( InputStream in, StreamConsumer consumer, @Nullable Charset charset ) { this( null == charset ? new InputStreamReader( in ) : new InputStreamReader( in, charset ), null, consumer ); } + /** + * @param in {@link Writer} + * @param writer {@link PrintWriter} + * @param consumer {@link StreamConsumer} + */ private StreamPumper( Reader in, PrintWriter writer, StreamConsumer consumer ) { this.in = new BufferedReader( in, SIZE ); @@ -69,6 +81,7 @@ public class StreamPumper this.consumer = consumer; } + /** run it. */ public void run() { try @@ -113,6 +126,9 @@ public class StreamPumper } } + /** + * flush. + */ public void flush() { if ( out != null ) @@ -121,11 +137,17 @@ public class StreamPumper } } + /** + * Close it. + */ public void close() { IOUtil.close( out ); } + /** + * @return {@link Exception} + */ public Exception getException() { return exception; Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java Sun Oct 4 17:35:19 2015 @@ -281,11 +281,11 @@ public class DirectoryScanner /** * Sets whether or not the file system should be regarded as case sensitive. * - * @param isCaseSensitive whether or not the file system should be regarded as a case sensitive one + * @param isCaseSensitiveParameter whether or not the file system should be regarded as a case sensitive one */ - public void setCaseSensitive( final boolean isCaseSensitive ) + public void setCaseSensitive( final boolean isCaseSensitiveParameter ) { - this.isCaseSensitive = isCaseSensitive; + this.isCaseSensitive = isCaseSensitiveParameter; } /** @@ -360,6 +360,9 @@ public class DirectoryScanner } } + /** + * @param scanConductor {@link #scanConductor} + */ public void setScanConductor( final ScanConductor scanConductor ) { this.scanConductor = scanConductor; @@ -443,6 +446,7 @@ public class DirectoryScanner * {@link DirectoryScanResult#getFilesAdded()} and {@link DirectoryScanResult#getFilesRemoved()} * * @param oldFiles the list of previously captured files names. + * @return the result of the directory scan. */ public DirectoryScanResult diffIncludedFiles( String... oldFiles ) { @@ -455,6 +459,11 @@ public class DirectoryScanner return diffFiles( oldFiles, filesIncluded.toArray( new String[filesIncluded.size()] ) ); } + /** + * @param oldFiles array of old files. + * @param newFiles array of new files. + * @return calculated differerence. + */ public static DirectoryScanResult diffFiles( @Nullable String[] oldFiles, @Nullable String[] newFiles ) { Set<String> oldFileSet = arrayAsHashSet( oldFiles ); @@ -583,39 +592,7 @@ public class DirectoryScanner if ( !followSymlinks ) { - final List<String> noLinks = new ArrayList<String>(); - for ( final String newfile : newfiles ) - { - try - { - if ( isSymbolicLink( dir, newfile ) ) - { - final String name = vpath + newfile; - final File file = new File( dir, newfile ); - if ( file.isDirectory() ) - { - dirsExcluded.add( name ); - } - else - { - filesExcluded.add( name ); - } - } - else - { - noLinks.add( newfile ); - } - } - catch ( final IOException ioe ) - { - final String msg = - "IOException caught while checking " + "for links, couldn't get cannonical path!"; - // will be caught and redirected to Ant's logging system - System.err.println( msg ); - noLinks.add( newfile ); - } - } - newfiles = noLinks.toArray( new String[noLinks.size()] ); + newfiles = doNotFollowSymbolicLinks( dir, vpath, newfiles ); } for ( final String newfile : newfiles ) @@ -738,6 +715,44 @@ public class DirectoryScanner } } + private String[] doNotFollowSymbolicLinks( final File dir, final String vpath, String[] newfiles ) + { + final List<String> noLinks = new ArrayList<String>(); + for ( final String newfile : newfiles ) + { + try + { + if ( isSymbolicLink( dir, newfile ) ) + { + final String name = vpath + newfile; + final File file = new File( dir, newfile ); + if ( file.isDirectory() ) + { + dirsExcluded.add( name ); + } + else + { + filesExcluded.add( name ); + } + } + else + { + noLinks.add( newfile ); + } + } + catch ( final IOException ioe ) + { + final String msg = + "IOException caught while checking " + "for links, couldn't get cannonical path!"; + // will be caught and redirected to Ant's logging system + System.err.println( msg ); + noLinks.add( newfile ); + } + } + newfiles = noLinks.toArray( new String[noLinks.size()] ); + return newfiles; + } + /** * Tests whether or not a name matches against at least one include pattern. * Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java Sun Oct 4 17:35:19 2015 @@ -87,6 +87,9 @@ import java.util.Random; */ public class FileUtils { + /** + * protected constructor. + */ protected FileUtils() { // This is a utility class. Normally dont instantiate @@ -304,7 +307,7 @@ public class FileUtils * @param file the file path * @return the file content lines as String[] using the systems default encoding. * An empty List if the file didn't exist. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String[] fileReadArray( @Nonnull File file ) throws IOException @@ -657,7 +660,7 @@ public class FileUtils * @return The equivalent <code>File</code> object, or <code>null</code> if the URL's protocol * is not <code>file</code> */ - @Nullable public static File toFile( final @Nullable URL url ) + @Nullable public static File toFile( @Nullable final URL url ) { if ( url == null || !url.getProtocol().equalsIgnoreCase( "file" ) ) { @@ -1179,6 +1182,10 @@ public class FileUtils } } + /** + * @param file The file. + * @return true / false + */ public static boolean deleteLegacyStyle( @Nonnull File file ) { if ( Java7Support.isAtLeastJava7() ) @@ -1428,7 +1435,7 @@ public class FileUtils * @param includes the includes pattern, comma separated * @param excludes the excludes pattern, comma separated * @return a list of File objects - * @throws IOException + * @throws IOException in case of failure. * @see #getFileNames(File, String, String, boolean) */ @Nonnull @@ -1446,7 +1453,7 @@ public class FileUtils * @param excludes the excludes pattern, comma separated * @param includeBasedir true to include the base dir in each file * @return a list of File objects - * @throws IOException + * @throws IOException in case of failure. * @see #getFileNames(File, String, String, boolean) */ @Nonnull @@ -1475,7 +1482,7 @@ public class FileUtils * @param excludes the excludes pattern, comma separated * @param includeBasedir true to include the base dir in each String of file * @return a list of files as String - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static List<String> getFileNames( @Nonnull File directory, @Nullable String includes, @Nullable String excludes, boolean includeBasedir ) @@ -1512,7 +1519,7 @@ public class FileUtils * @param excludes the excludes pattern, comma separated * @param includeBasedir true to include the base dir in each String of file * @return a list of directories as String - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static List<String> getDirectoryNames( @Nonnull File directory, @Nullable String includes, @Nullable String excludes, boolean includeBasedir ) @@ -1530,7 +1537,7 @@ public class FileUtils * @param includeBasedir true to include the base dir in each String of file * @param isCaseSensitive true if case sensitive * @return a list of directories as String - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static List<String> getDirectoryNames( @Nonnull File directory, @Nullable String includes, @Nullable String excludes, boolean includeBasedir, @@ -1860,10 +1867,15 @@ public class FileUtils } /** - * + * Wrapper class for Filter. + * */ public abstract static class FilterWrapper { + /** + * @param fileReader {@link Reader} + * @return The Reader instance. + */ public abstract Reader getReader( Reader fileReader ); } @@ -2010,6 +2022,8 @@ public class FileUtils * </p> * * @param file the file to check + * @throws IOException in case of failure. + * @return true if symbolic link false otherwise. * */ public static boolean isSymbolicLink( @Nonnull final File file ) @@ -2029,6 +2043,7 @@ public class FileUtils * @return true if and only if we reliably can say this is a symlink. This will * always return false for java versions prior to 1.7. * + * @throws IOException in case of failure. */ public static boolean isSymbolicLinkForSure( @Nonnull final File file ) throws IOException Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java?rev=1706704&r1=1706703&r2=1706704&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java Sun Oct 4 17:35:19 2015 @@ -161,7 +161,7 @@ public final class IOUtil /** * Copy chars from a <code>Reader</code> to a <code>Writer</code>. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final Reader input, @Nonnull final Writer output ) throws IOException @@ -173,7 +173,7 @@ public final class IOUtil * Copy chars from a <code>Reader</code> to a <code>Writer</code>. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final Reader input, @Nonnull final Writer output, final int bufferSize ) throws IOException @@ -199,7 +199,7 @@ public final class IOUtil * Copy and convert bytes from an <code>InputStream</code> to chars on a * <code>Writer</code>. * The platform's default encoding is used for the byte-to-char conversion. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final InputStream input, @Nonnull final Writer output ) throws IOException @@ -213,7 +213,7 @@ public final class IOUtil * The platform's default encoding is used for the byte-to-char conversion. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final InputStream input, @Nonnull final Writer output, final int bufferSize ) throws IOException @@ -229,7 +229,7 @@ public final class IOUtil * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final InputStream input, @Nonnull final Writer output, @Nonnull final String encoding ) @@ -247,7 +247,7 @@ public final class IOUtil * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final InputStream input, @Nonnull final Writer output, @Nonnull final String encoding, final int bufferSize ) @@ -263,7 +263,7 @@ public final class IOUtil /** * Get the contents of an <code>InputStream</code> as a String. * The platform's default encoding is used for the byte-to-char conversion. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final InputStream input ) throws IOException @@ -276,7 +276,7 @@ public final class IOUtil * The platform's default encoding is used for the byte-to-char conversion. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final InputStream input, final int bufferSize ) throws IOException @@ -292,7 +292,7 @@ public final class IOUtil * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final InputStream input, @Nonnull final String encoding ) throws IOException @@ -307,7 +307,7 @@ public final class IOUtil * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final InputStream input, @Nonnull final String encoding, final int bufferSize ) @@ -323,7 +323,7 @@ public final class IOUtil /** * Get the contents of an <code>InputStream</code> as a <code>byte[]</code>. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static byte[] toByteArray( @Nonnull final InputStream input ) throws IOException @@ -335,7 +335,7 @@ public final class IOUtil * Get the contents of an <code>InputStream</code> as a <code>byte[]</code>. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static byte[] toByteArray( @Nonnull final InputStream input, final int bufferSize ) throws IOException @@ -356,7 +356,7 @@ public final class IOUtil /** * Serialize chars from a <code>Reader</code> to bytes on an <code>OutputStream</code>, and * flush the <code>OutputStream</code>. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final Reader input, @Nonnull final OutputStream output ) throws IOException @@ -369,7 +369,7 @@ public final class IOUtil * flush the <code>OutputStream</code>. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final Reader input, @Nonnull final OutputStream output, final int bufferSize ) throws IOException @@ -386,7 +386,7 @@ public final class IOUtil /** * Get the contents of a <code>Reader</code> as a String. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final Reader input ) throws IOException @@ -398,7 +398,7 @@ public final class IOUtil * Get the contents of a <code>Reader</code> as a String. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final Reader input, final int bufferSize ) throws IOException @@ -413,7 +413,7 @@ public final class IOUtil /** * Get the contents of a <code>Reader</code> as a <code>byte[]</code>. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static byte[] toByteArray( @Nonnull final Reader input ) throws IOException @@ -425,7 +425,7 @@ public final class IOUtil * Get the contents of a <code>Reader</code> as a <code>byte[]</code>. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static byte[] toByteArray( @Nonnull final Reader input, final int bufferSize ) throws IOException @@ -446,7 +446,7 @@ public final class IOUtil /** * Serialize chars from a <code>String</code> to bytes on an <code>OutputStream</code>, and * flush the <code>OutputStream</code>. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final String input, @Nonnull final OutputStream output ) throws IOException @@ -459,7 +459,7 @@ public final class IOUtil * flush the <code>OutputStream</code>. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final String input, @Nonnull final OutputStream output, final int bufferSize ) throws IOException @@ -477,9 +477,9 @@ public final class IOUtil /** * Copy chars from a <code>String</code> to a <code>Writer</code>. - * @param input - * @param output - * @throws IOException + * @param input Input string. + * @param output resulting output {@link Writer} + * @throws IOException in case of failure. */ public static void copy( @Nonnull final String input, @Nonnull final Writer output ) throws IOException @@ -492,7 +492,7 @@ public final class IOUtil /** * Get the contents of a <code>String</code> as a <code>byte[]</code>. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static byte[] toByteArray( @Nonnull final String input ) throws IOException @@ -504,7 +504,7 @@ public final class IOUtil * Get the contents of a <code>String</code> as a <code>byte[]</code>. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static byte[] toByteArray( @Nonnull final String input, final int bufferSize ) throws IOException @@ -526,7 +526,7 @@ public final class IOUtil * Copy and convert bytes from a <code>byte[]</code> to chars on a * <code>Writer</code>. * The platform's default encoding is used for the byte-to-char conversion. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final byte[] input, @Nonnull final Writer output ) throws IOException @@ -540,7 +540,7 @@ public final class IOUtil * The platform's default encoding is used for the byte-to-char conversion. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final byte[] input, @Nonnull final Writer output, final int bufferSize ) throws IOException @@ -556,7 +556,7 @@ public final class IOUtil * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final byte[] input, @Nonnull final Writer output, final String encoding ) throws IOException @@ -573,7 +573,7 @@ public final class IOUtil * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final byte[] input, @Nonnull final Writer output, @Nonnull final String encoding, final int bufferSize ) @@ -589,7 +589,7 @@ public final class IOUtil /** * Get the contents of a <code>byte[]</code> as a String. * The platform's default encoding is used for the byte-to-char conversion. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final byte[] input ) throws IOException @@ -602,7 +602,7 @@ public final class IOUtil * The platform's default encoding is used for the byte-to-char conversion. * * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final byte[] input, final int bufferSize ) throws IOException @@ -618,7 +618,7 @@ public final class IOUtil * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final byte[] input, @Nonnull final String encoding ) throws IOException @@ -633,7 +633,7 @@ public final class IOUtil * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. * @param bufferSize Size of internal buffer to use. - * @throws IOException + * @throws IOException in case of failure. */ @Nonnull public static String toString( @Nonnull final byte[] input, @Nonnull final String encoding, final int bufferSize ) @@ -649,7 +649,7 @@ public final class IOUtil /** * Copy bytes from a <code>byte[]</code> to an <code>OutputStream</code>. - * @throws IOException + * @throws IOException in case of failure. */ public static void copy( @Nonnull final byte[] input, @Nonnull final OutputStream output ) throws IOException @@ -663,7 +663,7 @@ public final class IOUtil * @param input1 the first stream * @param input2 the second stream * @return true if the content of the streams are equal or they both don't exist, false otherwise - * @throws IOException + * @throws IOException in case of failure. */ public static boolean contentEquals( @Nonnull final InputStream input1, @Nonnull final InputStream input2 ) throws IOException