poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1674964 - in /poi/trunk/src: examples/src/org/apache/poi/xssf/usermodel/examples/ scratchpad/src/org/apache/poi/hslf/model/ scratchpad/src/org/apache/poi/hwpf/model/ scratchpad/testcases/org/apache/poi/hslf/model/ scratchpad/testcases/org/...
Date Mon, 20 Apr 2015 19:15:22 GMT
Author: centic
Date: Mon Apr 20 19:15:21 2015
New Revision: 1674964

URL: http://svn.apache.org/r1674964
Log:
Fix usage of Generics in some classes

Modified:
    poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRange.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java
    poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java Mon
Apr 20 19:15:21 2015
@@ -114,16 +114,17 @@ public class AligningCells {
 
         // Make the selection
         CTRowImpl ctRow = (CTRowImpl) row.getCTRow();
-        List spanList = new ArrayList();
 
         // Add object with format start_coll:end_coll. For example 1:3 will span from
         // cell 1 to cell 3, where the column index starts with 0
         //
         // You can add multiple spans for one row
         Object span = start_column + ":" + end_column;
+
+        List<Object> spanList = new ArrayList<Object>();
         spanList.add(span);
 
         //add spns to the row
         ctRow.setSpans(spanList);
     }
-} 
\ No newline at end of file
+}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java Mon Apr 20 19:15:21
2015
@@ -152,7 +152,7 @@ public final class Hyperlink {
      * @return found hyperlinks or <code>null</code> if not found
      */
     protected static Hyperlink[] find(TextRun run){
-        ArrayList lst = new ArrayList();
+        List<Hyperlink> lst = new ArrayList<Hyperlink>();
         SlideShow ppt = run.getSheet().getSlideShow();
         //document-level container which stores info about all links in a presentation
         ExObjList exobj = ppt.getDocumentRecord().getExObjList();
@@ -177,7 +177,7 @@ public final class Hyperlink {
      * @return found hyperlink or <code>null</code>
      */
     protected static Hyperlink find(Shape shape){
-        ArrayList lst = new ArrayList();
+        List<Hyperlink> lst = new ArrayList<Hyperlink>();
         SlideShow ppt = shape.getSheet().getSlideShow();
         //document-level container which stores info about all links in a presentation
         ExObjList exobj = ppt.getDocumentRecord().getExObjList();
@@ -195,10 +195,10 @@ public final class Hyperlink {
             }
         }
 
-        return lst.size() == 1 ? (Hyperlink)lst.get(0) : null;
+        return lst.size() == 1 ? lst.get(0) : null;
     }
 
-    private static void find(Record[] records, ExObjList exobj, List out){
+    private static void find(Record[] records, ExObjList exobj, List<Hyperlink> out){
         for (int i = 0; i < records.length; i++) {
             //see if we have InteractiveInfo in the textrun's records
             if( records[i] instanceof InteractiveInfo){

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java Mon Apr 20 19:15:21
2015
@@ -150,25 +150,26 @@ public final class Table extends ShapeGr
 
     protected void initTable(){
         Shape[] sh = getShapes();
-        Arrays.sort(sh, new Comparator(){
-            public int compare( Object o1, Object o2 ) {
-                Rectangle anchor1 = ((Shape)o1).getAnchor();
-                Rectangle anchor2 = ((Shape)o2).getAnchor();
+        Arrays.sort(sh, new Comparator<Shape>(){
+            public int compare( Shape o1, Shape o2 ) {
+                Rectangle anchor1 = o1.getAnchor();
+                Rectangle anchor2 = o2.getAnchor();
                 int delta = anchor1.y - anchor2.y;
                 if(delta == 0) delta = anchor1.x - anchor2.x;
                 return delta;
             }
         });
+
         int y0 = (sh.length > 0) ? sh[0].getAnchor().y - 1 : -1;
         int maxrowlen = 0;
-        ArrayList lst = new ArrayList();
-        ArrayList row = null;
+        List<List<Shape>> lst = new ArrayList<List<Shape>>();
+        List<Shape> row = null;
         for (int i = 0; i < sh.length; i++) {
             if(sh[i] instanceof TextShape){
                 Rectangle anchor = sh[i].getAnchor();
                 if(anchor.y != y0){
                     y0 = anchor.y;
-                    row = new ArrayList();
+                    row = new ArrayList<Shape>();
                     lst.add(row);
                 }
                 row.add(sh[i]);
@@ -177,7 +178,7 @@ public final class Table extends ShapeGr
         }
         cells = new TableCell[lst.size()][maxrowlen];
         for (int i = 0; i < lst.size(); i++) {
-            row = (ArrayList)lst.get(i);
+            row = lst.get(i);
             for (int j = 0; j < row.size(); j++) {
                 TextShape tx = (TextShape)row.get(j);
                 cells[i][j] = new TableCell(tx.getSpContainer(), getParent());

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java Mon Apr 20 19:15:21
2015
@@ -53,7 +53,7 @@ public class CHPBinTable
             .getLogger( CHPBinTable.class );
 
   /** List of character properties.*/
-  protected ArrayList<CHPX> _textRuns = new ArrayList<CHPX>();
+  protected List<CHPX> _textRuns = new ArrayList<CHPX>();
 
   public CHPBinTable()
   {
@@ -498,7 +498,7 @@ public class CHPBinTable
         int endingFc = translator.getByteIndex( _textRuns.get(
                 _textRuns.size() - 1 ).getEnd() );
 
-    ArrayList<CHPX> overflow = _textRuns;
+    List<CHPX> overflow = _textRuns;
     do
     {
       CHPX startingProp = overflow.get(0);

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java Mon Apr 20 19:15:21
2015
@@ -38,11 +38,11 @@ public class SectionTable
   private final static POILogger _logger = POILogFactory.getLogger(SectionTable.class);
   private static final int SED_SIZE = 12;
 
-  protected ArrayList<SEPX> _sections = new ArrayList<SEPX>();
+  protected List<SEPX> _sections = new ArrayList<SEPX>();
   protected List<TextPiece> _text;
 
   /** So we can know if things are unicode or not */
-  private TextPieceTable tpt;
+  //private TextPieceTable tpt;
 
   public SectionTable()
   {
@@ -54,7 +54,7 @@ public class SectionTable
                       TextPieceTable tpt, int mainLength)
   {
     PlexOfCps sedPlex = new PlexOfCps(tableStream, offset, size, SED_SIZE);
-    this.tpt = tpt;
+    //this.tpt = tpt;
     this._text = tpt.getTextPieces();
 
     int length = sedPlex.length();
@@ -160,7 +160,7 @@ public class SectionTable
     // return FC;
     // }
 
-  public ArrayList<SEPX> getSections()
+  public List<SEPX> getSections()
   {
     return _sections;
   }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java Mon Apr
20 19:15:21 2015
@@ -22,6 +22,8 @@ import junit.framework.TestCase;
 import java.io.*;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.poi.hslf.usermodel.SlideShow;
 import org.apache.poi.hslf.record.TextHeaderAtom;
@@ -73,7 +75,7 @@ public final class TestTextShape extends
     public void testRead() throws IOException {
         SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("text_shapes.ppt"));
 
-        ArrayList lst1 = new ArrayList();
+        List<String> lst1 = new ArrayList<String>();
         Slide slide = ppt.getSlides()[0];
         Shape[] shape = slide.getShapes();
         for (int i = 0; i < shape.length; i++) {
@@ -110,7 +112,7 @@ public final class TestTextShape extends
             lst1.add(run.getText());
         }
 
-        ArrayList lst2 = new ArrayList();
+        List<String> lst2 = new ArrayList<String>();
         TextRun[] run = slide.getTextRuns();
         for (int i = 0; i < run.length; i++) {
             lst2.add(run[i].getText());
@@ -160,7 +162,7 @@ public final class TestTextShape extends
 
         Slide slide = ppt.getSlides()[0];
 
-        HashMap map = new HashMap();
+        Map<String, TextShape> map = new HashMap<String, TextShape>();
         Shape[] shape = slide.getShapes();
         for (int i = 0; i < shape.length; i++) {
             if(shape[i] instanceof TextShape){
@@ -171,25 +173,25 @@ public final class TestTextShape extends
 
         TextShape tx;
 
-        tx = (TextShape)map.get("TEST1");
+        tx = map.get("TEST1");
         assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.39, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
 
-        tx = (TextShape)map.get("TEST2");
+        tx = map.get("TEST2");
         assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.39, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
 
-        tx = (TextShape)map.get("TEST3");
+        tx = map.get("TEST3");
         assertEquals(0.39, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
 
-        tx = (TextShape)map.get("TEST4");
+        tx = map.get("TEST4");
         assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.39, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java Mon
Apr 20 19:15:21 2015
@@ -18,7 +18,7 @@
 package org.apache.poi.hwpf.model;
 
 import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -59,16 +59,16 @@ public final class TestCHPBinTable
 
     CHPBinTable newBinTable = new CHPBinTable(newMainStream, newTableStream, 0, newTableStream.length,
fakeTPT);
 
-    ArrayList oldTextRuns = _cHPBinTable._textRuns;
-    ArrayList newTextRuns = newBinTable._textRuns;
+    List<CHPX> oldTextRuns = _cHPBinTable._textRuns;
+    List<CHPX> newTextRuns = newBinTable._textRuns;
 
     assertEquals(oldTextRuns.size(), newTextRuns.size());
 
     int size = oldTextRuns.size();
     for (int x = 0; x < size; x++)
     {
-      PropertyNode oldNode = (PropertyNode)oldTextRuns.get(x);
-      PropertyNode newNode = (PropertyNode)newTextRuns.get(x);
+      CHPX oldNode = oldTextRuns.get(x);
+      CHPX newNode = newTextRuns.get(x);
       assertTrue(oldNode.equals(newNode));
     }
 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestSectionTable.java Mon
Apr 20 19:15:21 2015
@@ -20,7 +20,7 @@ package org.apache.poi.hwpf.model;
 import junit.framework.*;
 
 import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.poi.hwpf.*;
 import org.apache.poi.hwpf.model.io.*;
@@ -58,8 +58,8 @@ public final class TestSectionTable
     		newMainStream, newTableStream, 0,
     		newTableStream.length, 0, tpt, fib.getSubdocumentTextStreamLength( SubdocumentType.MAIN
));
 
-    ArrayList oldSections = sectionTable.getSections();
-    ArrayList newSections = newSectionTable.getSections();
+    List<SEPX> oldSections = sectionTable.getSections();
+    List<SEPX> newSections = newSectionTable.getSections();
 
     assertEquals(oldSections.size(), newSections.size());
 
@@ -79,8 +79,8 @@ public final class TestSectionTable
     int size = oldSections.size();
     for (int x = 0; x < size; x++)
     {
-      PropertyNode oldNode = (PropertyNode)oldSections.get(x);
-      PropertyNode newNode = (PropertyNode)newSections.get(x);
+	  SEPX oldNode = oldSections.get(x);
+	  SEPX newNode = newSections.get(x);
       assertEquals(oldNode, newNode);
     }
   }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRange.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRange.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRange.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRange.java Mon Apr
20 19:15:21 2015
@@ -17,7 +17,7 @@
 
 package org.apache.poi.hwpf.usermodel;
 
-import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -62,7 +62,7 @@ public final class TestRange extends Tes
         HWPFDocument hwpfDocument = new HWPFDocument( POIDataSamples
                 .getDocumentInstance().openResourceAsStream( "Bug46817.doc" ) );
 
-        final ArrayList<SEPX> sections = hwpfDocument.getSectionTable()
+        final List<SEPX> sections = hwpfDocument.getSectionTable()
                 .getSections();
         assertEquals( sections.size(), 1 );
 

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=1674964&r1=1674963&r2=1674964&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 Mon Apr 20 19:15:21
2015
@@ -82,7 +82,7 @@ public final class StreamUtility {
 	private static int[] diffInternal(InputStream isA, InputStream isB, int[] allowableDifferenceRegions)
 			throws IOException {
 		int offset = 0;
-		List temp = new ArrayList();
+		List<Integer> temp = new ArrayList<Integer>();
 		while (true) {
 			int b = isA.read();
 			int b2 = isB.read();
@@ -114,7 +114,7 @@ public final class StreamUtility {
 		return false;
 	}
 
-	private static int[] toPrimitiveIntArray(List temp) {
+	private static int[] toPrimitiveIntArray(List<Integer> temp) {
 		int nItems = temp.size();
 		if(nItems < 1) {
 			return null;

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java?rev=1674964&r1=1674963&r2=1674964&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java Mon Apr
20 19:15:21 2015
@@ -142,7 +142,7 @@ public final class TestSmallDocumentBloc
     {
         for (int j = 0; j <= 8; j++)
         {
-            List foo = new ArrayList();
+            List<Object> foo = new ArrayList<Object>();
 
             for (int k = 0; k < j; k++)
             {



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


Mime
View raw message