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 [2/5] - in
/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils:
./ cli/ cli/shell/ introspection/ io/ reflection/ xml/
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -28,7 +28,7 @@ import java.util.StringTokenizer;
/**
* <p>Common <code>String</code> manipulation routines.</p>
- *
+ * <p/>
* <p>Originally from
* <a href="http://jakarta.apache.org/turbine/">Turbine</a>, the
* GenerationJavaCore library and Velocity.
@@ -46,8 +46,8 @@ import java.util.StringTokenizer;
* @author <a href="mailto:fredrik@westermarck.com">Fredrik Westermarck</a>
* @author Holger Krauth
* @author <a href="mailto:alex@purpletech.com">Alexander Day Chaffee</a>
- * @since 1.0
* @version $Id$
+ * @since 1.0
*/
public class StringUtils
{
@@ -55,7 +55,7 @@ public class StringUtils
* <p><code>StringUtils</code> instances should NOT be constructed in
* standard programming. Instead, the class should be used as
* <code>StringUtils.trim(" foo ");</code>.</p>
- *
+ * <p/>
* <p>This constructor is public to permit tools that require a JavaBean
* manager to operate.</p>
*/
@@ -71,9 +71,9 @@ public class StringUtils
* ends of this String, handling <code>null</code> by returning
* an empty String.</p>
*
- * @see java.lang.String#trim()
* @param str the String to check
* @return the trimmed text (never <code>null</code>)
+ * @see java.lang.String#trim()
*/
public static String clean( String str )
{
@@ -85,9 +85,9 @@ public class StringUtils
* ends of this String, handling <code>null</code> by returning
* <code>null</code>.</p>
*
- * @see java.lang.String#trim()
* @param str the String to check
* @return the trimmed text (or <code>null</code>)
+ * @see java.lang.String#trim()
*/
public static String trim( String str )
{
@@ -96,7 +96,7 @@ public class StringUtils
/**
* <p>Deletes all whitespaces from a String.</p>
- *
+ * <p/>
* <p>Whitespace is defined by
* {@link Character#isWhitespace(char)}.</p>
*
@@ -132,14 +132,14 @@ public class StringUtils
/**
* <p>Checks if a (trimmed) String is <code>null</code> or empty.</p>
- *
+ * <p/>
* <p><strong>Note:</strong> In future releases, this method will no longer trim the input string such that it works
* complementary to {@link #isNotEmpty(String)}. Code that wants to test for whitespace-only strings should be
* migrated to use {@link #isBlank(String)} instead.</p>
*
* @param str the String to check
* @return <code>true</code> if the String is <code>null</code>, or
- * length zero once trimmed
+ * length zero once trimmed
*/
public static boolean isEmpty( String str )
{
@@ -150,7 +150,7 @@ public class StringUtils
* <p>
* Checks if a String is whitespace, empty ("") or null.
* </p>
- *
+ * <p/>
* <pre>
* StringUtils.isBlank(null) = true
* StringUtils.isBlank("") = true
@@ -184,7 +184,7 @@ public class StringUtils
* <p>
* Checks if a String is not empty (""), not null and not whitespace only.
* </p>
- *
+ * <p/>
* <pre>
* StringUtils.isNotBlank(null) = false
* StringUtils.isNotBlank("") = false
@@ -207,15 +207,15 @@ public class StringUtils
/**
* <p>Compares two Strings, returning <code>true</code> if they are equal.</p>
- *
+ * <p/>
* <p><code>null</code>s are handled without exceptions. Two <code>null</code>
* references are considered to be equal. The comparison is case sensitive.</p>
*
- * @see java.lang.String#equals(Object)
* @param str1 the first string
* @param str2 the second string
* @return <code>true</code> if the Strings are equal, case sensitive, or
- * both <code>null</code>
+ * both <code>null</code>
+ * @see java.lang.String#equals(Object)
*/
public static boolean equals( String str1, String str2 )
{
@@ -225,15 +225,15 @@ public class StringUtils
/**
* <p>Compares two Strings, returning <code>true</code> if they are equal ignoring
* the case.</p>
- *
+ * <p/>
* <p><code>Nulls</code> are handled without exceptions. Two <code>null</code>
* references are considered equal. Comparison is case insensitive.</p>
*
- * @see java.lang.String#equalsIgnoreCase(String)
- * @param str1 the first string
- * @param str2 the second string
+ * @param str1 the first string
+ * @param str2 the second string
* @return <code>true</code> if the Strings are equal, case insensitive, or
- * both <code>null</code>
+ * both <code>null</code>
+ * @see java.lang.String#equalsIgnoreCase(String)
*/
public static boolean equalsIgnoreCase( String str1, String str2 )
{
@@ -242,10 +242,10 @@ public class StringUtils
/**
* <p>Find the first index of any of a set of potential substrings.</p>
- *
+ * <p/>
* <p><code>null</code> String will return <code>-1</code>.</p>
*
- * @param str the String to check
+ * @param str the String to check
* @param searchStrs the Strings to search for
* @return the first index of any of the searchStrs in str
* @throws NullPointerException if any of searchStrs[i] is <code>null</code>
@@ -281,11 +281,11 @@ public class StringUtils
/**
* <p>Find the latest index of any of a set of potential substrings.</p>
- *
+ * <p/>
* <p><code>null</code> string will return <code>-1</code>.</p>
*
- * @param str the String to check
- * @param searchStrs the Strings to search for
+ * @param str the String to check
+ * @param searchStrs the Strings to search for
* @return the last index of any of the Strings
* @throws NullPointerException if any of searchStrs[i] is <code>null</code>
*/
@@ -314,13 +314,13 @@ public class StringUtils
/**
* <p>Gets a substring from the specified string avoiding exceptions.</p>
- *
+ * <p/>
* <p>A negative start position can be used to start <code>n</code>
* characters from the end of the String.</p>
*
- * @param str the String to get the substring from
+ * @param str the String to get the substring from
* @param start the position to start from, negative means
- * count back from the end of the String by this many characters
+ * count back from the end of the String by this many characters
* @return substring from start position
*/
public static String substring( String str, int start )
@@ -350,15 +350,15 @@ public class StringUtils
/**
* <p>Gets a substring from the specified String avoiding exceptions.</p>
- *
+ * <p/>
* <p>A negative start position can be used to start/end <code>n</code>
* characters from the end of the String.</p>
*
- * @param str the String to get the substring from
+ * @param str the String to get the substring from
* @param start the position to start from, negative means
- * count back from the end of the string by this many characters
- * @param end the position to end at (exclusive), negative means
- * count back from the end of the String by this many characters
+ * count back from the end of the string by this many characters
+ * @param end the position to end at (exclusive), negative means
+ * count back from the end of the String by this many characters
* @return substring from start position to end positon
*/
public static String substring( String str, int start, int end )
@@ -405,7 +405,7 @@ public class StringUtils
/**
* <p>Gets the leftmost <code>n</code> characters of a String.</p>
- *
+ * <p/>
* <p>If <code>n</code> characters are not available, or the
* String is <code>null</code>, the String will be returned without
* an exception.</p>
@@ -433,7 +433,7 @@ public class StringUtils
/**
* <p>Gets the rightmost <code>n</code> characters of a String.</p>
- *
+ * <p/>
* <p>If <code>n</code> characters are not available, or the String
* is <code>null</code>, the String will be returned without an
* exception.</p>
@@ -461,7 +461,7 @@ public class StringUtils
/**
* <p>Gets <code>n</code> characters from the middle of a String.</p>
- *
+ * <p/>
* <p>If <code>n</code> characters are not available, the remainder
* of the String will be returned without an exception. If the
* String is <code>null</code>, <code>null</code> will be returned.</p>
@@ -471,12 +471,11 @@ public class StringUtils
* @param len the length of the required String
* @return the leftmost characters
* @throws IndexOutOfBoundsException if pos is out of bounds
- * @throws IllegalArgumentException if len is less than zero
+ * @throws IllegalArgumentException if len is less than zero
*/
public static String mid( String str, int pos, int len )
{
- if ( ( pos < 0 ) ||
- ( ( str != null ) && ( pos > str.length() ) ) )
+ if ( ( pos < 0 ) || ( ( str != null ) && ( pos > str.length() ) ) )
{
throw new StringIndexOutOfBoundsException( "String index " + pos + " is out of bounds" );
}
@@ -504,7 +503,7 @@ public class StringUtils
/**
* <p>Splits the provided text into a array, using whitespace as the
* separator.</p>
- *
+ * <p/>
* <p>The separator is not included in the returned String array.</p>
*
* @param str the String to parse
@@ -525,20 +524,20 @@ public class StringUtils
/**
* <p>Splits the provided text into a array, based on a given separator.</p>
- *
+ * <p/>
* <p>The separator is not included in the returned String array. The
* maximum number of splits to perfom can be controlled. A <code>null</code>
* separator will cause parsing to be on whitespace.</p>
- *
+ * <p/>
* <p>This is useful for quickly splitting a String directly into
* an array of tokens, instead of an enumeration of tokens (as
* <code>StringTokenizer</code> does).</p>
*
- * @param str The string to parse.
+ * @param str The string to parse.
* @param separator Characters used as the delimiters. If
- * <code>null</code>, splits on whitespace.
- * @param max The maximum number of elements to include in the
- * array. A zero or negative value implies no limit.
+ * <code>null</code>, splits on whitespace.
+ * @param max The maximum number of elements to include in the
+ * array. A zero or negative value implies no limit.
* @return an array of parsed Strings
*/
public static String[] split( String str, String separator, int max )
@@ -590,9 +589,10 @@ public class StringUtils
// Joining
//--------------------------------------------------------------------------
+
/**
* <p>Concatenates elements of an array into a single String.</p>
- *
+ * <p/>
* <p>The difference from join is that concatenate has no delimiter.</p>
*
* @param array the array of values to concatenate.
@@ -606,11 +606,11 @@ public class StringUtils
/**
* <p>Joins the elements of the provided array into a single String
* containing the provided list of elements.</p>
- *
+ * <p/>
* <p>No delimiter is added before or after the list. A
* <code>null</code> separator is the same as a blank String.</p>
*
- * @param array the array of values to join together
+ * @param array the array of values to join together
* @param separator the separator character to use
* @return the joined String
*/
@@ -621,8 +621,7 @@ public class StringUtils
separator = "";
}
int arraySize = array.length;
- int bufSize = ( arraySize == 0 ? 0 : ( array[0].toString().length() +
- separator.length() ) * arraySize );
+ int bufSize = ( arraySize == 0 ? 0 : ( array[0].toString().length() + separator.length() ) * arraySize );
StringBuffer buf = new StringBuffer( bufSize );
for ( int i = 0; i < arraySize; i++ )
@@ -639,12 +638,12 @@ public class StringUtils
/**
* <p>Joins the elements of the provided <code>Iterator</code> into
* a single String containing the provided elements.</p>
- *
+ * <p/>
* <p>No delimiter is added before or after the list. A
* <code>null</code> separator is the same as a blank String.</p>
*
- * @param iterator the <code>Iterator</code> of values to join together
- * @param separator the separator character to use
+ * @param iterator the <code>Iterator</code> of values to join together
+ * @param separator the separator character to use
* @return the joined String
*/
public static String join( Iterator<?> iterator, String separator )
@@ -665,21 +664,19 @@ public class StringUtils
return buf.toString();
}
-
-
// Replacing
//--------------------------------------------------------------------------
/**
* <p>Replace a char with another char inside a larger String, once.</p>
- *
+ * <p/>
* <p>A <code>null</code> reference passed to this method is a no-op.</p>
*
- * @see #replace(String text, char repl, char with, int max)
* @param text text to search and replace in
* @param repl char to search for
* @param with char to replace with
* @return the text with any replacements processed
+ * @see #replace(String text, char repl, char with, int max)
*/
public static String replaceOnce( String text, char repl, char with )
{
@@ -688,14 +685,14 @@ public class StringUtils
/**
* <p>Replace all occurances of a char within another char.</p>
- *
+ * <p/>
* <p>A <code>null</code> reference passed to this method is a no-op.</p>
*
- * @see #replace(String text, char repl, char with, int max)
* @param text text to search and replace in
* @param repl char to search for
* @param with char to replace with
* @return the text with any replacements processed
+ * @see #replace(String text, char repl, char with, int max)
*/
public static String replace( String text, char repl, char with )
{
@@ -705,13 +702,13 @@ public class StringUtils
/**
* <p>Replace a char with another char inside a larger String,
* for the first <code>max</code> values of the search char.</p>
- *
+ * <p/>
* <p>A <code>null</code> reference passed to this method is a no-op.</p>
*
* @param text text to search and replace in
* @param repl char to search for
* @param with char to replace with
- * @param max maximum number of values to replace, or <code>-1</code> if no maximum
+ * @param max maximum number of values to replace, or <code>-1</code> if no maximum
* @return the text with any replacements processed
*/
public static String replace( String text, char repl, char with, int max )
@@ -721,14 +718,14 @@ public class StringUtils
/**
* <p>Replace a String with another String inside a larger String, once.</p>
- *
+ * <p/>
* <p>A <code>null</code> reference passed to this method is a no-op.</p>
*
- * @see #replace(String text, String repl, String with, int max)
* @param text text to search and replace in
* @param repl String to search for
* @param with String to replace with
* @return the text with any replacements processed
+ * @see #replace(String text, String repl, String with, int max)
*/
public static String replaceOnce( String text, String repl, String with )
{
@@ -737,14 +734,14 @@ public class StringUtils
/**
* <p>Replace all occurances of a String within another String.</p>
- *
+ * <p/>
* <p>A <code>null</code> reference passed to this method is a no-op.</p>
*
- * @see #replace(String text, String repl, String with, int max)
* @param text text to search and replace in
* @param repl String to search for
* @param with String to replace with
* @return the text with any replacements processed
+ * @see #replace(String text, String repl, String with, int max)
*/
public static String replace( String text, String repl, String with )
{
@@ -754,13 +751,13 @@ public class StringUtils
/**
* <p>Replace a String with another String inside a larger String,
* for the first <code>max</code> values of the search String.</p>
- *
+ * <p/>
* <p>A <code>null</code> reference passed to this method is a no-op.</p>
*
* @param text text to search and replace in
* @param repl String to search for
* @param with String to replace with
- * @param max maximum number of values to replace, or <code>-1</code> if no maximum
+ * @param max maximum number of values to replace, or <code>-1</code> if no maximum
* @return the text with any replacements processed
*/
public static String replace( String text, String repl, String with, int max )
@@ -789,20 +786,17 @@ public class StringUtils
/**
* <p>Overlay a part of a String with another String.</p>
*
- * @param text String to do overlaying in
+ * @param text String to do overlaying in
* @param overlay String to overlay
- * @param start int to start overlaying at
- * @param end int to stop overlaying before
+ * @param start int to start overlaying at
+ * @param end int to stop overlaying before
* @return String with overlayed text
* @throws NullPointerException if text or overlay is <code>null</code>
*/
public static String overlayString( String text, String overlay, int start, int end )
{
- return new StringBuffer( start + overlay.length() + text.length() - end + 1 )
- .append( text.substring( 0, start ) )
- .append( overlay )
- .append( text.substring( end ) )
- .toString();
+ return new StringBuffer( start + overlay.length() + text.length() - end + 1 ).append(
+ text.substring( 0, start ) ).append( overlay ).append( text.substring( end ) ).toString();
}
// Centering
@@ -810,11 +804,11 @@ public class StringUtils
/**
* <p>Center a String in a larger String of size <code>n</code>.<p>
- *
+ * <p/>
* <p>Uses spaces as the value to buffer the String with.
* Equivalent to <code>center(str, size, " ")</code>.</p>
*
- * @param str String to center
+ * @param str String to center
* @param size int size of new String
* @return String containing centered String
* @throws NullPointerException if str is <code>null</code>
@@ -826,15 +820,15 @@ public class StringUtils
/**
* <p>Center a String in a larger String of size <code>n</code>.</p>
- *
+ * <p/>
* <p>Uses a supplied String as the value to buffer the String with.</p>
*
- * @param str String to center
- * @param size int size of new String
+ * @param str String to center
+ * @param size int size of new String
* @param delim String to buffer the new String with
* @return String containing centered String
* @throws NullPointerException if str or delim is <code>null</code>
- * @throws ArithmeticException if delim is the empty String
+ * @throws ArithmeticException if delim is the empty String
*/
public static String center( String str, int size, String delim )
{
@@ -999,7 +993,7 @@ public class StringUtils
/**
* <p>Remove the last character from a String.</p>
- *
+ * <p/>
* <p>If the String ends in <code>\r\n</code>, then remove both
* of them.</p>
*
@@ -1056,14 +1050,14 @@ public class StringUtils
return str.substring( 0, lastIdx );
}
-
// Conversion
//--------------------------------------------------------------------------
// spec 3.10.6
+
/**
* <p>Escapes any values it finds into their String form.</p>
- *
+ * <p/>
* <p>So a tab becomes the characters <code>'\\'</code> and
* <code>'t'</code>.</p>
*
@@ -1118,7 +1112,7 @@ public class StringUtils
buffer.append( '\\' );
buffer.append( 'r' );
break;
- default :
+ default:
if ( ch > 0xf )
{
buffer.append( "\\u00" + Integer.toHexString( ch ) );
@@ -1146,7 +1140,7 @@ public class StringUtils
buffer.append( '\\' );
buffer.append( '\\' );
break;
- default :
+ default:
buffer.append( ch );
break;
}
@@ -1162,11 +1156,11 @@ public class StringUtils
* <p>Repeat a String <code>n</code> times to form a
* new string.</p>
*
- * @param str String to repeat
+ * @param str String to repeat
* @param repeat number of times to repeat str
* @return String with repeated String
* @throws NegativeArraySizeException if <code>repeat < 0</code>
- * @throws NullPointerException if str is <code>null</code>
+ * @throws NullPointerException if str is <code>null</code>
*/
public static String repeat( String str, int repeat )
{
@@ -1180,10 +1174,10 @@ public class StringUtils
/**
* <p>Right pad a String with spaces.</p>
- *
+ * <p/>
* <p>The String is padded to the size of <code>n</code>.</p>
*
- * @param str String to repeat
+ * @param str String to repeat
* @param size number of times to repeat str
* @return right padded String
* @throws NullPointerException if str is <code>null</code>
@@ -1195,15 +1189,15 @@ public class StringUtils
/**
* <p>Right pad a String with a specified string.</p>
- *
+ * <p/>
* <p>The String is padded to the size of <code>n</code>.</p>
*
- * @param str String to pad out
- * @param size size to pad to
+ * @param str String to pad out
+ * @param size size to pad to
* @param delim String to pad with
* @return right padded String
* @throws NullPointerException if str or delim is <code>null</code>
- * @throws ArithmeticException if delim is the empty String
+ * @throws ArithmeticException if delim is the empty String
*/
public static String rightPad( String str, int size, String delim )
{
@@ -1217,10 +1211,10 @@ public class StringUtils
/**
* <p>Left pad a String with spaces.</p>
- *
+ * <p/>
* <p>The String is padded to the size of <code>n</code>.</p>
*
- * @param str String to pad out
+ * @param str String to pad out
* @param size size to pad to
* @return left padded String
* @throws NullPointerException if str or delim is <code>null</code>
@@ -1233,12 +1227,12 @@ public class StringUtils
/**
* Left pad a String with a specified string. Pad to a size of n.
*
- * @param str String to pad out
- * @param size size to pad to
+ * @param str String to pad out
+ * @param size size to pad to
* @param delim String to pad with
* @return left padded String
* @throws NullPointerException if str or delim is null
- * @throws ArithmeticException if delim is the empty string
+ * @throws ArithmeticException if delim is the empty string
*/
public static String leftPad( String str, int size, String delim )
{
@@ -1267,11 +1261,11 @@ public class StringUtils
/**
* <p>Remove a specified String from the front and back of a
* String.</p>
- *
+ * <p/>
* <p>If whitespace is wanted to be removed, used the
* {@link #strip(java.lang.String)} method.</p>
*
- * @param str the String to remove a string from
+ * @param str the String to remove a string from
* @param delim the String to remove at start and end
* @return the stripped String
*/
@@ -1297,7 +1291,7 @@ public class StringUtils
* <p>Strip the specified delimiter from the front and back of
* every String in the array.</p>
*
- * @param strs the Strings to remove a String from
+ * @param strs the Strings to remove a String from
* @param delimiter the String to remove at start and end
* @return the stripped Strings
*/
@@ -1318,11 +1312,11 @@ public class StringUtils
/**
* <p>Strip any of a supplied String from the end of a String.</p>
- *
+ * <p/>
* <p>If the strip String is <code>null</code>, whitespace is
* stripped.</p>
*
- * @param str the String to remove characters from
+ * @param str the String to remove characters from
* @param strip the String to remove
* @return the stripped String
*/
@@ -1353,11 +1347,11 @@ public class StringUtils
/**
* <p>Strip any of a supplied String from the start of a String.</p>
- *
+ * <p/>
* <p>If the strip String is <code>null</code>, whitespace is
* stripped.</p>
*
- * @param str the String to remove characters from
+ * @param str the String to remove characters from
* @param strip the String to remove
* @return the stripped String
*/
@@ -1426,7 +1420,7 @@ public class StringUtils
/**
* <p>Uncapitalise a String.</p>
- *
+ * <p/>
* <p>That is, convert the first character into lower-case.
* <code>null</code> is returned as <code>null</code>.</p>
*
@@ -1445,16 +1439,14 @@ public class StringUtils
}
else
{
- return new StringBuffer( str.length() )
- .append( Character.toLowerCase( str.charAt( 0 ) ) )
- .append( str.substring( 1 ) )
- .toString();
+ return new StringBuffer( str.length() ).append( Character.toLowerCase( str.charAt( 0 ) ) ).append(
+ str.substring( 1 ) ).toString();
}
}
/**
* <p>Capitalise a String.</p>
- *
+ * <p/>
* <p>That is, convert the first character into title-case.
* <code>null</code> is returned as <code>null</code>.</p>
*
@@ -1473,19 +1465,17 @@ public class StringUtils
}
else
{
- return new StringBuffer( str.length() )
- .append( Character.toTitleCase( str.charAt( 0 ) ) )
- .append( str.substring( 1 ) )
- .toString();
+ return new StringBuffer( str.length() ).append( Character.toTitleCase( str.charAt( 0 ) ) ).append(
+ str.substring( 1 ) ).toString();
}
}
/**
* <p>Swaps the case of String.</p>
- *
+ * <p/>
* <p>Properly looks after making sure the start of words
* are Titlecase and not Uppercase.</p>
- *
+ * <p/>
* <p><code>null</code> is returned as <code>null</code>.</p>
*
* @param str the String to swap the case of
@@ -1539,10 +1529,10 @@ public class StringUtils
/**
* <p>Capitalise all the words in a String.</p>
- *
+ * <p/>
* <p>Uses {@link Character#isWhitespace(char)} as a
* separator between words.</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>null</code>.</p>
*
* @param str the String to capitalise
@@ -1580,13 +1570,13 @@ public class StringUtils
/**
* <p>Uncapitalise all the words in a string.</p>
- *
+ * <p/>
* <p>Uses {@link Character#isWhitespace(char)} as a
* separator between words.</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>null</code>.</p>
*
- * @param str the string to uncapitalise
+ * @param str the string to uncapitalise
* @return uncapitalised string
*/
public static String uncapitaliseAllWords( String str )
@@ -1625,7 +1615,7 @@ public class StringUtils
/**
* <p>Get the String that is nested in between two instances of the
* same String.</p>
- *
+ * <p/>
* <p>If <code>str</code> is <code>null</code>, will
* return <code>null</code>.</p>
*
@@ -1642,8 +1632,8 @@ public class StringUtils
/**
* <p>Get the String that is nested in between two Strings.</p>
*
- * @param str the String containing nested-string
- * @param open the String before nested-string
+ * @param str the String containing nested-string
+ * @param open the String before nested-string
* @param close the String after nested-string
* @return the String that was nested, or <code>null</code>
* @throws NullPointerException if open or close is <code>null</code>
@@ -1668,7 +1658,7 @@ public class StringUtils
/**
* <p>How many times is the substring in the larger String.</p>
- *
+ * <p/>
* <p><code>null</code> returns <code>0</code>.</p>
*
* @param str the String to check
@@ -1701,7 +1691,7 @@ public class StringUtils
/**
* <p>Checks if the String contains only unicode letters.</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>false</code>.
* An empty String will return <code>true</code>.</p>
*
@@ -1727,7 +1717,7 @@ public class StringUtils
/**
* <p>Checks if the String contains only whitespace.</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>false</code>. An
* empty String will return <code>true</code>.</p>
*
@@ -1754,13 +1744,13 @@ public class StringUtils
/**
* <p>Checks if the String contains only unicode letters and
* space (<code>' '</code>).</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>false</code>. An
* empty String will return <code>true</code>.</p>
*
* @param str the String to check
* @return <code>true</code> if only contains letters and space,
- * and is non-null
+ * and is non-null
*/
public static boolean isAlphaSpace( String str )
{
@@ -1771,8 +1761,7 @@ public class StringUtils
int sz = str.length();
for ( int i = 0; i < sz; i++ )
{
- if ( ( Character.isLetter( str.charAt( i ) ) == false ) &&
- ( str.charAt( i ) != ' ' ) )
+ if ( ( Character.isLetter( str.charAt( i ) ) == false ) && ( str.charAt( i ) != ' ' ) )
{
return false;
}
@@ -1782,13 +1771,13 @@ public class StringUtils
/**
* <p>Checks if the String contains only unicode letters or digits.</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>false</code>. An empty
* String will return <code>true</code>.</p>
*
* @param str the String to check
* @return <code>true</code> if only contains letters or digits,
- * and is non-null
+ * and is non-null
*/
public static boolean isAlphanumeric( String str )
{
@@ -1810,13 +1799,13 @@ public class StringUtils
/**
* <p>Checks if the String contains only unicode letters, digits
* or space (<code>' '</code>).</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>false</code>. An empty
* String will return <code>true</code>.</p>
*
* @param str the String to check
* @return <code>true</code> if only contains letters, digits or space,
- * and is non-null
+ * and is non-null
*/
public static boolean isAlphanumericSpace( String str )
{
@@ -1827,8 +1816,7 @@ public class StringUtils
int sz = str.length();
for ( int i = 0; i < sz; i++ )
{
- if ( ( Character.isLetterOrDigit( str.charAt( i ) ) == false ) &&
- ( str.charAt( i ) != ' ' ) )
+ if ( ( Character.isLetterOrDigit( str.charAt( i ) ) == false ) && ( str.charAt( i ) != ' ' ) )
{
return false;
}
@@ -1838,7 +1826,7 @@ public class StringUtils
/**
* <p>Checks if the String contains only unicode digits.</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>false</code>.
* An empty String will return <code>true</code>.</p>
*
@@ -1865,13 +1853,13 @@ public class StringUtils
/**
* <p>Checks if the String contains only unicode digits or space
* (<code>' '</code>).</p>
- *
+ * <p/>
* <p><code>null</code> will return <code>false</code>. An empty
* String will return <code>true</code>.</p>
*
* @param str the String to check
* @return <code>true</code> if only contains digits or space,
- * and is non-null
+ * and is non-null
*/
public static boolean isNumericSpace( String str )
{
@@ -1882,8 +1870,7 @@ public class StringUtils
int sz = str.length();
for ( int i = 0; i < sz; i++ )
{
- if ( ( Character.isDigit( str.charAt( i ) ) == false ) &&
- ( str.charAt( i ) != ' ' ) )
+ if ( ( Character.isDigit( str.charAt( i ) ) == false ) && ( str.charAt( i ) != ' ' ) )
{
return false;
}
@@ -1901,7 +1888,7 @@ public class StringUtils
*
* @param obj the Object to check
* @return the passed in Object's toString, or blank if it was
- * <code>null</code>
+ * <code>null</code>
*/
public static String defaultString( Object obj )
{
@@ -1913,11 +1900,11 @@ public class StringUtils
* or, if the <code>Object</code> is <code>null</code>, a passed
* in default String.</p>
*
- * @param obj the Object to check
- * @param defaultString the default String to return if str is
- * <code>null</code>
+ * @param obj the Object to check
+ * @param defaultString the default String to return if str is
+ * <code>null</code>
* @return the passed in string, or the default if it was
- * <code>null</code>
+ * <code>null</code>
*/
public static String defaultString( Object obj, String defaultString )
{
@@ -1929,7 +1916,7 @@ public class StringUtils
/**
* <p>Reverse a String.</p>
- *
+ * <p/>
* <p><code>null</code> String returns <code>null</code>.</p>
*
* @param str the String to reverse
@@ -1946,12 +1933,12 @@ public class StringUtils
/**
* <p>Reverses a String that is delimited by a specific character.</p>
- *
+ * <p/>
* <p>The Strings between the delimiters are not reversed.
* Thus java.lang.String becomes String.lang.java (if the delimiter
* is <code>'.'</code>).</p>
*
- * @param str the String to reverse
+ * @param str the String to reverse
* @param delimiter the delimiter to use
* @return the reversed String
*/
@@ -1966,10 +1953,10 @@ public class StringUtils
/**
* <p>Reverses an array.</p>
- *
+ * <p/>
* <p>TAKEN FROM CollectionsUtils.</p>
*
- * @param array the array to reverse
+ * @param array the array to reverse
*/
private static void reverseArray( Object[] array )
{
@@ -1992,16 +1979,16 @@ public class StringUtils
/**
* Turn "Now is the time for all good men" into "Now is the time for..."
- * <p>
+ * <p/>
* Specifically:
- * <p>
+ * <p/>
* If str is less than max characters long, return it.
* 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 maxWidth maximum length of result string
- **/
+ */
public static String abbreviate( String s, int maxWidth )
{
return abbreviate( s, 0, maxWidth );
@@ -2009,16 +1996,16 @@ public class StringUtils
/**
* Turn "Now is the time for all good men" into "...is the time for..."
- * <p>
+ * <p/>
* Works like abbreviate(String, int), but allows you to specify a "left edge"
* offset. Note that this left edge is not necessarily going to be the leftmost
* character in the result, or the first
* character following the ellipses, but it will appear somewhere in the result.
* In no case will it return a string of length greater than maxWidth.
*
- * @param offset left edge of source string
+ * @param offset left edge of source string
* @param maxWidth maximum length of result string
- **/
+ */
public static String abbreviate( String s, int offset, int maxWidth )
{
if ( maxWidth < 4 )
@@ -2059,11 +2046,11 @@ public class StringUtils
* Compare two strings, and return the portion where they differ.
* (More precisely, return the remainder of the second string,
* starting from where it's different from the first.)
- * <p>
+ * <p/>
* E.g. strdiff("i am a machine", "i am a robot") -> "robot"
*
* @return the portion of s2 where it differs from s1; returns the empty string ("") if they are equal
- **/
+ */
public static String difference( String s1, String s2 )
{
int at = differenceAt( s1, s2 );
@@ -2081,7 +2068,7 @@ public class StringUtils
* </p>
*
* @return the index where s2 and s1 begin to differ; -1 if they are equal
- **/
+ */
public static int differenceAt( String s1, String s2 )
{
int i;
@@ -2171,11 +2158,12 @@ public class StringUtils
/**
* Convert the first character of the given String to uppercase.
* This method will <i>not</i> trim of spaces!
- *
+ * <p/>
* <p>
- * <b>Attention:</b> this method will currently throw a
- * <code>IndexOutOfBoundsException</code> for empty strings!
+ * <b>Attention:</b> this method will currently throw a
+ * <code>IndexOutOfBoundsException</code> for empty strings!
* </p>
+ *
* @param data the String to get capitalized
* @return data string with the first character transformed to uppercase
* @throws NullPointerException if data is <code>null</code>
@@ -2192,11 +2180,12 @@ public class StringUtils
/**
* Convert the first character of the given String to lowercase.
* This method will <i>not</i> trim of spaces!
- *
+ * <p/>
* <p>
- * <b>Attention:</b> this method will currently throw a
- * <code>IndexOutOfBoundsException</code> for empty strings!
+ * <b>Attention:</b> this method will currently throw a
+ * <code>IndexOutOfBoundsException</code> for empty strings!
* </p>
+ *
* @param data the String to get it's first character lower-cased.
* @return data string with the first character transformed to lowercase
* @throws NullPointerException if data is <code>null</code>
@@ -2237,7 +2226,7 @@ public class StringUtils
/**
* <p>Quote and escape a String with the given character, handling <code>null</code>.</p>
- *
+ * <p/>
* <pre>
* StringUtils.quoteAndEscape(null, *) = null
* StringUtils.quoteAndEscape("", *) = ""
@@ -2250,11 +2239,10 @@ public class StringUtils
* @param quoteChar
* @return the String quoted and escaped
* @see #quoteAndEscape(String, char, char[], char[], char, boolean)
- * @since 1.5.1
* @see #quoteAndEscape(String, char, char[], char[], char, boolean)
+ * @since 1.5.1
*/
- public static String quoteAndEscape( String source,
- char quoteChar )
+ public static String quoteAndEscape( String source, char quoteChar )
{
return quoteAndEscape( source, quoteChar, new char[]{ quoteChar }, new char[]{ ' ' }, '\\', false );
}
@@ -2269,9 +2257,7 @@ public class StringUtils
* @see #quoteAndEscape(String, char, char[], char[], char, boolean)
* @since 1.5.1
*/
- public static String quoteAndEscape( String source,
- char quoteChar,
- char[] quotingTriggers )
+ public static String quoteAndEscape( String source, char quoteChar, char[] quotingTriggers )
{
return quoteAndEscape( source, quoteChar, new char[]{ quoteChar }, quotingTriggers, '\\', false );
}
@@ -2286,10 +2272,7 @@ public class StringUtils
* @see #quoteAndEscape(String, char, char[], char[], char, boolean)
* @since 1.5.1
*/
- public static String quoteAndEscape( String source,
- char quoteChar,
- final char[] escapedChars,
- char escapeChar,
+ public static String quoteAndEscape( String source, char quoteChar, final char[] escapedChars, char escapeChar,
boolean force )
{
return quoteAndEscape( source, quoteChar, escapedChars, new char[]{ ' ' }, escapeChar, force );
@@ -2305,20 +2288,16 @@ public class StringUtils
* @return the String quoted and escaped
* @since 1.5.1
*/
- public static String quoteAndEscape( String source,
- char quoteChar,
- final char[] escapedChars,
- final char[] quotingTriggers,
- char escapeChar,
- boolean force )
+ public static String quoteAndEscape( String source, char quoteChar, final char[] escapedChars,
+ final char[] quotingTriggers, char escapeChar, boolean force )
{
if ( source == null )
{
return null;
}
- if ( !force && source.startsWith( Character.toString( quoteChar ) )
- && source.endsWith( Character.toString( quoteChar ) ) )
+ if ( !force && source.startsWith( Character.toString( quoteChar ) ) && source.endsWith(
+ Character.toString( quoteChar ) ) )
{
return source;
}
@@ -2368,7 +2347,7 @@ public class StringUtils
return null;
}
- char[] eqc = new char[ escapedChars.length ];
+ char[] eqc = new char[escapedChars.length];
System.arraycopy( escapedChars, 0, eqc, 0, escapedChars.length );
Arrays.sort( eqc );
@@ -2399,13 +2378,15 @@ public class StringUtils
*/
public static String removeDuplicateWhitespace( String s )
{
- StringBuffer result = new StringBuffer( );
+ StringBuffer result = new StringBuffer();
int length = s.length();
boolean isPreviousWhiteSpace = false;
- for (int i = 0; i < length; i++){
+ for ( int i = 0; i < length; i++ )
+ {
char c = s.charAt( i );
boolean thisCharWhiteSpace = Character.isWhitespace( c );
- if (!(isPreviousWhiteSpace && thisCharWhiteSpace)){
+ if ( !( isPreviousWhiteSpace && thisCharWhiteSpace ) )
+ {
result.append( c );
}
isPreviousWhiteSpace = thisCharWhiteSpace;
@@ -2431,7 +2412,7 @@ public class StringUtils
* Parses the given String and replaces all occurrences of
* '\n', '\r' and '\r\n' with the system line separator.
*
- * @param s a not null String
+ * @param s a not null String
* @param ls the wanted line separator ("\n" on UNIX), if null using the System line separator.
* @return a String that contains only System line separators.
* @throws IllegalArgumentException if ls is not '\n', '\r' and '\r\n' characters.
@@ -2484,9 +2465,9 @@ public class StringUtils
/**
* <p>Checks if String contains a search character, handling <code>null</code>.
* This method uses {@link String#indexOf(int)}.</p>
- *
+ * <p/>
* <p>A <code>null</code> or empty ("") String will return <code>false</code>.</p>
- *
+ * <p/>
* <pre>
* StringUtils.contains(null, *) = false
* StringUtils.contains("", *) = false
@@ -2494,10 +2475,10 @@ public class StringUtils
* StringUtils.contains("abc", 'z') = false
* </pre>
*
- * @param str the String to check, may be null
- * @param searchChar the character to find
+ * @param str the String to check, may be null
+ * @param searchChar the character to find
* @return true if the String contains the search character,
- * false if not or <code>null</code> string input
+ * false if not or <code>null</code> string input
* @since 1.5.7
*/
public static boolean contains( String str, char searchChar )
@@ -2512,9 +2493,9 @@ public class StringUtils
/**
* <p>Checks if String contains a search String, handling <code>null</code>.
* This method uses {@link String#indexOf(int)}.</p>
- *
+ * <p/>
* <p>A <code>null</code> String will return <code>false</code>.</p>
- *
+ * <p/>
* <pre>
* StringUtils.contains(null, *) = false
* StringUtils.contains(*, null) = false
@@ -2524,10 +2505,10 @@ public class StringUtils
* StringUtils.contains("abc", "z") = false
* </pre>
*
- * @param str the String to check, may be null
- * @param searchStr the String to find, may be null
+ * @param str the String to check, may be null
+ * @param searchStr the String to find, may be null
* @return true if the String contains the search String,
- * false if not or <code>null</code> string input
+ * false if not or <code>null</code> string input
* @since 1.5.7
*/
public static boolean contains( String str, String searchStr )
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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -18,9 +18,12 @@ import java.util.concurrent.Callable;
/**
* Callable wrapper that exposes the proper exeception type to the client.
+ *
* @author Kristian Rosenvold
*/
-public interface CommandLineCallable extends Callable<Integer>
+public interface CommandLineCallable
+ extends Callable<Integer>
{
- public Integer call() throws CommandLineException;
+ public Integer call()
+ throws CommandLineException;
}
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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -20,10 +20,9 @@ package org.apache.maven.shared.utils.cl
*/
/**
- *
* @author Olivier Lamy
- * @since 1.5.9
* @version $Id$
+ * @since 1.5.9
*/
public class CommandLineTimeOutException
extends CommandLineException
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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -24,10 +24,6 @@ package org.apache.maven.shared.utils.cl
* SOFTWARE.
*/
-import org.apache.maven.shared.utils.Os;
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -42,6 +38,9 @@ import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
+import org.apache.maven.shared.utils.Os;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.io.IOUtil;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl </a>
@@ -52,6 +51,7 @@ public abstract class CommandLineUtils
/**
* Sixteen-bit Unicode Transformation Format, little-endian byte order.
* Every implementation of the Java platform is required to support this character encoding.
+ *
* @see java.nio.charset.Charset
*/
public static final String UTF_16LE = "UTF-16LE";
@@ -75,14 +75,16 @@ public abstract class CommandLineUtils
}
}
- private static class ProcessHook extends Thread {
+ private static class ProcessHook
+ extends Thread
+ {
private final Process process;
private ProcessHook( Process process )
{
- super("CommandlineUtils process shutdown hook");
+ super( "CommandlineUtils process shutdown hook" );
this.process = process;
- this.setContextClassLoader( null );
+ this.setContextClassLoader( null );
}
public void run()
@@ -133,6 +135,7 @@ public abstract class CommandLineUtils
/**
* Immediately forks a process, returns a callable that will block until process is complete.
+ *
* @param cl The command line to execute
* @param systemIn The input to read from, must be thread safe
* @param systemOut A consumer that receives output, must be thread safe
@@ -145,9 +148,9 @@ public abstract class CommandLineUtils
* @noinspection ThrowableResultOfMethodCallIgnored
*/
public static CommandLineCallable executeCommandLineAsCallable( final Commandline cl, final InputStream systemIn,
- final StreamConsumer systemOut,
- final StreamConsumer systemErr,
- final int timeoutInSeconds )
+ final StreamConsumer systemOut,
+ final StreamConsumer systemErr,
+ final int timeoutInSeconds )
throws CommandLineException
{
if ( cl == null )
@@ -157,8 +160,7 @@ public abstract class CommandLineUtils
final Process p = cl.execute();
- final StreamFeeder inputFeeder = systemIn != null ?
- new StreamFeeder( systemIn, p.getOutputStream() ) : null;
+ final StreamFeeder inputFeeder = systemIn != null ? new StreamFeeder( systemIn, p.getOutputStream() ) : null;
final StreamPumper outputPumper = new StreamPumper( p.getInputStream(), systemOut );
@@ -209,7 +211,8 @@ public abstract class CommandLineUtils
}
if ( isAlive( p ) )
{
- throw new InterruptedException( "Process timeout out after " + timeoutInSeconds + " seconds" );
+ throw new InterruptedException(
+ "Process timeout out after " + timeoutInSeconds + " seconds" );
}
returnValue = p.exitValue();
@@ -238,7 +241,8 @@ public abstract class CommandLineUtils
outputPumper.disable();
errorPumper.disable();
- throw new CommandLineTimeOutException( "Error while executing external command, process killed.", ex );
+ throw new CommandLineTimeOutException( "Error while executing external command, process killed.",
+ ex );
}
finally
{
@@ -344,7 +348,7 @@ public abstract class CommandLineUtils
Runtime r = Runtime.getRuntime();
- //If this is windows set the shell to command.com or cmd.exe with correct arguments.
+ //If this is windows set the shell to command.com or cmd.exe with correct arguments.
boolean overriddenEncoding = false;
if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
{
@@ -550,9 +554,9 @@ public abstract class CommandLineUtils
@SuppressWarnings( { "JavaDoc", "UnusedDeclaration", "deprecation" } )
public static String quote( String argument, boolean wrapExistingQuotes )
throws CommandLineException
- {
+ {
return quote( argument, false, false, wrapExistingQuotes );
- }
+ }
/**
* @deprecated Use {@link StringUtils#quoteAndEscape(String, char, char[], char[], char, boolean)},
@@ -640,7 +644,7 @@ public abstract class CommandLineUtils
{
try
{
- return System.class.getMethod( "getenv");
+ return System.class.getMethod( "getenv" );
}
catch ( NoSuchMethodException e )
{
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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -78,13 +78,6 @@ package org.apache.maven.shared.utils.cl
* ====================================================================
*/
-import org.apache.maven.shared.utils.Os;
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.cli.shell.BourneShell;
-import org.apache.maven.shared.utils.cli.shell.CommandShell;
-import org.apache.maven.shared.utils.cli.shell.CmdShell;
-import org.apache.maven.shared.utils.cli.shell.Shell;
-
import java.io.File;
import java.io.IOException;
import java.util.Collections;
@@ -93,6 +86,12 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Vector;
+import org.apache.maven.shared.utils.Os;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.cli.shell.BourneShell;
+import org.apache.maven.shared.utils.cli.shell.CmdShell;
+import org.apache.maven.shared.utils.cli.shell.CommandShell;
+import org.apache.maven.shared.utils.cli.shell.Shell;
/**
* <p/>
@@ -123,7 +122,7 @@ import java.util.Vector;
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class Commandline
- implements Cloneable
+ implements Cloneable
{
protected Vector arguments = new Vector();
@@ -142,7 +141,7 @@ public class Commandline
/**
* @deprecated Use {@link Commandline#setWorkingDirectory(File)} or
- * {@link Commandline#setWorkingDirectory(String)} instead.
+ * {@link Commandline#setWorkingDirectory(String)} instead.
*/
private File workingDir;
@@ -381,7 +380,7 @@ public class Commandline
* Adds an argument object to our list of args.
*
* @return the argument object.
- * @see #addArg(Arg,boolean)
+ * @see #addArg(Arg, boolean)
*/
public void addArg( Arg argument )
{
@@ -448,7 +447,7 @@ public class Commandline
* Add system environment variables
*/
public void addSystemEnvironment()
- throws Exception
+ throws Exception
{
Properties systemEnvVars = CommandLineUtils.getSystemEnvVars();
@@ -466,7 +465,7 @@ public class Commandline
* Return the list of environment variables
*/
public String[] getEnvironmentVariables()
- throws CommandLineException
+ throws CommandLineException
{
try
{
@@ -627,7 +626,7 @@ public class Commandline
* Executes the command.
*/
public Process execute()
- throws CommandLineException
+ throws CommandLineException
{
// TODO: Provided only for backward compat. with <= 1.4
verifyShellState();
@@ -650,13 +649,13 @@ public class Commandline
{
if ( !workingDir.exists() )
{
- throw new CommandLineException( "Working directory \"" + workingDir.getPath()
- + "\" does not exist!" );
+ throw new CommandLineException(
+ "Working directory \"" + workingDir.getPath() + "\" does not exist!" );
}
else if ( !workingDir.isDirectory() )
{
- throw new CommandLineException( "Path \"" + workingDir.getPath()
- + "\" does not specify a directory." );
+ throw new CommandLineException(
+ "Path \"" + workingDir.getPath() + "\" does not specify a directory." );
}
process = Runtime.getRuntime().exec( getShellCommandline(), environment, workingDir );
@@ -687,7 +686,7 @@ public class Commandline
}
public Properties getSystemEnvVars()
- throws Exception
+ throws Exception
{
return CommandLineUtils.getSystemEnvVars();
}
@@ -717,7 +716,7 @@ public class Commandline
* @deprecated Use {@link CommandLineUtils#translateCommandline(String)} instead.
*/
public static String[] translateCommandline( String toProcess )
- throws Exception
+ throws Exception
{
return CommandLineUtils.translateCommandline( toProcess );
}
@@ -726,7 +725,7 @@ public class Commandline
* @deprecated Use {@link CommandLineUtils#quote(String)} instead.
*/
public static String quoteArgument( String argument )
- throws CommandLineException
+ throws CommandLineException
{
return CommandLineUtils.quote( argument );
}
@@ -740,7 +739,7 @@ public class Commandline
}
public static class Argument
- implements Arg
+ implements Arg
{
private String[] parts;
@@ -751,7 +750,7 @@ public class Commandline
{
if ( value != null )
{
- parts = new String[] { value };
+ parts = new String[]{ value };
}
}
@@ -779,7 +778,7 @@ public class Commandline
*/
public void setFile( File value )
{
- parts = new String[] { value.getAbsolutePath() };
+ parts = new String[]{ value.getAbsolutePath() };
}
/* (non-Javadoc)
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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -65,7 +65,7 @@ package org.apache.maven.shared.utils.cl
* Works in concert with the StreamPumper class to
* allow implementations to gain access to the lines being
* "Pumped".
- *
+ * <p/>
* Please note that implementations of this interface can be expected to be
* called from arbitrary threads and must therefore be threadsafe.
*
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java Mon Oct 1 20:06:11 2012
@@ -34,7 +34,9 @@ import java.io.OutputStream;
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class StreamFeeder extends AbstractStreamHandler {
+public class StreamFeeder
+ extends AbstractStreamHandler
+{
private InputStream input;
private OutputStream output;
@@ -126,7 +128,7 @@ public class StreamFeeder extends Abstra
// ----------------------------------------------------------------------
private void feed()
- throws IOException
+ throws IOException
{
int data = input.read();
@@ -134,7 +136,7 @@ public class StreamFeeder extends Abstra
{
synchronized ( output )
{
- if ( !isDisabled())
+ if ( !isDisabled() )
{
output.write( data );
}
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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -78,13 +78,12 @@ package org.apache.maven.shared.utils.cl
* ====================================================================
*/
-import org.apache.maven.shared.utils.io.IOUtil;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import org.apache.maven.shared.utils.io.IOUtil;
/**
* Class to pump the error stream during Process's runtime. Copied from the Ant
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/BourneShell.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/BourneShell.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/BourneShell.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/BourneShell.java Mon Oct 1 20:06:11 2012
@@ -20,11 +20,10 @@ package org.apache.maven.shared.utils.cl
*/
-import org.apache.maven.shared.utils.Os;
-import org.apache.maven.shared.utils.StringUtils;
-
import java.util.ArrayList;
import java.util.List;
+import org.apache.maven.shared.utils.Os;
+import org.apache.maven.shared.utils.StringUtils;
/**
* @author Jason van Zyl
@@ -32,23 +31,8 @@ import java.util.List;
public class BourneShell
extends Shell
{
- private static final char[] BASH_QUOTING_TRIGGER_CHARS = {
- ' ',
- '$',
- ';',
- '&',
- '|',
- '<',
- '>',
- '*',
- '?',
- '(',
- ')',
- '[',
- ']',
- '{',
- '}',
- '`' };
+ private static final char[] BASH_QUOTING_TRIGGER_CHARS =
+ { ' ', '$', ';', '&', '|', '<', '>', '*', '?', '(', ')', '[', ']', '{', '}', '`' };
public BourneShell()
{
@@ -70,7 +54,9 @@ public class BourneShell
}
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getExecutable()
{
if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
@@ -78,7 +64,7 @@ public class BourneShell
return super.getExecutable();
}
- return unifyQuotes( super.getExecutable());
+ return unifyQuotes( super.getExecutable() );
}
public List<String> getShellArgsList()
@@ -141,7 +127,7 @@ public class BourneShell
/**
* <p>Unify quotes in a path for the Bourne Shell.</p>
- *
+ * <p/>
* <pre>
* BourneShell.unifyQuotes(null) = null
* BourneShell.unifyQuotes("") = (empty)
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CmdShell.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CmdShell.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CmdShell.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CmdShell.java Mon Oct 1 20:06:11 2012
@@ -39,7 +39,7 @@ public class CmdShell
{
setShellCommand( "cmd.exe" );
setQuotedExecutableEnabled( true );
- setShellArgs( new String[]{"/X", "/C"} );
+ setShellArgs( new String[]{ "/X", "/C" } );
}
/**
@@ -52,7 +52,7 @@ public class CmdShell
* <p>
* From cmd.exe /? output:
* </p>
- *
+ * <p/>
* <pre>
* If /C or /K is specified, then the remainder of the command line after
* the switch is processed as a command line, where the following logic is
@@ -75,8 +75,8 @@ public class CmdShell
* remove the last quote character on the command line, preserving
* any text after the last quote character.
* </pre>
- *
- *<p>
+ * <p/>
+ * <p>
* Always quoting the entire command line, regardless of these conditions
* appears to make Windows processes invoke successfully.
* </p>
@@ -88,7 +88,7 @@ public class CmdShell
sb.append( super.getCommandLine( executable, arguments ).get( 0 ) );
sb.append( "\"" );
- return Arrays.asList( new String[]{sb.toString()} );
+ return Arrays.asList( new String[]{ sb.toString() } );
}
}
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CommandShell.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CommandShell.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CommandShell.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/shell/CommandShell.java Mon Oct 1 20:06:11 2012
@@ -34,7 +34,7 @@ public class CommandShell
public CommandShell()
{
setShellCommand( "command.com" );
- setShellArgs( new String[]{"/C"} );
+ setShellArgs( new String[]{ "/C" } );
}
}
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=1392562&r1=1392561&r2=1392562&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 Mon Oct 1 20:06:11 2012
@@ -20,13 +20,11 @@ package org.apache.maven.shared.utils.cl
*/
-
-import org.apache.maven.shared.utils.StringUtils;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.maven.shared.utils.StringUtils;
/**
* <p>
@@ -112,7 +110,7 @@ public class Shell
if ( ( shellArgs == null ) || shellArgs.isEmpty() )
{
return null;
- }
+ }
else
{
return (String[]) shellArgs.toArray( new String[shellArgs.size()] );
@@ -132,12 +130,12 @@ public class Shell
}
protected List<String> getRawCommandLine( String executable, String[] arguments )
- {
+ {
List<String> commandLine = new ArrayList<String>();
- StringBuffer sb = new StringBuffer();
+ StringBuffer sb = new StringBuffer();
- if ( executable != null )
- {
+ if ( executable != null )
+ {
String preamble = getExecutionPreamble();
if ( preamble != null )
{
@@ -146,17 +144,19 @@ public class Shell
if ( isQuotedExecutableEnabled() )
{
- char[] escapeChars = getEscapeChars( isSingleQuotedExecutableEscaped(), isDoubleQuotedExecutableEscaped() );
+ char[] escapeChars =
+ getEscapeChars( isSingleQuotedExecutableEscaped(), isDoubleQuotedExecutableEscaped() );
- sb.append( StringUtils.quoteAndEscape( getExecutable(), getExecutableQuoteDelimiter(), escapeChars, getQuotingTriggerChars(), '\\', false ) );
+ sb.append( StringUtils.quoteAndEscape( getExecutable(), getExecutableQuoteDelimiter(), escapeChars,
+ getQuotingTriggerChars(), '\\', false ) );
}
else
{
sb.append( getExecutable() );
}
}
- for ( int i = 0; i < arguments.length; i++ )
- {
+ for ( int i = 0; i < arguments.length; i++ )
+ {
if ( sb.length() > 0 )
{
sb.append( " " );
@@ -164,14 +164,16 @@ public class Shell
if ( isQuotedArgumentsEnabled() )
{
- char[] escapeChars = getEscapeChars( isSingleQuotedExecutableEscaped(), isDoubleQuotedExecutableEscaped() );
+ char[] escapeChars =
+ getEscapeChars( isSingleQuotedExecutableEscaped(), isDoubleQuotedExecutableEscaped() );
- sb.append( StringUtils.quoteAndEscape( arguments[i], getArgumentQuoteDelimiter(), escapeChars, getQuotingTriggerChars(), '\\', false ) );
- }
+ sb.append( StringUtils.quoteAndEscape( arguments[i], getArgumentQuoteDelimiter(), escapeChars,
+ getQuotingTriggerChars(), '\\', false ) );
+ }
else
- {
+ {
sb.append( arguments[i] );
- }
+ }
}
commandLine.add( sb.toString() );
@@ -252,7 +254,7 @@ public class Shell
* Get the full command line to execute, including shell command, shell arguments,
* executable and executable arguments
*
- * @param arguments arguments for the executable, not the shell
+ * @param arguments arguments for the executable, not the shell
* @return List of String objects, whose array version is suitable to be used as argument
* of Runtime.getRuntime().exec()
*/
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/ClassMap.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/ClassMap.java?rev=1392562&r1=1392561&r2=1392562&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/ClassMap.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/introspection/ClassMap.java Mon Oct 1 20:06:11 2012
@@ -39,6 +39,7 @@ public class ClassMap
}
private static final CacheMiss CACHE_MISS = new CacheMiss();
+
private static final Object OBJECT = new Object();
/**
@@ -100,8 +101,7 @@ public class ClassMap
{
try
{
- cacheEntry = methodMap.find( name,
- params );
+ cacheEntry = methodMap.find( name, params );
}
catch ( MethodMap.AmbiguousException ae )
{
@@ -109,21 +109,18 @@ public class ClassMap
* that's a miss :)
*/
- methodCache.put( methodKey,
- CACHE_MISS );
+ methodCache.put( methodKey, CACHE_MISS );
throw ae;
}
if ( cacheEntry == null )
{
- methodCache.put( methodKey,
- CACHE_MISS );
+ methodCache.put( methodKey, CACHE_MISS );
}
else
{
- methodCache.put( methodKey,
- cacheEntry );
+ methodCache.put( methodKey, cacheEntry );
}
}
@@ -200,21 +197,37 @@ public class ClassMap
if ( parameterTypes[j].isPrimitive() )
{
if ( parameterTypes[j].equals( Boolean.TYPE ) )
+ {
methodKey.append( "java.lang.Boolean" );
+ }
else if ( parameterTypes[j].equals( Byte.TYPE ) )
+ {
methodKey.append( "java.lang.Byte" );
+ }
else if ( parameterTypes[j].equals( Character.TYPE ) )
+ {
methodKey.append( "java.lang.Character" );
+ }
else if ( parameterTypes[j].equals( Double.TYPE ) )
+ {
methodKey.append( "java.lang.Double" );
+ }
else if ( parameterTypes[j].equals( Float.TYPE ) )
+ {
methodKey.append( "java.lang.Float" );
+ }
else if ( parameterTypes[j].equals( Integer.TYPE ) )
+ {
methodKey.append( "java.lang.Integer" );
+ }
else if ( parameterTypes[j].equals( Long.TYPE ) )
+ {
methodKey.append( "java.lang.Long" );
+ }
else if ( parameterTypes[j].equals( Short.TYPE ) )
+ {
methodKey.append( "java.lang.Short" );
+ }
}
else
{
@@ -457,7 +470,6 @@ public class ClassMap
* try the superclass
*/
-
Class superclazz = clazz.getSuperclass();
if ( superclazz != null )
@@ -495,8 +507,11 @@ public class ClassMap
private static final class MethodInfo
{
Method method;
+
String name;
+
Class[] parameterTypes;
+
boolean upcast;
MethodInfo( Method method )