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 [1/5] - in
/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils:
./ cli/ cli/shell/ introspection/ io/ reflection/ xml/
Author: krosenvold
Date: Mon Oct 1 20:06:11 2012
New Revision: 1392562
URL: http://svn.apache.org/viewvc?rev=1392562&view=rev
Log:
o Reformatted to code style
Modified:
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ArrayUtils.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/CollectionUtils.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ExceptionUtils.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Expand.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Os.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PathTool.java
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/ReaderFactory.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/CommandLineCallable.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/StreamConsumer.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.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/cli/shell/BourneShell.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CmdShell.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CommandShell.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/Shell.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/ClassMap.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/MethodMap.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractor.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanResult.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/DirectoryWalkListener.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/DirectoryWalker.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
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/MatchPatterns.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/ScanConductor.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/WalkCollector.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/package-info.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/reflection/ReflectorException.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReader.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlReaderException.java
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlStreamReaderException.java
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ArrayUtils.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ArrayUtils.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ArrayUtils.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ArrayUtils.java Mon Oct 1 20:06:11 2012
@@ -36,74 +36,92 @@ public class ArrayUtils
* An empty immutable <code>Object</code> array.
*/
public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+
/**
* An empty immutable <code>Class</code> array.
*/
public static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+
/**
* An empty immutable <code>String</code> array.
*/
public static final String[] EMPTY_STRING_ARRAY = new String[0];
+
/**
* An empty immutable <code>long</code> array.
*/
public static final long[] EMPTY_LONG_ARRAY = new long[0];
+
/**
* An empty immutable <code>Long</code> array.
*/
public static final Long[] EMPTY_LONG_OBJECT_ARRAY = new Long[0];
+
/**
* An empty immutable <code>int</code> array.
*/
public static final int[] EMPTY_INT_ARRAY = new int[0];
+
/**
* An empty immutable <code>Integer</code> array.
*/
public static final Integer[] EMPTY_INTEGER_OBJECT_ARRAY = new Integer[0];
+
/**
* An empty immutable <code>short</code> array.
*/
public static final short[] EMPTY_SHORT_ARRAY = new short[0];
+
/**
* An empty immutable <code>Short</code> array.
*/
public static final Short[] EMPTY_SHORT_OBJECT_ARRAY = new Short[0];
+
/**
* An empty immutable <code>byte</code> array.
*/
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
+
/**
* An empty immutable <code>Byte</code> array.
*/
public static final Byte[] EMPTY_BYTE_OBJECT_ARRAY = new Byte[0];
+
/**
* An empty immutable <code>double</code> array.
*/
public static final double[] EMPTY_DOUBLE_ARRAY = new double[0];
+
/**
* An empty immutable <code>Double</code> array.
*/
public static final Double[] EMPTY_DOUBLE_OBJECT_ARRAY = new Double[0];
+
/**
* An empty immutable <code>float</code> array.
*/
public static final float[] EMPTY_FLOAT_ARRAY = new float[0];
+
/**
* An empty immutable <code>Float</code> array.
*/
public static final Float[] EMPTY_FLOAT_OBJECT_ARRAY = new Float[0];
+
/**
* An empty immutable <code>boolean</code> array.
*/
public static final boolean[] EMPTY_BOOLEAN_ARRAY = new boolean[0];
+
/**
* An empty immutable <code>Boolean</code> array.
*/
public static final Boolean[] EMPTY_BOOLEAN_OBJECT_ARRAY = new Boolean[0];
+
/**
* An empty immutable <code>char</code> array.
*/
public static final char[] EMPTY_CHAR_ARRAY = new char[0];
+
/**
* An empty immutable <code>Character</code> array.
*/
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/CollectionUtils.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/CollectionUtils.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/CollectionUtils.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/CollectionUtils.java Mon Oct 1 20:06:11 2012
@@ -46,18 +46,18 @@ public class CollectionUtils
* Take a dominant and recessive Map and merge the key:value
* pairs where the recessive Map may add key:value pairs to the dominant
* Map but may not override any existing key:value pairs.
- *
+ * <p/>
* If we have two Maps, a dominant and recessive, and
* their respective keys are as follows:
- *
- * dominantMapKeys = { a, b, c, d, e, f }
+ * <p/>
+ * dominantMapKeys = { a, b, c, d, e, f }
* recessiveMapKeys = { a, b, c, x, y, z }
- *
+ * <p/>
* Then the result should be the following:
- *
+ * <p/>
* resultantKeys = { a, b, c, d, e, f, x, y, z }
*
- * @param dominantMap Dominant Map.
+ * @param dominantMap Dominant Map.
* @param recessiveMap Recessive Map.
* @return The result map with combined dominant and recessive values.
*/
@@ -88,9 +88,9 @@ public class CollectionUtils
// Create the set of keys that will be contributed by the
// recessive Map by subtracting the intersection of keys
// from the recessive Map's keys.
- Collection contributingRecessiveKeys =
- CollectionUtils.subtract( recessiveMapKeys,
- CollectionUtils.intersection( dominantMapKeys, recessiveMapKeys ) );
+ Collection contributingRecessiveKeys = CollectionUtils.subtract( recessiveMapKeys,
+ CollectionUtils.intersection( dominantMapKeys,
+ recessiveMapKeys ) );
result.putAll( dominantMap );
@@ -141,7 +141,7 @@ public class CollectionUtils
/**
* Returns a {@link Collection} containing the intersection
* of the given {@link Collection}s.
- * <p>
+ * <p/>
* The cardinality of each element in the returned {@link Collection}
* will be equal to the minimum of the cardinality of that element
* in the two given {@link Collection}s.
@@ -155,11 +155,9 @@ public class CollectionUtils
Map mapb = getCardinalityMap( b );
Set elts = new HashSet( a );
elts.addAll( b );
- Iterator it = elts.iterator();
- while ( it.hasNext() )
+ for ( Object obj : elts )
{
- Object obj = it.next();
- for ( int i = 0,m = Math.min( getFreq( obj, mapa ), getFreq( obj, mapb ) ); i < m; i++ )
+ for ( int i = 0, m = Math.min( getFreq( obj, mapa ), getFreq( obj, mapb ) ); i < m; i++ )
{
list.add( obj );
}
@@ -240,7 +238,7 @@ public class CollectionUtils
*/
public static <T> Set<T> arrayAsHashSet( T[] array )
{
- if ( array == null || array.length == 0)
+ if ( array == null || array.length == 0 )
{
return Collections.EMPTY_SET;
}
@@ -263,7 +261,7 @@ public class CollectionUtils
*/
public static <T> Set<T> arrayAsTreeSet( T[] array )
{
- if ( array == null || array.length == 0)
+ if ( array == null || array.length == 0 )
{
return Collections.EMPTY_SET;
}
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ExceptionUtils.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ExceptionUtils.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ExceptionUtils.java Mon Oct 1 20:06:11 2012
@@ -49,6 +49,7 @@ public class ExceptionUtils
private static final int MAX_ROOT_CAUSE_DEPTH = 20;
private static CopyOnWriteArrayList<String> specialCauseMethodNames = new CopyOnWriteArrayList<String>();
+
static
{
specialCauseMethodNames.add( "getException" );
@@ -71,25 +72,24 @@ public class ExceptionUtils
@Deprecated
public static void addCauseMethodName( String methodName )
{
- specialCauseMethodNames.add(methodName);
+ specialCauseMethodNames.add( methodName );
}
/**
* The {@link Throwable#getCause()} of the given Throwable.
*
* @param throwable
- *
* @return the cause of the given Throwable, <code>null</code> if no cause exists.
*/
public static Throwable getCause( Throwable throwable )
{
Throwable retVal = throwable.getCause();
- if ( retVal == null)
+ if ( retVal == null )
{
- retVal = getCause( throwable
- , specialCauseMethodNames.toArray( new String[ specialCauseMethodNames.size() ] ) );
+ retVal =
+ getCause( throwable, specialCauseMethodNames.toArray( new String[specialCauseMethodNames.size()] ) );
}
return retVal;
@@ -109,12 +109,12 @@ public class ExceptionUtils
// first try a few standard Exception types we already know
if ( retVal == null && throwable instanceof SQLException )
{
- retVal = ((SQLException) throwable).getNextException();
+ retVal = ( (SQLException) throwable ).getNextException();
}
- if ( retVal == null && throwable instanceof InvocationTargetException)
+ if ( retVal == null && throwable instanceof InvocationTargetException )
{
- retVal = ((InvocationTargetException) throwable).getTargetException();
+ retVal = ( (InvocationTargetException) throwable ).getTargetException();
}
if ( retVal == null )
@@ -151,11 +151,11 @@ public class ExceptionUtils
{
method = throwable.getClass().getMethod( methodName, null );
}
- catch (NoSuchMethodException e)
+ catch ( NoSuchMethodException e )
{
return null;
}
- catch (SecurityException e)
+ catch ( SecurityException e )
{
return null;
}
@@ -169,11 +169,11 @@ public class ExceptionUtils
{
return (Throwable) method.invoke( throwable );
}
- catch (IllegalAccessException e)
+ catch ( IllegalAccessException e )
{
return null;
}
- catch (InvocationTargetException e)
+ catch ( InvocationTargetException e )
{
return null;
}
@@ -186,7 +186,6 @@ public class ExceptionUtils
* the recursively deepest Throwable in the chain.
*
* @param throwable
- *
* @return the original cause of the Throwable
*/
public static Throwable getRootCause( Throwable throwable )
@@ -231,6 +230,7 @@ public class ExceptionUtils
/**
* Determine the number of causale Throwables. That is the amount of
* all Throwables in the exception chain.
+ *
* @param throwable
* @return the amount of Throwables in the exception chain.
*/
@@ -257,7 +257,6 @@ public class ExceptionUtils
{
ArrayList<Throwable> throwables = new ArrayList<Throwable>();
-
Throwable rootCause = throwable;
int depth = 0;
@@ -282,17 +281,17 @@ public class ExceptionUtils
depth++;
}
- return throwables.toArray( new Throwable[ throwables.size() ] );
+ return throwables.toArray( new Throwable[throwables.size()] );
}
/**
* Determines all the nested Throwables and calculate the index of the
* Throwable with the given type
+ *
* @param throwable
* @param type
* @return the index of the type in the Throwable chain, or <code>-1</code> if it isn't contained.
- *
* @see #indexOfThrowable(Throwable, Class, int)
*/
public static int indexOfThrowable( Throwable throwable, Class<? extends Throwable> type )
@@ -303,11 +302,11 @@ public class ExceptionUtils
/**
* Determines all the nested Throwables and calculate the index of the
* Throwable with the given type starting with the given fromIndex
+ *
* @param throwable
* @param type
* @param fromIndex the index to start with
* @return the index of the type in the Throwable chain, or <code>-1</code> if it isn't contained.
- *
* @see #indexOfThrowable(Throwable, Class)
*/
public static int indexOfThrowable( Throwable throwable, Class<? extends Throwable> type, int fromIndex )
@@ -323,7 +322,7 @@ public class ExceptionUtils
throw new IndexOutOfBoundsException( "fromIndex must be > 0 but was: " + fromIndex );
}
- if ( type != null)
+ if ( type != null )
{
Throwable[] throwables = getThrowables( throwable );
@@ -334,7 +333,7 @@ public class ExceptionUtils
for ( int i = fromIndex; i < throwables.length; i++ )
{
- Throwable t = throwables[ i ];
+ Throwable t = throwables[i];
if ( t.getClass().equals( type ) )
{
@@ -348,6 +347,7 @@ public class ExceptionUtils
/**
* Print the stacktrace of root cause of the given Throwable to System.err
+ *
* @param throwable
* @see #getCause(Throwable)
*/
@@ -369,6 +369,7 @@ public class ExceptionUtils
/**
* Print the stacktrace of root cause of the given Throwable to the PrintStream
+ *
* @param throwable
* @see #getCause(Throwable)
*/
@@ -379,11 +380,12 @@ public class ExceptionUtils
{
rootCause = throwable;
}
- rootCause.printStackTrace(stream);
+ rootCause.printStackTrace( stream );
}
/**
* Print the stacktrace of root cause of the given Throwable to the PrintWriter
+ *
* @param throwable
* @see #getCause(Throwable)
*/
@@ -400,6 +402,7 @@ public class ExceptionUtils
/**
* The stacktrace frames for the root cause of the given Throwable
+ *
* @param throwable
* @return String with the Stacktrace of the Throwable
* @see #getCause(Throwable)
@@ -417,6 +420,7 @@ public class ExceptionUtils
/**
* The stacktrace for the given Throwable
+ *
* @param throwable
* @return String with the Stacktrace of the Throwable
*/
@@ -432,6 +436,7 @@ public class ExceptionUtils
/**
* The stacktrace for the given Throwable
+ *
* @param throwable
* @return String with the Stacktrace of the Throwable
*/
@@ -439,7 +444,7 @@ public class ExceptionUtils
{
// nowadays this is the same...
- return getStackTrace(throwable);
+ return getStackTrace( throwable );
}
/**
@@ -461,6 +466,7 @@ public class ExceptionUtils
/**
* Get all the separate single lines of the stacktrace for the Throwable
+ *
* @param throwable
* @return the lines of the stack trace for the throwable
*/
@@ -468,9 +474,9 @@ public class ExceptionUtils
{
StackTraceElement[] stackTraceElements = throwable.getStackTrace();
- String[] retVal = new String[ stackTraceElements.length + 1 ];
+ String[] retVal = new String[stackTraceElements.length + 1];
- retVal[ 0 ] = throwable.getClass().getName() + ": " + throwable.getMessage();
+ retVal[0] = throwable.getClass().getName() + ": " + throwable.getMessage();
int i = 1;
@@ -481,9 +487,9 @@ public class ExceptionUtils
sb.append( "." );
sb.append( stackTraceElement.getMethodName() );
sb.append( "(" ).append( stackTraceElement.getFileName() ).append( "):" );
- sb.append(stackTraceElement.getLineNumber());
+ sb.append( stackTraceElement.getLineNumber() );
- retVal[ i++ ] = sb.toString();
+ retVal[i++] = sb.toString();
}
return retVal;
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Expand.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Expand.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Expand.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Expand.java Mon Oct 1 20:06:11 2012
@@ -19,8 +19,6 @@ package org.apache.maven.shared.utils;
* under the License.
*/
-import org.apache.maven.shared.utils.io.FileUtils;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -29,6 +27,7 @@ import java.io.InputStream;
import java.util.Date;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.apache.maven.shared.utils.io.FileUtils;
/**
* Expand will unpack the given zip archive.
@@ -51,6 +50,7 @@ public class Expand
* if the unpackaging should get performed if the destination already exists.
*/
private boolean overwrite = false;
+
private static final int BUFFER_SIZE = 2 ^ 16;
@@ -80,6 +80,7 @@ public class Expand
* If the destination directory should get overwritten if the content
* already exists. If <code>false</code> we will only overwrite if the local
* file or directory is older than the one in the archive.
+ *
* @param overwrite
*/
public void setOverwrite( boolean overwrite )
@@ -94,14 +95,14 @@ public class Expand
* @throws Exception
*/
public void execute()
- throws Exception
+ throws Exception
{
expandFile( source, dest );
}
/**
* <p>It is intended to be overwritten when implementing an own unarchiver</p>
- *
+ * <p/>
* <p><b>Note:</b> we kept this protected method for the sake of backward compatibility!</p>
*
* @param srcFile
@@ -109,9 +110,9 @@ public class Expand
* @throws Exception
*/
protected void expandFile( File srcFile, File dest )
- throws Exception
+ throws Exception
{
- if (source == null)
+ if ( source == null )
{
throw new NullPointerException( "Source Archive must not be null!" );
}
@@ -129,10 +130,10 @@ public class Expand
ZipEntry zipEntry;
- while( (zipEntry = zipInputStream.getNextEntry()) != null )
+ while ( ( zipEntry = zipInputStream.getNextEntry() ) != null )
{
String zipEntryName = zipEntry.getName();
- Date zipEntryDate = new Date( zipEntry.getTime() );
+ Date zipEntryDate = new Date( zipEntry.getTime() );
extractFile( source, destDir, zipInputStream, zipEntryName, zipEntryDate, zipEntry.isDirectory() );
}
@@ -143,7 +144,7 @@ public class Expand
{
fileInputStream.close();
}
- catch( IOException ioe )
+ catch ( IOException ioe )
{
// no worries, all is ok ...
}
@@ -152,24 +153,20 @@ public class Expand
/**
* Extract a single ZipEntry.
- *
+ * <p/>
* <p><b>Note:</b> we kept this protected method for the sake of backward compatibility!</p>
*
- * @param archive the archive to unpack
- * @param destDir the destination dirctory
+ * @param archive the archive to unpack
+ * @param destDir the destination dirctory
* @param compressedInputStream
* @param entryName
* @param entryDate
* @param isDirectory
* @throws Exception
*/
- protected void extractFile( File archive
- , File destDir
- , InputStream compressedInputStream
- , String entryName
- , Date entryDate
- , boolean isDirectory )
- throws Exception
+ protected void extractFile( File archive, File destDir, InputStream compressedInputStream, String entryName,
+ Date entryDate, boolean isDirectory )
+ throws Exception
{
File targetFile = new File( destDir, entryName );
@@ -181,8 +178,8 @@ public class Expand
}
if ( !targetFile.exists() ||
- overwrite ||
- targetFile.lastModified() <= entryDate.getTime() )
+ overwrite ||
+ targetFile.lastModified() <= entryDate.getTime() )
{
if ( isDirectory )
{
@@ -190,12 +187,12 @@ public class Expand
}
else
{
- byte[] buffer = new byte[ BUFFER_SIZE ];
+ byte[] buffer = new byte[BUFFER_SIZE];
FileOutputStream fileOutputStream = new FileOutputStream( targetFile );
try
{
int len;
- while( (len = compressedInputStream.read( buffer ) ) > 0)
+ while ( ( len = compressedInputStream.read( buffer ) ) > 0 )
{
fileOutputStream.write( buffer, 0, len );
}
@@ -208,7 +205,7 @@ public class Expand
{
fileOutputStream.close();
}
- catch( IOException ioe )
+ catch ( IOException ioe )
{
// no worries, all is ok ...
}
@@ -224,7 +221,7 @@ public class Expand
* @throws IOException
*/
private void deleteFileOrDir( File targetFile )
- throws IOException
+ throws IOException
{
if ( targetFile.isDirectory() )
{
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Os.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Os.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Os.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/Os.java Mon Oct 1 20:06:11 2012
@@ -28,12 +28,12 @@ import java.util.Set;
/**
* <p>Condition that tests the OS type.</p>
- *
+ * <p/>
* <p>This class got copied over from Apache ANT.
* Even the version from plexus-utils was
* only an ANT fork!<br/>
* The last time it got copied was on 2011-08-12</p>
- *
+ * <p/>
* <p>When merging changes please take care of the special
* OS_FAMILY handling in this version of Os.java!</p>
*
@@ -41,21 +41,20 @@ import java.util.Set;
* @author Magesh Umasankar
* @author Brian Fox
* @author Mark Struberg
- * @since 1.0
* @version $Revision$
+ * @since 1.0
*/
public class Os
{
- public static final String OS_NAME =
- System.getProperty( "os.name" ).toLowerCase( Locale.ENGLISH );
- public static final String OS_ARCH =
- System.getProperty( "os.arch" ).toLowerCase( Locale.ENGLISH );
- public static final String OS_VERSION =
- System.getProperty( "os.version" ).toLowerCase( Locale.ENGLISH );
- public static final String PATH_SEP =
- System.getProperty( "path.separator" );
- public static final String OS_FAMILY =
- getOsFamily();
+ public static final String OS_NAME = System.getProperty( "os.name" ).toLowerCase( Locale.ENGLISH );
+
+ public static final String OS_ARCH = System.getProperty( "os.arch" ).toLowerCase( Locale.ENGLISH );
+
+ public static final String OS_VERSION = System.getProperty( "os.version" ).toLowerCase( Locale.ENGLISH );
+
+ public static final String PATH_SEP = System.getProperty( "path.separator" );
+
+ public static final String OS_FAMILY = getOsFamily();
// store the valid families
private static final Set validFamilies = getValidFamilies();
@@ -65,62 +64,77 @@ public class Os
* OS family to look for
*/
private String family;
+
/**
* Name of OS
*/
private String name;
+
/**
* version of OS
*/
private String version;
+
/**
* OS architecture
*/
private String arch;
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_WINDOWS = "windows";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_WIN9X = "win9x";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_NT = "winnt";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_OS2 = "os/2";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_NETWARE = "netware";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_DOS = "dos";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_MAC = "mac";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_TANDEM = "tandem";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_UNIX = "unix";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_OPENVMS = "openvms";
+
/**
* OS family that can be tested for. {@value}
*/
public static final String FAMILY_ZOS = "z/os";
+
/**
* OS family that can be tested for. {@value}
*/
@@ -241,7 +255,8 @@ public class Os
* @throws Exception if there is an error.
* @see Os#setFamily(String)
*/
- public boolean eval() throws Exception
+ public boolean eval()
+ throws Exception
{
return isOs( family, name, arch, version );
}
@@ -309,13 +324,11 @@ public class Os
* @return true if the OS matches
* @since 1.7
*/
- public static boolean isOs( String family, String name, String arch,
- String version )
+ public static boolean isOs( String family, String name, String arch, String version )
{
boolean retValue = false;
- if ( family != null || name != null || arch != null
- || version != null )
+ if ( family != null || name != null || arch != null || version != null )
{
boolean isFamily = true;
@@ -334,12 +347,11 @@ public class Os
if ( isWindows )
{
//there are only four 9x platforms that we look for
- is9x = (OS_NAME.indexOf( "95" ) >= 0
- || OS_NAME.indexOf( "98" ) >= 0
- || OS_NAME.indexOf( "me" ) >= 0
+ is9x =
+ ( OS_NAME.indexOf( "95" ) >= 0 || OS_NAME.indexOf( "98" ) >= 0 || OS_NAME.indexOf( "me" ) >= 0
//wince isn't really 9x, but crippled enough to
//be a muchness. Ant doesnt run on CE, anyway.
- || OS_NAME.indexOf( "ce" ) >= 0);
+ || OS_NAME.indexOf( "ce" ) >= 0 );
isNT = !is9x;
}
if ( family.equals( FAMILY_WINDOWS ) )
@@ -368,8 +380,7 @@ public class Os
}
else if ( family.equals( FAMILY_MAC ) )
{
- isFamily = OS_NAME.indexOf( FAMILY_MAC ) > -1
- || OS_NAME.indexOf( DARWIN ) > -1;
+ isFamily = OS_NAME.indexOf( FAMILY_MAC ) > -1 || OS_NAME.indexOf( DARWIN ) > -1;
}
else if ( family.equals( FAMILY_TANDEM ) )
{
@@ -377,15 +388,12 @@ public class Os
}
else if ( family.equals( FAMILY_UNIX ) )
{
- isFamily = PATH_SEP.equals( ":" )
- && !isFamily( FAMILY_OPENVMS )
- && (!isFamily( FAMILY_MAC ) || OS_NAME.endsWith( "x" )
- || OS_NAME.indexOf( DARWIN ) > -1);
+ isFamily = PATH_SEP.equals( ":" ) && !isFamily( FAMILY_OPENVMS ) && ( !isFamily( FAMILY_MAC )
+ || OS_NAME.endsWith( "x" ) || OS_NAME.indexOf( DARWIN ) > -1 );
}
else if ( family.equals( FAMILY_ZOS ) )
{
- isFamily = OS_NAME.indexOf( FAMILY_ZOS ) > -1
- || OS_NAME.indexOf( "os/390" ) > -1;
+ isFamily = OS_NAME.indexOf( FAMILY_ZOS ) > -1 || OS_NAME.indexOf( "os/390" ) > -1;
}
else if ( family.equals( FAMILY_OS400 ) )
{
@@ -397,9 +405,7 @@ public class Os
}
else
{
- throw new RuntimeException(
- "Don\'t know how to detect os family \""
- + family + "\"" );
+ throw new RuntimeException( "Don\'t know how to detect os family \"" + family + "\"" );
}
}
if ( name != null )
@@ -442,6 +448,7 @@ public class Os
/**
* Test if the given family String represents a valid Family
+ *
* @param family
* @return <code>true</code> if 'family' represents a valid OS-Familiy, <code>false</code> otherwise.
*/
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PathTool.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PathTool.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PathTool.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/PathTool.java Mon Oct 1 20:06:11 2012
@@ -25,7 +25,7 @@ import java.util.StringTokenizer;
/**
* Path tool contains static methods to assist in determining path-related
* information such as relative paths.
- *
+ * <p/>
* This class originally got developed at Apache Anakia and later maintained
* in maven-utils of Apache Maven-1.
* Some external fixes by Apache Committers have been applied later.
@@ -53,14 +53,14 @@ public class PathTool
* PathTool.getRelativePath( "/usr/local/java/bin/java.sh", "/usr/local/" ) = ""
* </pre>
*
- * @param basedir The base directory.
+ * @param basedir The base directory.
* @param filename The filename that is relative to the base
- * directory.
+ * directory.
* @return The relative path of the filename from the base
- * directory. This value is not terminated with a forward slash.
- * A zero-length string is returned if: the filename is not relative to
- * the base directory, <code>basedir</code> is null or zero-length,
- * or <code>filename</code> is null or zero-length.
+ * directory. This value is not terminated with a forward slash.
+ * A zero-length string is returned if: the filename is not relative to
+ * the base directory, <code>basedir</code> is null or zero-length,
+ * or <code>filename</code> is null or zero-length.
*/
public static final String getRelativePath( String basedir, String filename )
{
@@ -71,8 +71,8 @@ public class PathTool
* Verify the arguments and make sure the filename is relative
* to the base directory.
*/
- if ( basedir == null || basedir.length() == 0 || filename == null
- || filename.length() == 0 || !filename.startsWith( basedir ) )
+ if ( basedir == null || basedir.length() == 0 || filename == null || filename.length() == 0
+ || !filename.startsWith( basedir ) )
{
return "";
}
@@ -110,8 +110,8 @@ public class PathTool
*
* @param filename The filename to be parsed.
* @return The relative path of the filename. This value is not
- * terminated with a forward slash. A zero-length string is
- * returned if: <code>filename</code> is null or zero-length.
+ * terminated with a forward slash. A zero-length string is
+ * returned if: <code>filename</code> is null or zero-length.
* @see #getRelativeFilePath(String, String)
*/
public static final String getRelativePath( String filename )
@@ -157,8 +157,8 @@ public class PathTool
*
* @param filename The filename to be parsed.
* @return The directory portion of the <code>filename</code>. If
- * the filename does not contain a directory component, "." is
- * returned.
+ * the filename does not contain a directory component, "." is
+ * returned.
*/
public static final String getDirectoryComponent( String filename )
{
@@ -193,7 +193,7 @@ public class PathTool
* @param relativePath
* @return String
*/
- public static final String calculateLink(String link, String relativePath)
+ public static final String calculateLink( String link, String relativePath )
{
//This must be some historical feature
if ( link.startsWith( "/site/" ) )
@@ -326,16 +326,16 @@ public class PathTool
// check for the presence of windows drives. No relative way of
// traversing from one to the other.
- if ( (toPath.startsWith( ":", 1 ) && fromPath.startsWith( ":", 1 ))
- && (!toPath.substring( 0, 1 ).equals( fromPath.substring( 0, 1 ) )) )
+ if ( ( toPath.startsWith( ":", 1 ) && fromPath.startsWith( ":", 1 ) ) && ( !toPath.substring( 0, 1 ).equals(
+ fromPath.substring( 0, 1 ) ) ) )
{
// they both have drive path element but they dont match, no
// relative path
return null;
}
- if ( (toPath.startsWith( ":", 1 ) && !fromPath.startsWith( ":", 1 ))
- || (!toPath.startsWith( ":", 1 ) && fromPath.startsWith( ":", 1 )) )
+ if ( ( toPath.startsWith( ":", 1 ) && !fromPath.startsWith( ":", 1 ) ) || ( !toPath.startsWith( ":", 1 )
+ && fromPath.startsWith( ":", 1 ) ) )
{
// one has a drive path element and the other doesnt, no relative
// path.
@@ -361,26 +361,24 @@ public class PathTool
* within the filename (except the leading if present), append the
* "../" string to the return value.
*
- * @param filename The filename to parse.
+ * @param filename The filename to parse.
* @param separator The separator used within the filename.
* @return The relative path of the filename. This value is not
- * terminated with a forward slash. A zero-length string is
- * returned if: the filename is zero-length.
+ * terminated with a forward slash. A zero-length string is
+ * returned if: the filename is zero-length.
*/
- private static final String determineRelativePath( String filename,
- String separator )
+ private static final String determineRelativePath( String filename, String separator )
{
if ( filename.length() == 0 )
{
return "";
}
-
/*
- * Count the slashes in the relative filename, but exclude the
- * leading slash. If the path has no slashes, then the filename
- * is relative to the current directory.
- */
+ * Count the slashes in the relative filename, but exclude the
+ * leading slash. If the path has no slashes, then the filename
+ * is relative to the current directory.
+ */
int slashCount = StringUtils.countMatches( filename, separator ) - 1;
if ( slashCount <= 0 )
{
@@ -411,9 +409,9 @@ public class PathTool
* often is returned as the separator.
*
* @param filename The filename parsed to determine the file
- * separator.
+ * separator.
* @return The file separator used within <code>filename</code>.
- * This value is either a forward or backward slash.
+ * This value is either a forward or backward slash.
*/
private static final String determineSeparator( String filename )
{
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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -20,11 +20,10 @@ package org.apache.maven.shared.utils;
*/
-import org.apache.maven.shared.utils.io.IOUtil;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
+import org.apache.maven.shared.utils.io.IOUtil;
public class PropertyUtils
{
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ReaderFactory.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ReaderFactory.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ReaderFactory.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/ReaderFactory.java Mon Oct 1 20:06:11 2012
@@ -19,8 +19,6 @@ package org.apache.maven.shared.utils;
* under the License.
*/
-import org.apache.maven.shared.utils.xml.XmlStreamReader;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -32,6 +30,7 @@ import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.nio.charset.Charset;
+import org.apache.maven.shared.utils.xml.XmlStreamReader;
/**
@@ -48,6 +47,7 @@ public class ReaderFactory
/**
* ISO Latin Alphabet #1, also known as ISO-LATIN-1.
* Every implementation of the Java platform is required to support this character encoding.
+ *
* @see Charset
*/
public static final String ISO_8859_1 = "ISO-8859-1";
@@ -55,6 +55,7 @@ public class ReaderFactory
/**
* Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
* Every implementation of the Java platform is required to support this character encoding.
+ *
* @see Charset
*/
public static final String US_ASCII = "US-ASCII";
@@ -63,6 +64,7 @@ public class ReaderFactory
* Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either
* order accepted on input, big-endian used on output).
* Every implementation of the Java platform is required to support this character encoding.
+ *
* @see Charset
*/
public static final String UTF_16 = "UTF-16";
@@ -70,6 +72,7 @@ public class ReaderFactory
/**
* Sixteen-bit Unicode Transformation Format, big-endian byte order.
* Every implementation of the Java platform is required to support this character encoding.
+ *
* @see Charset
*/
public static final String UTF_16BE = "UTF-16BE";
@@ -77,6 +80,7 @@ public class ReaderFactory
/**
* Sixteen-bit Unicode Transformation Format, little-endian byte order.
* Every implementation of the Java platform is required to support this character encoding.
+ *
* @see Charset
*/
public static final String UTF_16LE = "UTF-16LE";
@@ -84,6 +88,7 @@ public class ReaderFactory
/**
* Eight-bit Unicode Transformation Format.
* Every implementation of the Java platform is required to support this character encoding.
+ *
* @see Charset
*/
public static final String UTF_8 = "UTF-8";
@@ -178,7 +183,7 @@ public class ReaderFactory
/**
* Create a new Reader with specified encoding.
*
- * @param in not null input stream.
+ * @param in not null input stream.
* @param encoding not null supported encoding.
* @return a reader instance for the input stream using the given encoding.
* @throws UnsupportedEncodingException if any.
@@ -193,23 +198,23 @@ public class ReaderFactory
/**
* Create a new Reader with specified encoding.
*
- * @param file not null file.
+ * @param file not null file.
* @param encoding not null supported encoding.
* @return a reader instance for the input file using the given encoding.
- * @throws FileNotFoundException if any.
+ * @throws FileNotFoundException if any.
* @throws UnsupportedEncodingException if any.
* @see <a href="http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html">Supported encodings</a>
*/
public static Reader newReader( File file, String encoding )
throws FileNotFoundException, UnsupportedEncodingException
{
- return new InputStreamReader( new FileInputStream(file), encoding );
+ return new InputStreamReader( new FileInputStream( file ), encoding );
}
/**
* Create a new Reader with specified encoding.
*
- * @param url not null url.
+ * @param url not null url.
* @param encoding not null supported encoding.
* @return a reader instance for the input url using the given encoding.
* @throws IOException if any.