poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1622589 - in /poi: site/src/documentation/content/xdocs/ trunk/src/java/org/apache/poi/hssf/record/ trunk/src/java/org/apache/poi/util/ trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/ trunk/src/scratchpad/src/org/apache/poi/hwpf/m...
Date Fri, 05 Sep 2014 00:31:48 GMT
Author: kiwiwings
Date: Fri Sep  5 00:31:47 2014
New Revision: 1622589

URL: http://svn.apache.org/r1622589
Log:
Bug 56913 - Replace usages of o.a.p.util.ArrayUtil.copyOf* methods with replacements from
j.u.Arrays

Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/DConRefRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
    poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Fri Sep  5 00:31:47 2014
@@ -38,6 +38,7 @@
     </devs>
 
     <release version="3.11-beta3" date="2014-??-??">
+        <action dev="PD" type="fix" fixes-bug="56913">Replace usages of o.a.p.util.ArrayUtil.copyOf*
methods with replacements from j.u.Arrays</action>
         <action dev="PD" type="fix" fixes-bug="51483">XSSF locking of specific features
not working</action>
         <action dev="PD" type="fix" fixes-bug="48195">Formulas: Fix incorrect evaluation
of IF() with ROW()/COLUMN() as else-result.</action>
         <action dev="PD" type="fix" fixes-bug="55280">XSSF: Greatly improve performance
of shifting rows in sheets with many merged regions.</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/DConRefRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/DConRefRecord.java?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/DConRefRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/DConRefRecord.java Fri Sep  5 00:31:47 2014
@@ -18,10 +18,11 @@
  */
 package org.apache.poi.hssf.record;
 
-import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianOutput;
 
+import java.util.Arrays;
+
 /**
  * DConRef records specify a range in a workbook (internal or external) that serves as a
data source
  * for pivot tables or data consolidation.
@@ -273,7 +274,7 @@ public class DConRefRecord extends Stand
      */
     public byte[] getPath()
     {
-        return ArrayUtil.copyOf(path, path.length);
+        return Arrays.copyOf(path, path.length);
     }
 
     /**
@@ -291,7 +292,7 @@ public class DConRefRecord extends Stand
             {
                 offset++;
             }
-            String out = new String(ArrayUtil.copyOfRange(path, offset, path.length));
+            String out = new String(Arrays.copyOfRange(path, offset, path.length));
             //UNC paths have \u0003 chars as path separators.
             out = out.replaceAll("\u0003", "/");
             return out;

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java Fri Sep  5 00:31:47
2014
@@ -118,7 +118,7 @@ public final class DrawingGroupRecord ex
                 writeHeader( data, offset, segmentLength );
             writtenActualData += 4;
             offset += 4;
-            ArrayUtil.arraycopy( rawData, writtenRawData, data, offset, segmentLength );
+            System.arraycopy( rawData, writtenRawData, data, offset, segmentLength );
             offset += segmentLength;
             writtenRawData += segmentLength;
             writtenActualData += segmentLength;

Modified: poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java Fri Sep  5 00:31:47 2014
@@ -106,89 +106,4 @@ public class ArrayUtil
     	// We're done - array will now have everything moved as required
     }
 
-    /**
-     * Copies the specified array, truncating or padding with zeros (if
-     * necessary) so the copy has the specified length. This method is temporary
-     * replace for Arrays.copyOf() until we start to require JDK 1.6.
-     * 
-     * @param source
-     *            the array to be copied
-     * @param newLength
-     *            the length of the copy to be returned
-     * @return a copy of the original array, truncated or padded with zeros to
-     *         obtain the specified length
-     * @throws NegativeArraySizeException
-     *             if <tt>newLength</tt> is negative
-     * @throws NullPointerException
-     *             if <tt>original</tt> is null
-     */
-    public static byte[] copyOf( byte[] source, int newLength )
-    {
-        byte[] result = new byte[newLength];
-        System.arraycopy( source, 0, result, 0,
-                Math.min( source.length, newLength ) );
-        return result;
-    }
-
-    /**
-     * Copies the specified array into specified result array, truncating or
-     * padding with zeros (if necessary) so the copy has the specified length.
-     * This method is temporary replace for Arrays.copyOf() until we start to
-     * require JDK 1.6.
-     * 
-     * @param source
-     *            the array to be copied
-     * @param result
-     *            the array to be filled and returned
-     * @throws NegativeArraySizeException
-     *             if <tt>newLength</tt> is negative
-     * @throws NullPointerException
-     *             if <tt>original</tt> is null
-     */
-    public static <T> T[] copyOf( T[] source, T[] result )
-    {
-        System.arraycopy( source, 0, result, 0,
-                Math.min( source.length, result.length ) );
-        return result;
-    }
-
-    /**
-     * Copies the specified range of the specified array into a new array.
-     * The initial index of the range (<tt>from</tt>) must lie between zero
-     * and <tt>original.length</tt>, inclusive.  The value at
-     * <tt>original[from]</tt> is placed into the initial element of the copy
-     * (unless <tt>from == original.length</tt> or <tt>from == to</tt>).
-     * Values from subsequent elements in the original array are placed into
-     * subsequent elements in the copy.  The final index of the range
-     * (<tt>to</tt>), which must be greater than or equal to <tt>from</tt>,
-     * may be greater than <tt>original.length</tt>, in which case
-     * <tt>(byte)0</tt> is placed in all elements of the copy whose index is
-     * greater than or equal to <tt>original.length - from</tt>.  The length
-     * of the returned array will be <tt>to - from</tt>.
-     *
-     * This method is temporary
-     * replace for Arrays.copyOfRange() until we start to require JDK 1.6.
-     *
-     * @param original the array from which a range is to be copied
-     * @param from the initial index of the range to be copied, inclusive
-     * @param to the final index of the range to be copied, exclusive.
-     *     (This index may lie outside the array.)
-     * @return a new array containing the specified range from the original array,
-     *     truncated or padded with zeros to obtain the required length
-     * @throws ArrayIndexOutOfBoundsException if <tt>from &lt; 0</tt>
-     *     or <tt>from &gt; original.length()</tt>
-     * @throws IllegalArgumentException if <tt>from &gt; to</tt>
-     * @throws NullPointerException if <tt>original</tt> is null
-     * @since 1.6
-     */
-    public static byte[] copyOfRange(byte[] original, int from, int to) {
-        int newLength = to - from;
-        if (newLength < 0)
-            throw new IllegalArgumentException(from + " > " + to);
-        byte[] copy = new byte[newLength];
-        System.arraycopy(original, from, copy, 0,
-                Math.min(original.length - from, newLength));
-        return copy;
-    }
-
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java Fri
Sep  5 00:31:47 2014
@@ -19,6 +19,7 @@ package org.apache.poi.xwpf.usermodel;
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.Arrays;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -32,7 +33,6 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.openxml4j.opc.PackagingURIHelper;
 import org.apache.poi.openxml4j.opc.TargetMode;
