You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/10/09 00:29:43 UTC
svn commit: r823348 [4/4] - in /poi/trunk/src:
contrib/src/org/apache/poi/hssf/contrib/view/
contrib/src/org/apache/poi/ss/usermodel/contrib/
examples/src/org/apache/poi/hpsf/examples/ java/org/apache/poi/ddf/
java/org/apache/poi/hpsf/ java/org/apache/...
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java Thu Oct 8 22:29:41 2009
@@ -56,7 +56,7 @@
* the file 'functionMetadata.txt'. There are more than 300 built-in functions in Excel and the
* intention of this class is to make it easier to maintain the metadata, by extracting it from
* a reliable source.
- *
+ *
* @author Josh Micich
*/
public final class ExcelFileFormatDocFunctionExtractor {
@@ -65,10 +65,10 @@
/**
* For simplicity, the output file is strictly simple ASCII.
- * This method detects any unexpected characters.
+ * This method detects any unexpected characters.
*/
/* package */ static boolean isSimpleAscii(char c) {
-
+
if (c>=0x21 && c<=0x7E) {
// everything from '!' to '~' (includes letters, digits, punctuation
return true;
@@ -83,8 +83,8 @@
}
return false;
}
-
-
+
+
private static final class FunctionData {
// special characters from the ooo document
private static final int CHAR_ELLIPSIS_8230 = 8230;
@@ -148,7 +148,7 @@
return b ? "x" : "";
}
}
-
+
private static final class FunctionDataCollector {
private final Map _allFunctionsByIndex;
@@ -156,7 +156,7 @@
private final Set _groupFunctionIndexes;
private final Set _groupFunctionNames;
private final PrintStream _ps;
-
+
public FunctionDataCollector(PrintStream ps) {
_ps = ps;
_allFunctionsByIndex = new HashMap();
@@ -168,19 +168,19 @@
public void addFuntion(int funcIx, boolean hasFootnote, String funcName, int minParams, int maxParams,
String returnClass, String paramClasses, String volatileFlagStr) {
boolean isVolatile = volatileFlagStr.length() > 0;
-
- Integer funcIxKey = new Integer(funcIx);
+
+ Integer funcIxKey = Integer.valueOf(funcIx);
if(!_groupFunctionIndexes.add(funcIxKey)) {
throw new RuntimeException("Duplicate function index (" + funcIx + ")");
}
if(!_groupFunctionNames.add(funcName)) {
throw new RuntimeException("Duplicate function name '" + funcName + "'");
}
-
+
checkRedefinedFunction(hasFootnote, funcName, funcIxKey);
- FunctionData fd = new FunctionData(funcIx, hasFootnote, funcName,
+ FunctionData fd = new FunctionData(funcIx, hasFootnote, funcName,
minParams, maxParams, returnClass, paramClasses, isVolatile);
-
+
_allFunctionsByIndex.put(funcIxKey, fd);
_allFunctionsByName.put(funcName, fd);
}
@@ -195,7 +195,7 @@
fdPrev = (FunctionData) _allFunctionsByIndex.get(funcIxKey);
if(fdPrev != null) {
if(!fdPrev.hasFootnote() || !hasNote) {
- throw new RuntimeException("changing function ["
+ throw new RuntimeException("changing function ["
+ funcIxKey + "] definition without foot-note");
}
_allFunctionsByName.remove(fdPrev.getName());
@@ -204,10 +204,10 @@
fdPrev = (FunctionData) _allFunctionsByName.get(funcName);
if(fdPrev != null) {
if(!fdPrev.hasFootnote() || !hasNote) {
- throw new RuntimeException("changing function '"
+ throw new RuntimeException("changing function '"
+ funcName + "' definition without foot-note");
}
- _allFunctionsByIndex.remove(new Integer(fdPrev.getIndex()));
+ _allFunctionsByIndex.remove(Integer.valueOf(fdPrev.getIndex()));
}
}
@@ -217,7 +217,7 @@
_groupFunctionIndexes.clear();
_groupFunctionNames.clear();
Arrays.sort(keys);
-
+
_ps.println("# " + headingText);
for (int i = 0; i < keys.length; i++) {
FunctionData fd = (FunctionData) _allFunctionsByIndex.get(keys[i]);
@@ -225,25 +225,25 @@
}
}
}
-
+
/**
- * To avoid drag-in - parse XML using only JDK.
+ * To avoid drag-in - parse XML using only JDK.
*/
private static class EFFDocHandler implements ContentHandler {
private static final String[] HEADING_PATH_NAMES = {
- "office:document-content", "office:body", "office:text", "text:h",
+ "office:document-content", "office:body", "office:text", "text:h",
};
private static final String[] TABLE_BASE_PATH_NAMES = {
- "office:document-content", "office:body", "office:text", "table:table",
+ "office:document-content", "office:body", "office:text", "table:table",
};
private static final String[] TABLE_ROW_RELPATH_NAMES = {
- "table:table-row",
+ "table:table-row",
};
private static final String[] TABLE_CELL_RELPATH_NAMES = {
- "table:table-row", "table:table-cell", "text:p",
+ "table:table-row", "table:table-cell", "text:p",
};
// after May 2008 there was one more style applied to the footnotes
- private static final String[] NOTE_REF_RELPATH_NAMES_OLD = {
+ private static final String[] NOTE_REF_RELPATH_NAMES_OLD = {
"table:table-row", "table:table-cell", "text:p", "text:span", "text:note-ref",
};
private static final String[] NOTE_REF_RELPATH_NAMES = {
@@ -255,7 +255,7 @@
/** <code>true</code> only when parsing the target tables */
private boolean _isInsideTable;
- private final List _rowData;
+ private final List _rowData;
private final StringBuffer _textNodeBuffer;
private final List _rowNoteFlags;
private boolean _cellHasNote;
@@ -304,7 +304,7 @@
if(matchesPath(0, HEADING_PATH_NAMES)) {
_lastHeadingText = _textNodeBuffer.toString().trim();
_textNodeBuffer.setLength(0);
- }
+ }
if(_isInsideTable) {
if(matchesTargetPath()) {
_fdc.endTableGroup(_lastHeadingText);
@@ -350,7 +350,7 @@
String returnClass = cellData[i + 4];
String paramClasses = cellData[i + 5];
String volatileFlagStr = cellData[i + 6];
-
+
_fdc.addFuntion(funcIx, hasFootnote, funcName, minParams, maxParams, returnClass, paramClasses, volatileFlagStr);
}
private static int parseInt(String valStr) {
@@ -412,7 +412,7 @@
private static void extractFunctionData(FunctionDataCollector fdc, InputStream is) {
XMLReader xr;
-
+
try {
// First up, try the default one
xr = XMLReaderFactory.createXMLReader();
@@ -460,7 +460,7 @@
public void write(byte[] b, int off, int len) throws IOException {
for (int i = 0; i < len; i++) {
checkByte(b[i + off]);
-
+
}
_os.write(b, off, len);
}
@@ -483,7 +483,7 @@
} catch(UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
-
+
outputLicenseHeader(ps);
Class genClass = ExcelFileFormatDocFunctionExtractor.class;
ps.println("# Created by (" + genClass.getName() + ")");
@@ -504,7 +504,7 @@
throw new RuntimeException(e);
}
ps.close();
-
+
String canonicalOutputFileName;
try {
canonicalOutputFileName = outFile.getCanonicalPath();
@@ -554,7 +554,7 @@
InputStream is = new FileInputStream(f);
while(true) {
int bytesRead = is.read(buf);
- if(bytesRead<1) {
+ if(bytesRead<1) {
break;
}
m.update(buf, 0, bytesRead);
@@ -563,7 +563,7 @@
} catch (IOException e) {
throw new RuntimeException(e);
}
-
+
return "0x" + new BigInteger(1, m.digest()).toString(16);
}
@@ -585,7 +585,7 @@
OutputStream os = new FileOutputStream(result);
while(true) {
int bytesRead = is.read(buf);
- if(bytesRead<1) {
+ if(bytesRead<1) {
break;
}
os.write(buf, 0, bytesRead);
@@ -609,7 +609,7 @@
processFile(effDocFile, outFile);
return;
}
-
+
File tempEFFDocFile = downloadSourceFile();
processFile(tempEFFDocFile, outFile);
tempEFFDocFile.delete();
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java Thu Oct 8 22:29:41 2009
@@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -23,24 +23,24 @@
import java.util.List;
/**
- * Utility class to help test code verify that generated files do not differ from proof copies in
+ * Utility class to help test code verify that generated files do not differ from proof copies in
* any significant detail. Normally this task would be simple except for the presence of artifacts
- * in the file that change every time it is generated. Usually these volatile artifacts are
+ * in the file that change every time it is generated. Usually these volatile artifacts are
* time-stamps, user names, or other machine dependent parameters.
- *
+ *
* @author Josh Micich
*/
public final class StreamUtility {
/**
* Compares two streams with expected differences in specified regions. The streams are
- * expected to be of equal length and comparison is always byte for byte. That is -
- * differences can only involve exchanging each individual byte for another single byte.<br>
- * Both input streams are closed.
- *
- * @param allowableDifferenceRegions array of integer pairs: (offset, length).
+ * expected to be of equal length and comparison is always byte for byte. That is -
+ * differences can only involve exchanging each individual byte for another single byte.<br>
+ * Both input streams are closed.
+ *
+ * @param allowableDifferenceRegions array of integer pairs: (offset, length).
* Any differences encountered in these regions of the streams will be ignored
- * @return <code>null</code> if streams are identical, else the
+ * @return <code>null</code> if streams are identical, else the
* byte indexes of differing data. If streams were different lengths,
* the returned indexes will be -1 and the length of the shorter stream
*/
@@ -51,36 +51,36 @@
}
boolean success = false;
int[] result;
- try {
- result = diffInternal(isA, isB, allowableDifferenceRegions);
- success = true;
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- close(isA, success);
- close(isB, success);
- }
- return result;
+ try {
+ result = diffInternal(isA, isB, allowableDifferenceRegions);
+ success = true;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ close(isA, success);
+ close(isB, success);
+ }
+ return result;
}
/**
* @param success <code>false</code> if the outer method is throwing an exception.
*/
- private static void close(InputStream is, boolean success) {
- try {
- is.close();
- } catch (IOException e) {
- if(success) {
- // this is a new error. ok to throw
- throw new RuntimeException(e);
- }
- // else don't subvert original exception. just print stack trace for this one
- e.printStackTrace();
- }
- }
+ private static void close(InputStream is, boolean success) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ if(success) {
+ // this is a new error. ok to throw
+ throw new RuntimeException(e);
+ }
+ // else don't subvert original exception. just print stack trace for this one
+ e.printStackTrace();
+ }
+ }
- private static int[] diffInternal(InputStream isA, InputStream isB, int[] allowableDifferenceRegions)
- throws IOException {
+ private static int[] diffInternal(InputStream isA, InputStream isB, int[] allowableDifferenceRegions)
+ throws IOException {
int offset = 0;
List temp = new ArrayList();
while (true) {
@@ -97,11 +97,11 @@
return new int[] { -1, offset, };
}
if (b != b2 && !isIgnoredRegion(allowableDifferenceRegions, offset)) {
- temp.add(new Integer(offset));
+ temp.add(Integer.valueOf(offset));
}
offset++;
}
- }
+ }
private static boolean isIgnoredRegion(int[] allowableDifferenceRegions, int offset) {
for (int i = 0; i < allowableDifferenceRegions.length; i+=2) {
@@ -121,7 +121,7 @@
}
Integer[] boxInts = new Integer[nItems];
temp.toArray(boxInts);
-
+
int[] result = new int[nItems];
for (int i = 0; i < result.length; i++) {
result[i] = boxInts[i].intValue();
Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java Thu Oct 8 22:29:41 2009
@@ -40,7 +40,7 @@
Map<Integer, String> formats = BuiltinFormats.getBuiltinFormats();
for (int idx : formats.keySet()) {
- String fmt = formats.get(new Integer(idx));
+ String fmt = formats.get(Integer.valueOf(idx));
assertEquals(idx, df.getFormat(fmt));
}
Modified: poi/trunk/src/testcases/org/apache/poi/util/LocalTestNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/LocalTestNode.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/LocalTestNode.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/util/LocalTestNode.java Thu Oct 8 22:29:41 2009
@@ -15,7 +15,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.util;
@@ -33,7 +32,7 @@
LocalTestNode(final int key)
{
- _key = new Integer(key);
+ _key = Integer.valueOf(key);
_value = String.valueOf(key);
}
@@ -118,7 +117,6 @@
/**
* @return hash code
*/
-
public int hashCode()
{
return getKey().hashCode() ^ getValue().hashCode();
Modified: poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java Thu Oct 8 22:29:41 2009
@@ -15,261 +15,264 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.util;
-import junit.framework.*;
+import junit.framework.TestCase;
/**
* Unit test for ArrayUtil
*
* @author Nick Burch
*/
-public class TestArrayUtil extends TestCase
-{
+public class TestArrayUtil extends TestCase {
/**
* Test to ensure that our own arraycopy behaves as it should do
*/
public void testarraycopy() {
byte[] bytes = new byte[] { 0x01, 0x02, 0x03, 0x04 };
-
+
// Test copy whole thing
byte[] dest = new byte[4];
ArrayUtil.arraycopy(bytes, 0, dest, 0, 4);
-
+
assertEquals(dest.length, bytes.length);
for(int i=0; i<dest.length; i++) {
assertEquals(bytes[i], dest[i]);
}
-
+
// ToDo - test exceptions are as expected
}
-
-
+
+
/**
- * Helper for testArrayMoveWithin
+ * Helper for testArrayMoveWithin
*/
- private Integer[] getIntsList() {
+ private Integer[] getIntsList() {
return new Integer[] {
- new Integer(0),
- new Integer(1),
- new Integer(2),
- new Integer(3),
- new Integer(4),
- new Integer(5),
- new Integer(6),
- new Integer(7),
- new Integer(8),
- new Integer(9)
+ Integer.valueOf(0),
+ Integer.valueOf(1),
+ Integer.valueOf(2),
+ Integer.valueOf(3),
+ Integer.valueOf(4),
+ Integer.valueOf(5),
+ Integer.valueOf(6),
+ Integer.valueOf(7),
+ Integer.valueOf(8),
+ Integer.valueOf(9)
};
}
+
+ private static void assertEquals(int exp, Integer act) {
+ assertEquals(exp, act.intValue());
+ }
/**
* Test to ensure that arrayMoveWithin works as expected
*/
public void testArrayMoveWithin() {
Integer[] ints = getIntsList();
-
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(2), ints[2]);
- assertEquals(new Integer(3), ints[3]);
- assertEquals(new Integer(4), ints[4]);
- assertEquals(new Integer(5), ints[5]);
- assertEquals(new Integer(6), ints[6]);
- assertEquals(new Integer(7), ints[7]);
- assertEquals(new Integer(8), ints[8]);
- assertEquals(new Integer(9), ints[9]);
-
-
+
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(2, ints[2]);
+ assertEquals(3, ints[3]);
+ assertEquals(4, ints[4]);
+ assertEquals(5, ints[5]);
+ assertEquals(6, ints[6]);
+ assertEquals(7, ints[7]);
+ assertEquals(8, ints[8]);
+ assertEquals(9, ints[9]);
+
+
//
// Moving to a later point in the array
//
-
+
// Shift 1 back
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 4, 8, 1);
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(2), ints[2]);
- assertEquals(new Integer(3), ints[3]);
- assertEquals(new Integer(5), ints[4]);
- assertEquals(new Integer(6), ints[5]);
- assertEquals(new Integer(7), ints[6]);
- assertEquals(new Integer(8), ints[7]);
- assertEquals(new Integer(4), ints[8]);
- assertEquals(new Integer(9), ints[9]);
-
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(2, ints[2]);
+ assertEquals(3, ints[3]);
+ assertEquals(5, ints[4]);
+ assertEquals(6, ints[5]);
+ assertEquals(7, ints[6]);
+ assertEquals(8, ints[7]);
+ assertEquals(4, ints[8]);
+ assertEquals(9, ints[9]);
+
// Shift front 1 back
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 0, 7, 1);
- assertEquals(new Integer(1), ints[0]);
- assertEquals(new Integer(2), ints[1]);
- assertEquals(new Integer(3), ints[2]);
- assertEquals(new Integer(4), ints[3]);
- assertEquals(new Integer(5), ints[4]);
- assertEquals(new Integer(6), ints[5]);
- assertEquals(new Integer(7), ints[6]);
- assertEquals(new Integer(0), ints[7]);
- assertEquals(new Integer(8), ints[8]);
- assertEquals(new Integer(9), ints[9]);
-
+ assertEquals(1, ints[0]);
+ assertEquals(2, ints[1]);
+ assertEquals(3, ints[2]);
+ assertEquals(4, ints[3]);
+ assertEquals(5, ints[4]);
+ assertEquals(6, ints[5]);
+ assertEquals(7, ints[6]);
+ assertEquals(0, ints[7]);
+ assertEquals(8, ints[8]);
+ assertEquals(9, ints[9]);
+
// Shift 1 to end
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 4, 9, 1);
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(2), ints[2]);
- assertEquals(new Integer(3), ints[3]);
- assertEquals(new Integer(5), ints[4]);
- assertEquals(new Integer(6), ints[5]);
- assertEquals(new Integer(7), ints[6]);
- assertEquals(new Integer(8), ints[7]);
- assertEquals(new Integer(9), ints[8]);
- assertEquals(new Integer(4), ints[9]);
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(2, ints[2]);
+ assertEquals(3, ints[3]);
+ assertEquals(5, ints[4]);
+ assertEquals(6, ints[5]);
+ assertEquals(7, ints[6]);
+ assertEquals(8, ints[7]);
+ assertEquals(9, ints[8]);
+ assertEquals(4, ints[9]);
+
-
//
// Moving to an earlier point in the array
//
-
+
// Shift 1 forward
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 8, 3, 1);
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(2), ints[2]);
- assertEquals(new Integer(8), ints[3]);
- assertEquals(new Integer(3), ints[4]);
- assertEquals(new Integer(4), ints[5]);
- assertEquals(new Integer(5), ints[6]);
- assertEquals(new Integer(6), ints[7]);
- assertEquals(new Integer(7), ints[8]);
- assertEquals(new Integer(9), ints[9]);
-
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(2, ints[2]);
+ assertEquals(8, ints[3]);
+ assertEquals(3, ints[4]);
+ assertEquals(4, ints[5]);
+ assertEquals(5, ints[6]);
+ assertEquals(6, ints[7]);
+ assertEquals(7, ints[8]);
+ assertEquals(9, ints[9]);
+
// Shift end 1 forward
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 9, 2, 1);
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(9), ints[2]);
- assertEquals(new Integer(2), ints[3]);
- assertEquals(new Integer(3), ints[4]);
- assertEquals(new Integer(4), ints[5]);
- assertEquals(new Integer(5), ints[6]);
- assertEquals(new Integer(6), ints[7]);
- assertEquals(new Integer(7), ints[8]);
- assertEquals(new Integer(8), ints[9]);
-
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(9, ints[2]);
+ assertEquals(2, ints[3]);
+ assertEquals(3, ints[4]);
+ assertEquals(4, ints[5]);
+ assertEquals(5, ints[6]);
+ assertEquals(6, ints[7]);
+ assertEquals(7, ints[8]);
+ assertEquals(8, ints[9]);
+
// Shift 1 to front
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 5, 0, 1);
- assertEquals(new Integer(5), ints[0]);
- assertEquals(new Integer(0), ints[1]);
- assertEquals(new Integer(1), ints[2]);
- assertEquals(new Integer(2), ints[3]);
- assertEquals(new Integer(3), ints[4]);
- assertEquals(new Integer(4), ints[5]);
- assertEquals(new Integer(6), ints[6]);
- assertEquals(new Integer(7), ints[7]);
- assertEquals(new Integer(8), ints[8]);
- assertEquals(new Integer(9), ints[9]);
+ assertEquals(5, ints[0]);
+ assertEquals(0, ints[1]);
+ assertEquals(1, ints[2]);
+ assertEquals(2, ints[3]);
+ assertEquals(3, ints[4]);
+ assertEquals(4, ints[5]);
+ assertEquals(6, ints[6]);
+ assertEquals(7, ints[7]);
+ assertEquals(8, ints[8]);
+ assertEquals(9, ints[9]);
+
-
//
// Moving many to a later point in the array
//
-
+
// Shift 3 back
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 2, 6, 3);
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(5), ints[2]);
- assertEquals(new Integer(6), ints[3]);
- assertEquals(new Integer(7), ints[4]);
- assertEquals(new Integer(8), ints[5]);
- assertEquals(new Integer(2), ints[6]);
- assertEquals(new Integer(3), ints[7]);
- assertEquals(new Integer(4), ints[8]);
- assertEquals(new Integer(9), ints[9]);
-
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(5, ints[2]);
+ assertEquals(6, ints[3]);
+ assertEquals(7, ints[4]);
+ assertEquals(8, ints[5]);
+ assertEquals(2, ints[6]);
+ assertEquals(3, ints[7]);
+ assertEquals(4, ints[8]);
+ assertEquals(9, ints[9]);
+
// Shift 3 to back
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 2, 7, 3);
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(5), ints[2]);
- assertEquals(new Integer(6), ints[3]);
- assertEquals(new Integer(7), ints[4]);
- assertEquals(new Integer(8), ints[5]);
- assertEquals(new Integer(9), ints[6]);
- assertEquals(new Integer(2), ints[7]);
- assertEquals(new Integer(3), ints[8]);
- assertEquals(new Integer(4), ints[9]);
-
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(5, ints[2]);
+ assertEquals(6, ints[3]);
+ assertEquals(7, ints[4]);
+ assertEquals(8, ints[5]);
+ assertEquals(9, ints[6]);
+ assertEquals(2, ints[7]);
+ assertEquals(3, ints[8]);
+ assertEquals(4, ints[9]);
+
// Shift from 3 front
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 0, 5, 3);
- assertEquals(new Integer(3), ints[0]);
- assertEquals(new Integer(4), ints[1]);
- assertEquals(new Integer(5), ints[2]);
- assertEquals(new Integer(6), ints[3]);
- assertEquals(new Integer(7), ints[4]);
- assertEquals(new Integer(0), ints[5]);
- assertEquals(new Integer(1), ints[6]);
- assertEquals(new Integer(2), ints[7]);
- assertEquals(new Integer(8), ints[8]);
- assertEquals(new Integer(9), ints[9]);
-
-
+ assertEquals(3, ints[0]);
+ assertEquals(4, ints[1]);
+ assertEquals(5, ints[2]);
+ assertEquals(6, ints[3]);
+ assertEquals(7, ints[4]);
+ assertEquals(0, ints[5]);
+ assertEquals(1, ints[6]);
+ assertEquals(2, ints[7]);
+ assertEquals(8, ints[8]);
+ assertEquals(9, ints[9]);
+
+
//
// Moving many to an earlier point in the array
//
-
+
// Shift 3 forward
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 6, 2, 3);
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(6), ints[2]);
- assertEquals(new Integer(7), ints[3]);
- assertEquals(new Integer(8), ints[4]);
- assertEquals(new Integer(2), ints[5]);
- assertEquals(new Integer(3), ints[6]);
- assertEquals(new Integer(4), ints[7]);
- assertEquals(new Integer(5), ints[8]);
- assertEquals(new Integer(9), ints[9]);
-
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(6, ints[2]);
+ assertEquals(7, ints[3]);
+ assertEquals(8, ints[4]);
+ assertEquals(2, ints[5]);
+ assertEquals(3, ints[6]);
+ assertEquals(4, ints[7]);
+ assertEquals(5, ints[8]);
+ assertEquals(9, ints[9]);
+
// Shift 3 to front
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 6, 0, 3);
- assertEquals(new Integer(6), ints[0]);
- assertEquals(new Integer(7), ints[1]);
- assertEquals(new Integer(8), ints[2]);
- assertEquals(new Integer(0), ints[3]);
- assertEquals(new Integer(1), ints[4]);
- assertEquals(new Integer(2), ints[5]);
- assertEquals(new Integer(3), ints[6]);
- assertEquals(new Integer(4), ints[7]);
- assertEquals(new Integer(5), ints[8]);
- assertEquals(new Integer(9), ints[9]);
-
+ assertEquals(6, ints[0]);
+ assertEquals(7, ints[1]);
+ assertEquals(8, ints[2]);
+ assertEquals(0, ints[3]);
+ assertEquals(1, ints[4]);
+ assertEquals(2, ints[5]);
+ assertEquals(3, ints[6]);
+ assertEquals(4, ints[7]);
+ assertEquals(5, ints[8]);
+ assertEquals(9, ints[9]);
+
// Shift from 3 back
ints = getIntsList();
ArrayUtil.arrayMoveWithin(ints, 7, 3, 3);
- assertEquals(new Integer(0), ints[0]);
- assertEquals(new Integer(1), ints[1]);
- assertEquals(new Integer(2), ints[2]);
- assertEquals(new Integer(7), ints[3]);
- assertEquals(new Integer(8), ints[4]);
- assertEquals(new Integer(9), ints[5]);
- assertEquals(new Integer(3), ints[6]);
- assertEquals(new Integer(4), ints[7]);
- assertEquals(new Integer(5), ints[8]);
- assertEquals(new Integer(6), ints[9]);
-
-
+ assertEquals(0, ints[0]);
+ assertEquals(1, ints[1]);
+ assertEquals(2, ints[2]);
+ assertEquals(7, ints[3]);
+ assertEquals(8, ints[4]);
+ assertEquals(9, ints[5]);
+ assertEquals(3, ints[6]);
+ assertEquals(4, ints[7]);
+ assertEquals(5, ints[8]);
+ assertEquals(6, ints[9]);
+
+
// Check can't shift more than we have
try {
ints = getIntsList();
@@ -278,7 +281,7 @@
} catch(IllegalArgumentException e) {
// Good, we don't have 5 from 7 onwards
}
-
+
// Check can't shift where would overshoot
try {
ints = getIntsList();
@@ -289,4 +292,3 @@
}
}
}
-
Modified: poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java Thu Oct 8 22:29:41 2009
@@ -120,7 +120,7 @@
m.put(nodes[ k ].getKey(), nodes[ k ]);
assertTrue(m.containsKey(nodes[ k ].getKey()));
}
- assertTrue(!m.containsKey(new Integer(-1)));
+ assertTrue(!m.containsKey(Integer.valueOf(-1)));
try
{
m.containsKey("foo");
@@ -179,7 +179,7 @@
m.put(nodes[ k ].getKey(), nodes[ k ]);
assertSame(m.get(nodes[ k ].getKey()), nodes[ k ]);
}
- assertNull(m.get(new Integer(-1)));
+ assertNull(m.get(Integer.valueOf(-1)));
try
{
m.get("foo");
@@ -270,7 +270,7 @@
catch (ClassCastException ignored)
{
}
- assertNull(m.remove(new Integer(-1)));
+ assertNull(m.remove(Integer.valueOf(-1)));
try
{
m.remove("foo");
@@ -450,7 +450,7 @@
Collection c1 = new LinkedList();
Collection c2 = new LinkedList();
- c2.add(new Integer(-99));
+ c2.add(Integer.valueOf(-99));
for (int k = 0; k < nodes.length; k++)
{
m.put(nodes[ k ].getKey(), nodes[ k ]);
@@ -461,7 +461,7 @@
assertTrue(!m.keySet().containsAll(c2));
m = new BinaryTree();
c1 = new LinkedList();
- c1.add(new Integer(-55));
+ c1.add(Integer.valueOf(-55));
try
{
m.keySet().addAll(c1);
@@ -869,7 +869,7 @@
}
// reject incompatible values
- m2.put("2", new Integer(2));
+ m2.put("2", Integer.valueOf(2));
try
{
m = new BinaryTree(m2);
@@ -881,7 +881,7 @@
// reject incompatible keys
m2.remove("2");
- m2.put(new Integer(2), "bad key");
+ m2.put(Integer.valueOf(2), "bad key");
try
{
m = new BinaryTree(m2);
@@ -973,7 +973,7 @@
catch (ClassCastException ignored)
{
}
- assertNull(m.remove(new Integer(-1)));
+ assertNull(m.remove(Integer.valueOf(-1)));
try
{
m.removeValue("foo");
@@ -1135,7 +1135,7 @@
Collection c1 = new LinkedList();
Collection c2 = new LinkedList();
- c2.add(new Integer(-99));
+ c2.add(Integer.valueOf(-99));
for (int k = 0; k < nodes.length; k++)
{
m.put(nodes[ k ].getKey(), nodes[ k ]);
@@ -1146,7 +1146,7 @@
assertTrue(!m.keySetByValue().containsAll(c2));
m = new BinaryTree();
c1 = new LinkedList();
- c1.add(new Integer(-55));
+ c1.add(Integer.valueOf(-55));
try
{
m.keySetByValue().addAll(c1);
@@ -1390,7 +1390,7 @@
}
for (int k = 0; k < m.size(); k++)
{
- assertTrue(s.contains(new Integer(k)));
+ assertTrue(s.contains(Integer.valueOf(k)));
}
int count = 0;
@@ -1616,7 +1616,7 @@
}
for (int k = 0; k < m.size(); k++)
{
- assertTrue(s.contains(new Integer(k)));
+ assertTrue(s.contains(Integer.valueOf(k)));
}
int count = 0;
Modified: poi/trunk/src/testcases/org/apache/poi/util/TestPOILogger.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestPOILogger.java?rev=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/TestPOILogger.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/util/TestPOILogger.java Thu Oct 8 22:29:41 2009
@@ -39,8 +39,8 @@
POILogger log = POILogFactory.getLogger( "foo" );
- log.log( POILogger.WARN, "Test = ", new Integer( 1 ) );
- log.logFormatted( POILogger.ERROR, "Test param 1 = %, param 2 = %", "2", new Integer( 3 ) );
+ log.log( POILogger.WARN, "Test = ", Integer.valueOf( 1 ) );
+ log.logFormatted( POILogger.ERROR, "Test param 1 = %, param 2 = %", "2", Integer.valueOf( 3 ) );
log.logFormatted( POILogger.ERROR, "Test param 1 = %, param 2 = %", new int[]{4, 5} );
log.logFormatted( POILogger.ERROR,
"Test param 1 = %1.1, param 2 = %0.1", new double[]{4, 5.23} );
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=823348&r1=823347&r2=823348&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/TestStringUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/util/TestStringUtil.java Thu Oct 8 22:29:41 2009
@@ -60,11 +60,11 @@
(byte) 'r', (byte) 'l', (byte) 'd', (byte) 0xAE
};
String input;
- try {
- input = new String( expected_output, StringUtil.getPreferredEncoding() );
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
+ try {
+ input = new String( expected_output, StringUtil.getPreferredEncoding() );
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
StringUtil.putCompressedUnicode( input, output, 0 );
for ( int j = 0; j < expected_output.length; j++ )
@@ -129,57 +129,31 @@
}
public void testFormat() {
- assertEquals( "This is a test " + fmt( 1.2345, 2, 2 ),
- StringUtil.format( "This is a test %2.2", new Object[]
- {
- new Double( 1.2345 )
- } ) );
- assertEquals( "This is a test " + fmt( 1.2345, -1, 3 ),
- StringUtil.format( "This is a test %.3", new Object[]
- {
- new Double( 1.2345 )
- } ) );
- assertEquals( "This is a great test " + fmt( 1.2345, -1, 3 ),
- StringUtil.format( "This is a % test %.3", new Object[]
- {
- "great", new Double( 1.2345 )
- } ) );
- assertEquals( "This is a test 1",
- StringUtil.format( "This is a test %", new Object[]
- {
- new Integer( 1 )
- } ) );
- assertEquals( "This is a test 1",
- StringUtil.format( "This is a test %", new Object[]
- {
- new Integer( 1 ), new Integer( 1 )
- } ) );
- assertEquals( "This is a test 1.x",
- StringUtil.format( "This is a test %1.x", new Object[]
- {
- new Integer( 1 )
- } ) );
- assertEquals( "This is a test ?missing data?1.x",
- StringUtil.format( "This is a test %1.x", new Object[]
- {
- } ) );
- assertEquals( "This is a test %1.x",
- StringUtil.format( "This is a test \\%1.x", new Object[]
- {
- } ) );
+
+ confirm("This is a test " + fmt(1.2345, 2, 2), "This is a test %2.2", new Double(1.2345));
+ confirm("This is a test " + fmt(1.2345, -1, 3), "This is a test %.3", new Double(1.2345));
+ confirm("This is a great test " + fmt(1.2345, -1, 3),
+ "This is a % test %.3", "great", new Double(1.2345));
+ confirm("This is a test 1", "This is a test %", Integer.valueOf(1));
+ confirm("This is a test 1", "This is a test %", Integer.valueOf(1), Integer.valueOf(1));
+ confirm("This is a test 1.x", "This is a test %1.x", Integer.valueOf(1));
+ confirm("This is a test ?missing data?1.x", "This is a test %1.x");
+ confirm("This is a test %1.x", "This is a test \\%1.x");
}
+ private static void confirm(String expectedResult, String fmtString, Object ... params) {
+ String actualResult = StringUtil.format(fmtString, params);
+ assertEquals(expectedResult, actualResult);
+ }
private static String fmt(double num, int minIntDigits, int maxFracDigitis) {
NumberFormat nf = NumberFormat.getInstance();
- if ( minIntDigits != -1 )
- {
- nf.setMinimumIntegerDigits( minIntDigits );
+ if (minIntDigits != -1) {
+ nf.setMinimumIntegerDigits(minIntDigits);
}
- if ( maxFracDigitis != -1 )
- {
- nf.setMaximumFractionDigits( maxFracDigitis );
+ if (maxFracDigitis != -1) {
+ nf.setMaximumFractionDigits(maxFracDigitis);
}
return nf.format( num );
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org