Author: krosenvold
Date: Thu Oct 11 18:42:34 2012
New Revision: 1397223
URL: http://svn.apache.org/viewvc?rev=1397223&view=rev
Log:
o Removed unused code
Removed:
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/EnhancedStringTokenizer.java
Modified:
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/cli/shell/Shell.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/io/FileUtils.java
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/PathToolTest.java
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
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=1397223&r1=1397222&r2=1397223&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
Thu Oct 11 18:42:34 2012
@@ -97,182 +97,6 @@ public class PathTool
}
/**
- * Determines the relative path of a filename. This method is
- * useful in building relative links within pages of a web site. It
- * provides similar functionality to Anakia's
- * <code>$relativePath</code> context variable. The argument to
- * this method may contain either forward or backward slashes as
- * file separators. The relative path returned is formed using
- * forward slashes as it is expected this path is to be used as a
- * link in a web page (again mimicking Anakia's behavior).
- * <p/>
- * This method is thread-safe.
- *
- * @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.
- * @see #getRelativeFilePath(String, String)
- */
- public static String getRelativePath( String filename )
- {
- filename = uppercaseDrive( filename );
-
- if ( filename == null || filename.length() == 0 )
- {
- return "";
- }
-
- /*
- * Normalize the argument. First, determine the file separator
- * that is being used, then strip that off the end of the
- * filename. Then, if the filename doesn't begin with a
- * separator, add one.
- */
-
- String separator = determineSeparator( filename );
- filename = StringUtils.chompLast( filename, separator );
- if ( !filename.startsWith( separator ) )
- {
- filename = separator + filename;
- }
-
- return determineRelativePath( filename, separator );
- }
-
- /**
- * Determines the directory component of a filename. This is useful
- * within DVSL templates when used in conjunction with the DVSL's
- * <code>$context.getAppValue("infilename")</code> to get the
- * current directory that is currently being processed.
- * <p/>
- * This method is thread-safe.
- * <br/>
- * <pre>
- * PathTool.getDirectoryComponent( null )
= ""
- * PathTool.getDirectoryComponent( "/usr/local/java/bin" )
= "/usr/local/java"
- * PathTool.getDirectoryComponent( "/usr/local/java/bin/" )
= "/usr/local/java/bin"
- * PathTool.getDirectoryComponent( "/usr/local/java/bin/java.sh" )
= "/usr/local/java/bin"
- * </pre>
- *
- * @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.
- */
- public static String getDirectoryComponent( String filename )
- {
- if ( filename == null || filename.length() == 0 )
- {
- return "";
- }
-
- String separator = determineSeparator( filename );
- String directory = StringUtils.chomp( filename, separator );
-
- if ( filename.equals( directory ) )
- {
- return ".";
- }
-
- return directory;
- }
-
- /**
- * Calculates the appropriate link given the preferred link and the
relativePath of the document.
- * <br/>
- * <pre>
- * PathTool.calculateLink( "/index.html", "../.." )
= "../../index.html"
- * PathTool.calculateLink(
"http://plexus.codehaus.org/plexus-utils/index.html", "../.." ) =
"http://plexus.codehaus.org/plexus-utils/index.html"
- * PathTool.calculateLink( "/usr/local/java/bin/java.sh", "../.." )
= "../../usr/local/java/bin/java.sh"
- * PathTool.calculateLink( "../index.html", "/usr/local/java/bin" )
= "/usr/local/java/bin/../index.html"
- * PathTool.calculateLink( "../index.html",
"http://plexus.codehaus.org/plexus-utils" ) =
"http://plexus.codehaus.org/plexus-utils/../index.html"
- * </pre>
- *
- * @param link
- * @param relativePath
- * @return String
- */
- public static String calculateLink( String link, String relativePath )
- {
- //This must be some historical feature
- if ( link.startsWith( "/site/" ) )
- {
- return link.substring( 5 );
- }
-
- //Allows absolute links in nav-bars etc
- if ( link.startsWith( "/absolute/" ) )
- {
- return link.substring( 10 );
- }
-
- // This traps urls like http://
- if ( link.indexOf( ":" ) >= 0 )
- {
- return link;
- }
-
- //If relativepath is current directory, just pass the link through
- if ( relativePath.equals( "." ) )
- {
- if ( link.startsWith( "/" ) )
- {
- return link.substring( 1 );
- }
-
- return link;
- }
-
- //If we don't do this, you can end up with ..//bob.html rather than
../bob.html
- if ( relativePath.endsWith( "/" ) && link.startsWith( "/" ) )
- {
- return relativePath + "." + link.substring( 1 );
- }
-
- if ( relativePath.endsWith( "/" ) || link.startsWith( "/" ) )
- {
- return relativePath + link;
- }
-
- return relativePath + "/" + link;
- }
-
- /**
- * This method can calculate the relative path between two pathes on a web
site.
- * <br/>
- * <pre>
- * PathTool.getRelativeWebPath( null, null )
= ""
- * PathTool.getRelativeWebPath( null, "http://plexus.codehaus.org/" )
= ""
- * PathTool.getRelativeWebPath( "http://plexus.codehaus.org/", null )
= ""
- * PathTool.getRelativeWebPath( "http://plexus.codehaus.org/",
- *
"http://plexus.codehaus.org/plexus-utils/index.html" ) =
"plexus-utils/index.html"
- * PathTool.getRelativeWebPath(
"http://plexus.codehaus.org/plexus-utils/index.html",
- * "http://plexus.codehaus.org/"
= "../../"
- * </pre>
- *
- * @param oldPath
- * @param newPath
- * @return a relative web path from <code>oldPath</code>.
- */
- public static String getRelativeWebPath( final String oldPath, final
String newPath )
- {
- if ( StringUtils.isEmpty( oldPath ) || StringUtils.isEmpty( newPath ) )
- {
- return "";
- }
-
- String resultPath = buildRelativePath( newPath, oldPath, '/' );
-
- if ( newPath.endsWith( "/" ) && !resultPath.endsWith( "/" ) )
- {
- return resultPath + "/";
- }
-
- return resultPath;
- }
-
- /**
* This method can calculate the relative path between two pathes on a
file system.
* <br/>
* <pre>
@@ -289,8 +113,8 @@ public class PathTool
* </pre>
* Note: On Windows based system, the <code>/</code> character should be
replaced by <code>\</code> character.
*
- * @param oldPath
- * @param newPath
+ * @param oldPath old path
+ * @param newPath new path
* @return a relative file path from <code>oldPath</code>.
*/
public static String getRelativeFilePath( final String oldPath, final
String newPath )
@@ -424,7 +248,7 @@ public class PathTool
/**
* Cygwin prefers lowercase drive letters, but other parts of maven use
uppercase
*
- * @param path
+ * @param path old path
* @return String
*/
static String uppercaseDrive( String path )
Modified:
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/Shell.java
URL:
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/Shell.java?rev=1397223&r1=1397222&r2=1397223&view=diff
==============================================================================
---
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/Shell.java
(original)
+++
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/Shell.java
Thu Oct 11 18:42:34 2012
@@ -362,16 +362,6 @@ public class Shell
return shell;
}
- public String getOriginalExecutable()
- {
- return executable;
- }
-
- public List<String> getOriginalCommandLine( String executable, String[]
arguments )
- {
- return getRawCommandLine( executable, arguments );
- }
-
protected void setDoubleQuotedArgumentEscaped( boolean
doubleQuotedArgumentEscaped )
{
this.doubleQuotedArgumentEscaped = doubleQuotedArgumentEscaped;
Modified:
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/MethodMap.java
URL:
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/MethodMap.java?rev=1397223&r1=1397222&r2=1397223&view=diff
==============================================================================
---
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/MethodMap.java
(original)
+++
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/MethodMap.java
Thu Oct 11 18:42:34 2012
@@ -173,7 +173,7 @@ public class MethodMap
for ( Iterator<Method> maximal = maximals.iterator();
!lessSpecific && maximal.hasNext(); )
{
- Method max = (Method) maximal.next();
+ Method max = maximal.next();
switch ( moreSpecific( appArgs, max.getParameterTypes() ) )
{
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=1397223&r1=1397222&r2=1397223&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
Thu Oct 11 18:42:34 2012
@@ -153,37 +153,6 @@ public class FileUtils
}
/**
- * Returns a human-readable version of the file size (original is in
- * bytes).
- *
- * @param size The number of bytes.
- * @return A human-readable display value (includes units).
- */
- public static @Nonnull String byteCountToDisplaySize( int size )
- {
- String displaySize;
-
- if ( size / ONE_GB > 0 )
- {
- displaySize = String.valueOf( size / ONE_GB ) + " GB";
- }
- else if ( size / ONE_MB > 0 )
- {
- displaySize = String.valueOf( size / ONE_MB ) + " MB";
- }
- else if ( size / ONE_KB > 0 )
- {
- displaySize = String.valueOf( size / ONE_KB ) + " KB";
- }
- else
- {
- displaySize = String.valueOf( size ) + " bytes";
- }
-
- return displaySize;
- }
-
- /**
* Returns the directory path portion of a file specification string.
* Matches the equally named unix command.
*
@@ -209,45 +178,6 @@ public class FileUtils
}
/**
- * Returns the filename portion of a file specification string.
- * Matches the equally named unix command.
- *
- * @param filename the file path
- * @return The filename string without extension.
- */
- public static @Nonnull String basename( @Nonnull String filename )
- {
- return basename( filename, extension( filename ) );
- }
-
- /**
- * Returns the filename portion of a file specification string.
- * Matches the equally named unix command.
- *
- * @param filename the file path
- * @param suffix the file suffix
- * @return the basename of the file
- */
- private static @Nonnull String basename( @Nonnull String filename,
@Nullable String suffix )
- {
- int i = filename.lastIndexOf( File.separator ) + 1;
- int lastDot = ( ( suffix != null ) && ( suffix.length() > 0 ) ) ?
filename.lastIndexOf( suffix ) : -1;
-
- if ( lastDot >= 0 )
- {
- return filename.substring( i, lastDot );
- }
- else if ( i > 0 )
- {
- return filename.substring( i );
- }
- else
- {
- return filename; // else returns all (no path and no extension)
- }
- }
-
- /**
* Returns the extension portion of a file specification string.
* This everything after the last dot '.' in the filename (NOT including
* the dot).
@@ -458,21 +388,6 @@ public class FileUtils
/**
* Writes data to a file. The file will be created if it does not exist.
- * Note: the data is written with platform encoding
- *
- * @param file The path of the file to write.
- * @param data The content to write to the file.
- * @throws IOException if any
- * @since 2.0.6
- */
- public static void fileWrite( @Nonnull File file, @Nonnull String data )
- throws IOException
- {
- fileWrite( file, null, data );
- }
-
- /**
- * Writes data to a file. The file will be created if it does not exist.
*
* @param file The path of the file to write.
* @param encoding The encoding of the file.
Modified:
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/PathToolTest.java
URL:
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/PathToolTest.java?rev=1397223&r1=1397222&r2=1397223&view=diff
==============================================================================
---
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/PathToolTest.java
(original)
+++
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/PathToolTest.java
Thu Oct 11 18:42:34 2012
@@ -45,41 +45,6 @@ public class PathToolTest extends Assert
public TemporaryFolder tempFolder = new TemporaryFolder();
@Test
- public void testCalculateLink()
- {
- assertThat( PathTool.calculateLink( "/index.html", "../.." )
- , is( "../../index.html" ) );
-
- assertThat( PathTool.calculateLink(
"http://plexus.codehaus.org/plexus-utils/index.html", "../.." )
- , is( "http://plexus.codehaus.org/plexus-utils/index.html" )
);
-
- assertThat( PathTool.calculateLink( "/usr/local/java/bin/java.sh",
"../.." )
- , is( "../../usr/local/java/bin/java.sh" ) );
-
- assertThat( PathTool.calculateLink( "../index.html",
"/usr/local/java/bin" )
- , is( "/usr/local/java/bin/../index.html" ) );
-
- assertThat( PathTool.calculateLink( "../index.html",
"http://plexus.codehaus.org/plexus-utils" )
- , is(
"http://plexus.codehaus.org/plexus-utils/../index.html" ) );
- }
-
- @Test
- public void testGetDirectoryComponent()
- {
- assertThat( PathTool.getDirectoryComponent( null )
- , is( "" ) );
-
- assertThat( PathTool.getDirectoryComponent( "/usr/local/java/bin" )
- , is( "/usr/local/java" ) );
-
- assertThat( PathTool.getDirectoryComponent( "/usr/local/java/bin/" )
- , is( "/usr/local/java/bin" ) );
-
- assertThat( PathTool.getDirectoryComponent(
"/usr/local/java/bin/java.sh" )
- , is( "/usr/local/java/bin" ) );
- }
-
- @Test
// Keep in sync with testGetRelativeFilePath_Windows()
public void testGetRelativeFilePath_NonWindows()
{
@@ -176,44 +141,6 @@ public class PathToolTest extends Assert
}
@Test
- public void testGetRelativePath_1parm()
- {
- assertThat( PathTool.getRelativePath( null )
- , is( "" ) );
-
- File baseFolder = tempFolder.newFolder( "pathtooltest" );
-
- String folderName = "anotherFolders";
- File newDir = new File( baseFolder, folderName );
- newDir.mkdirs();
-
-
- assertThat( PathTool.getRelativePath( folderName )
- , is( "." ) );
- }
-
- @Test
- public void testGetRelativeWebPath()
- {
- assertThat( PathTool.getRelativeWebPath( null, null )
- , is( "" ) );
-
- assertThat( PathTool.getRelativeWebPath( null,
"http://plexus.codehaus.org/" )
- , is( "" ) );
-
- assertThat( PathTool.getRelativeWebPath(
"http://plexus.codehaus.org/", null )
- , is( "" ) );
-
- assertThat( PathTool.getRelativeWebPath( "http://plexus.codehaus.org/"
- ,
"http://plexus.codehaus.org/plexus-utils/index.html" )
- , is( "plexus-utils/index.html" ) );
-
- assertThat( PathTool.getRelativeWebPath(
"http://plexus.codehaus.org/plexus-utils/index.html"
- , "http://plexus.codehaus.org/"
)
- , is( "../../" ) );
- }
-
- @Test
public void testUppercaseDrive()
{
assertThat( PathTool.uppercaseDrive( null )
Modified:
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
URL:
http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java?rev=1397223&r1=1397222&r2=1397223&view=diff
==============================================================================
---
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
(original)
+++
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
Thu Oct 11 18:42:34 2012
@@ -160,16 +160,6 @@ public class FileUtilsTest
}
}
- //-----------------------------------------------------------------------
- // byteCountToDisplaySize
- @Test
- public void byteCountToDisplaySize()
- {
- assertThat( "0 bytes", is( FileUtils.byteCountToDisplaySize( 0 ) ) );
- assertThat( "1 KB", is( FileUtils.byteCountToDisplaySize( 1024 ) ) );
- assertThat( "1 MB", is( FileUtils.byteCountToDisplaySize( 1024 * 1024
) ) );
- assertThat( "1 GB", is( FileUtils.byteCountToDisplaySize( 1024 * 1024
* 1024 ) ) );
- }
//-----------------------------------------------------------------------
@Test
@@ -924,7 +914,7 @@ public class FileUtilsTest
throws Exception
{
File file = FileTestHelper.newFile( tempFolder, "lines.txt" );
- FileUtils.fileWrite( file, "This line was there before you..." );
+ FileUtils.fileWrite( file, null, "This line was there before you..." );
FileUtils.fileAppend( file.getAbsolutePath(), "this is brand new data"
);
@@ -938,7 +928,7 @@ public class FileUtilsTest
throws Exception
{
File file = FileTestHelper.newFile( tempFolder, "lines.txt" );
- FileUtils.fileWrite( file, "This line was there before you..." );
+ FileUtils.fileWrite( file, null, "This line was there before you..." );
FileUtils.fileAppend( file.getAbsolutePath(), "this is brand new data"
);
@@ -989,7 +979,7 @@ public class FileUtilsTest
throws Exception
{
File file = FileTestHelper.newFile( tempFolder, "lines.txt" );
- FileUtils.fileWrite( file, "This line was there before you..." );
+ FileUtils.fileWrite( file, null, "This line was there before you..." );
FileUtils.fileAppend( file.getAbsolutePath(), "this is brand new data"
);
@@ -1262,105 +1252,6 @@ public class FileUtilsTest
assertThat( FileUtils.filename( "/test/foo.bar.txt" ), is(
"foo.bar.txt" ) );
}
- //// basename(String)
-
- @SuppressWarnings("ConstantConditions")
- @Test( expected = NullPointerException.class )
- public void blowUpOnbasenameNull()
- throws Exception
- {
- FileUtils.basename( null );
- }
-
- @Test
- public void basenameEmpty()
- throws Exception
- {
- assertThat( FileUtils.basename( "" ), is( "" ) );
- }
-
- @Test
- public void basenameFilename()
- throws Exception
- {
- assertThat( FileUtils.basename( "foo.bar.txt" ), is( "foo.bar." ) );
- }
-
- @Test
- public void basenameFilenameNoExtension()
- throws Exception
- {
- assertThat( FileUtils.basename( "foo_bar_txt" ), is( "foo_bar_txt" ) );
- }
-
- @Test
- //X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void basenameWindowsRootPathOnUnix()
- throws Exception
- {
- assumeThat( File.separatorChar, is( '/' ) );
- assertThat( FileUtils.basename( "C:\\foo.bar.txt" ), is(
"C:\\foo.bar." ) );
- }
-
- @Test
- //X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void basenameWindowsNonRootPathOnUnix()
- throws Exception
- {
- assumeThat( File.separatorChar, is( '/' ) );
- assertThat( FileUtils.basename( "C:\\test\\foo.bar.txt" ), is(
"C:\\test\\foo.bar." ) );
- }
-
- @Test
- //X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void basenameUnixRootPathOnWindows()
- throws Exception
- {
- assumeThat( File.separatorChar, is( '\\' ) );
- assertThat( FileUtils.basename( "/foo.bar.txt" ), is( "/foo.bar." ) );
- }
-
- @Test
- //X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void basenameUnixNonRootPathOnWindows()
- throws Exception
- {
- assumeThat( File.separatorChar, is( '\\' ) );
- assertThat( FileUtils.basename( "/test/foo.bar.txt" ), is(
"/test/foo.bar." ) );
- }
-
- @Test
- public void basenameWindowsRootPathOnWindows()
- throws Exception
- {
- assumeThat( File.separatorChar, is( '\\' ) );
- assertThat( FileUtils.basename( "C:\\foo.bar.txt" ), is( "foo.bar." )
);
- }
-
- @Test
- public void basenameWindowsNonRootPathOnWindows()
- throws Exception
- {
- assumeThat( File.separatorChar, is( '\\' ) );
- assertThat( FileUtils.basename( "C:\\test\\foo.bar.txt" ), is(
"foo.bar." ) );
- }
-
- @Test
- public void basenameUnixRootPathOnUnix()
- throws Exception
- {
- assumeThat( File.separatorChar, is( '/' ) );
- assertThat( FileUtils.basename( "/foo.bar.txt" ), is( "foo.bar." ) );
- }
-
- @Test
- public void basenameUnixNonRootPathOnUnix()
- throws Exception
- {
- assumeThat( File.separatorChar, is( '/' ) );
- assertThat( FileUtils.basename( "/test/foo.bar.txt" ), is( "foo.bar."
) );
- }
-
//// extension(String)
@SuppressWarnings("ConstantConditions")