-import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.xwpf.XWPFTestDataSamples;
 import org.apache.xmlbeans.XmlCursor;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
@@ -307,7 +307,7 @@ public final class TestXWPFDocument exte
 	    String id1 = doc.addPictureData(newPic, Document.PICTURE_TYPE_JPEG);
 	    assertEquals(2,doc.getAllPackagePictures().size());
 	    /* copy data, to avoid instance-equality */
-	    byte[] newPicCopy = ArrayUtil.copyOf(newPic, newPic.length);
+	    byte[] newPicCopy = Arrays.copyOf(newPic, newPic.length);
 	    String id2 = doc.addPictureData(newPicCopy, Document.PICTURE_TYPE_JPEG);
 	    assertEquals(id1,id2);
 	    doc.getPackage().revert();

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java Fri Sep
 5 00:31:47 2014
@@ -16,11 +16,12 @@
 ==================================================================== */
 package org.apache.poi.hwpf.model;
 
-import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 
+import java.util.Arrays;
+
 public class NilPICFAndBinData
 {
 
@@ -52,8 +53,8 @@ public class NilPICFAndBinData
 
         // skip the 62 ignored bytes
         int binaryLength = lcb - cbHeader;
-        this._binData = ArrayUtil.copyOfRange( data, offset + cbHeader,
-                offset + cbHeader + binaryLength );
+        this._binData = Arrays.copyOfRange(data, offset + cbHeader,
+                offset + cbHeader + binaryLength);
     }
 
     public byte[] getBinData()

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java Fri Sep  5 00:31:47
2014
@@ -23,7 +23,6 @@ import java.util.Arrays;
 import java.util.NoSuchElementException;
 
 import org.apache.poi.hwpf.model.io.HWPFOutputStream;
-import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -118,10 +117,10 @@ public class PlfLfo
     {
         final int newLfoMac = _lfoMac + 1;
 
-        _rgLfo = ArrayUtil.copyOf( _rgLfo, new LFO[newLfoMac] );
+        _rgLfo = Arrays.copyOf(_rgLfo, newLfoMac);
         _rgLfo[_lfoMac + 1] = lfo;
 
-        _rgLfoData = ArrayUtil.copyOf( _rgLfoData, new LFOData[_lfoMac + 1] );
+        _rgLfoData = Arrays.copyOf(_rgLfoData, newLfoMac);
         _rgLfoData[_lfoMac + 1] = lfoData;
 
         this._lfoMac = newLfoMac;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java Fri Sep  5 00:31:47 2014
@@ -16,10 +16,11 @@
 ==================================================================== */
 package org.apache.poi.hwpf.model;
 
-import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.StringUtil;
 
+import java.util.Arrays;
+
 /**
  * The STTB is a string table that is made up of a header that is followed by an
  * array of elements. The cData value specifies the number of elements that are
@@ -64,7 +65,7 @@ public class Sttb
     {
         this._cDataLength = cDataLength;
 
-        this._data = ArrayUtil.copyOf( data, new String[data.length] );
+        this._data = Arrays.copyOf(data, data.length);
 
         this._cbExtra = 0;
         this._extraData = null;

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java?rev=1622589&r1=1622588&r2=1622589&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java Fri Sep  5 00:31:47
2014
@@ -23,7 +23,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 import junit.framework.TestCase;
-import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndianOutputStream;
 
 /**
@@ -288,7 +287,7 @@ public class TestDConRefRecord extends T
     public void testGetPath()
     {
         DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data1));
-        byte[] expResult = ArrayUtil.copyOfRange(data1, 9, data1.length);
+        byte[] expResult = Arrays.copyOfRange(data1, 9, data1.length);
         byte[] result = instance.getPath();
         assertTrue("get path", Arrays.equals(expResult, result));
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message