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/28 15:48:42 UTC
svn commit: r1403004 - in /maven/shared/trunk/maven-shared-utils/src:
main/java/org/apache/maven/shared/utils/xml/XmlWriterUtil.java
test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java
Author: krosenvold
Date: Sun Oct 28 14:48:42 2012
New Revision: 1403004
URL: http://svn.apache.org/viewvc?rev=1403004&view=rev
Log:
Modernized to java5
Modified:
maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlWriterUtil.java
maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlWriterUtil.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlWriterUtil.java?rev=1403004&r1=1403003&r2=1403004&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlWriterUtil.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/xml/XmlWriterUtil.java Sun Oct 28 14:48:42 2012
@@ -66,7 +66,7 @@ public class XmlWriterUtil
* Convenience method to repeat <code>CRLF</code> and to indent the writer by <code>2</code>.
*
* @param writer not null
- * @param repeat
+ * @param repeat The number of repetitions of the indent
* @param indent positive number
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeLineBreak(XMLWriter, int, int, int)
@@ -80,7 +80,7 @@ public class XmlWriterUtil
* Convenience method to repeat <code>CRLF</code> and to indent the writer by <code>indentSize</code>.
*
* @param writer not null
- * @param repeat
+ * @param repeat The number of repetitions of the indent
* @param indent positive number
* @param indentSize positive number
*/
@@ -133,7 +133,7 @@ public class XmlWriterUtil
* Convenience method to write XML comment line. The <code>comment</code> is splitted to have a size of <code>80</code>.
*
* @param writer not null
- * @param comment
+ * @param comment The comment to write
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeComment(XMLWriter, String, int, int)
*/
@@ -147,7 +147,7 @@ public class XmlWriterUtil
* and is indented by <code>indent</code> using <code>2</code> as indentation size.
*
* @param writer not null
- * @param comment
+ * @param comment The comment to write
* @param indent positive number
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeComment(XMLWriter, String, int, int)
@@ -162,7 +162,7 @@ public class XmlWriterUtil
* and is indented by <code>indent</code> using <code>indentSize</code>.
*
* @param writer not null
- * @param comment
+ * @param comment The comment to write
* @param indent positive number
* @param indentSize positive number
* @see #DEFAULT_COLUMN_LINE
@@ -177,7 +177,7 @@ public class XmlWriterUtil
* and is indented by <code>indent</code> using <code>indentSize</code>.
*
* @param writer not null
- * @param comment
+ * @param comment The comment to write
* @param indent positive number
* @param indentSize positive number
* @param columnSize positive number
@@ -209,17 +209,16 @@ public class XmlWriterUtil
String[] sentences = StringUtils.split( comment, LS );
StringBuffer line = new StringBuffer( indentation + "<!-- " );
- for ( int i = 0; i < sentences.length; i++ )
+ for ( String sentence : sentences )
{
- String sentence = sentences[i];
String[] words = StringUtils.split( sentence, " " );
- for ( int j = 0; j < words.length; j++ )
+ for ( String word : words )
{
- StringBuffer sentenceTmp = new StringBuffer( line.toString() );
- sentenceTmp.append( words[j] ).append( ' ' );
+ StringBuilder sentenceTmp = new StringBuilder( line.toString() );
+ sentenceTmp.append( word ).append( ' ' );
if ( sentenceTmp.length() > magicNumber )
{
- if ( line.length() != indentation.length() + "<!-- ".length())
+ if ( line.length() != indentation.length() + "<!-- ".length() )
{
if ( magicNumber - line.length() > 0 )
{
@@ -230,11 +229,11 @@ public class XmlWriterUtil
writer.writeMarkup( line.toString() );
}
line = new StringBuffer( indentation + "<!-- " );
- line.append( words[j] ).append( ' ' );
+ line.append( word ).append( ' ' );
}
else
{
- line.append( words[j] ).append( ' ' );
+ line.append( word ).append( ' ' );
}
}
@@ -259,7 +258,7 @@ public class XmlWriterUtil
* The XML comment block is not indented.
*
* @param writer not null
- * @param comment
+ * @param comment The comment to write
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeCommentText(XMLWriter, String, int, int)
*/
@@ -274,7 +273,7 @@ public class XmlWriterUtil
* <code>2</code> as indentation size.
*
* @param writer not null
- * @param comment
+ * @param comment The comment to write
* @param indent positive number
* @see #DEFAULT_INDENTATION_SIZE
* @see #writeCommentText(XMLWriter, String, int, int)
@@ -289,7 +288,7 @@ public class XmlWriterUtil
* The XML comment block is also indented by <code>indent</code> using <code>indentSize</code>.
*
* @param writer not null
- * @param comment
+ * @param comment The comment to write
* @param indent positive number
* @param indentSize positive number
* @see #DEFAULT_COLUMN_LINE
@@ -306,7 +305,7 @@ public class XmlWriterUtil
* The column size could be also be specified.
*
* @param writer not null
- * @param comment
+ * @param comment The comment to write
* @param indent positive number
* @param indentSize positive number
* @param columnSize positive number
Modified: maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java?rev=1403004&r1=1403003&r2=1403004&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java (original)
+++ maven/shared/trunk/maven-shared-utils/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java Sun Oct 28 14:48:42 2012
@@ -128,7 +128,7 @@ public class XmlWriterUtilTest
{
XmlWriterUtil.writeCommentLineBreak( xmlWriter );
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( "<!-- ====================================================================== -->" ).append( XmlWriterUtil.LS );
assertEquals( output.toString(), sb.toString() );
assertTrue( output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() );
@@ -334,6 +334,7 @@ public class XmlWriterUtilTest
assertEquals( output.toString(), sb.toString() );
}
+
/**
* Test method for {@link org.apache.maven.shared.utils.xml.XmlWriterUtil#writeCommentText(XMLWriter, java.lang.String, int, int)}.
*
@@ -346,7 +347,7 @@ public class XmlWriterUtilTest
XmlWriterUtil.writeCommentText( xmlWriter, "hello", 2, 4 );
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( XmlWriterUtil.LS );
sb.append( indent ).append( "<!-- ====================================================================== -->" )
.append( XmlWriterUtil.LS );
@@ -372,7 +373,7 @@ public class XmlWriterUtilTest
XmlWriterUtil.writeCommentText( xmlWriter, "hello", 2, 4, 50 );
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( XmlWriterUtil.LS );
sb.append( indent ).append( "<!-- ======================================== -->" ).append( XmlWriterUtil.LS );
sb.append( indent ).append( "<!-- hello -->" ).append( XmlWriterUtil.LS );
@@ -393,7 +394,7 @@ public class XmlWriterUtilTest
{
XmlWriterUtil.writeComment( xmlWriter, null );
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( "<!-- null -->" ).append( XmlWriterUtil.LS );
assertEquals( output.toString(), sb.toString() );
}
@@ -408,7 +409,7 @@ public class XmlWriterUtilTest
{
XmlWriterUtil.writeComment( xmlWriter, "This is a short text" );
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( "<!-- This is a short text -->" ).append( XmlWriterUtil.LS );
assertEquals( output.toString(), sb.toString() );
}
@@ -425,7 +426,7 @@ public class XmlWriterUtilTest
+ "Based on the concept of a project object model (POM), Maven can manage a project's build, reporting "
+ "and documentation from a central piece of information." );
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append( "<!-- Maven is a software project management and comprehension tool. Based -->" ).append( XmlWriterUtil.LS );
sb.append( "<!-- on the concept of a project object model (POM), Maven can manage a -->" ).append( XmlWriterUtil.LS );
sb.append( "<!-- project's build, reporting and documentation from a central piece of -->" ).append( XmlWriterUtil.LS );