Author: kiwiwings
Date: Thu Mar 10 00:20:34 2016
New Revision: 1734337
URL: http://svn.apache.org/viewvc?rev=1734337&view=rev
Log:
sonar fixes
Modified:
poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java
poi/trunk/src/java/org/apache/poi/util/StringUtil.java
poi/trunk/src/testcases/org/apache/poi/util/TestStringUtil.java
Modified:
poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java?rev=1734337&r1=1734336&r2=1734337&view=diff
==============================================================================
---
poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java
(original)
+++
poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java
Thu Mar 10 00:20:34 2016
@@ -129,8 +129,7 @@ public class FromHowTo {
}
}
- public void characters(char[] ch, int start, int length)
- throws SAXException {
+ public void characters(char[] ch, int start, int length) throws
SAXException { // NOSONAR
lastContents += new String(ch, start, length);
}
}
Modified: poi/trunk/src/java/org/apache/poi/util/StringUtil.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/StringUtil.java?rev=1734337&r1=1734336&r2=1734337&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/StringUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/StringUtil.java Thu Mar 10 00:20:34
2016
@@ -294,13 +294,11 @@ public class StringUtil {
* An Iterator over an array of Strings.
*/
public static class StringsIterator implements Iterator<String> {
- private String[] strings;
+ private String[] strings = {};
private int position = 0;
public StringsIterator(String[] strings) {
- if(strings != null) {
- this.strings = strings;
- } else {
- this.strings = new String[0];
+ if (strings != null) {
+ this.strings = strings.clone();
}
}
@@ -309,8 +307,9 @@ public class StringUtil {
}
public String next() {
int ourPos = position++;
- if(ourPos >= strings.length)
+ if(ourPos >= strings.length) {
throw new ArrayIndexOutOfBoundsException(ourPos);
+ }
return strings[ourPos];
}
public void remove() {}
Modified: poi/trunk/src/testcases/org/apache/poi/util/TestStringUtil.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestStringUtil.java?rev=1734337&r1=1734336&r2=1734337&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/TestStringUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/util/TestStringUtil.java Thu Mar 10
00:20:34 2016
@@ -17,24 +17,25 @@
package org.apache.poi.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.nio.charset.Charset;
import org.apache.poi.util.StringUtil.StringsIterator;
-
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Unit test for StringUtil
- *
- * @author Marc Johnson (mjohnson at apache dot org
- * @author Glen Stampoultzis (glens at apache.org)
- * @author Sergei Kozello (sergeikozello at mail.ru)
*/
-public final class TestStringUtil extends TestCase {
+public class TestStringUtil {
/**
* test getFromUnicodeHigh for symbols with code below and more 127
*/
+ @Test
public void testGetFromUnicodeHighSymbolsWithCodesMoreThan127() {
byte[] test_data = new byte[]{0x22, 0x04,
0x35, 0x04,
@@ -52,6 +53,7 @@ public final class TestStringUtil extend
StringUtil.getFromUnicodeLE( test_data ) );
}
+ @Test
public void testPutCompressedUnicode() {
byte[] output = new byte[100];
byte[] expected_output =
@@ -87,6 +89,7 @@ public final class TestStringUtil extend
}
}
+ @Test
public void testPutUncompressedUnicode() {
byte[] output = new byte[100];
String input = "Hello World";
@@ -124,6 +127,7 @@ public final class TestStringUtil extend
}
}
+ @Test
public void testStringsIterator() {
StringsIterator i;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]