poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r959335 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model: CHPBinTable.java CHPFormattedDiskPage.java TextPieceTable.java
Date Wed, 30 Jun 2010 14:41:04 GMT
Author: nick
Date: Wed Jun 30 14:41:03 2010
New Revision: 959335

URL: http://svn.apache.org/viewvc?rev=959335&view=rev
Log:
Fix generics warnings

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java

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=959335&r1=959334&r2=959335&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 Wed Jun 30 14:41:03
2010
@@ -35,7 +35,7 @@ import org.apache.poi.hwpf.sprm.SprmBuff
 public final class CHPBinTable
 {
   /** List of character properties.*/
-  protected ArrayList _textRuns = new ArrayList();
+  protected ArrayList<CHPX> _textRuns = new ArrayList<CHPX>();
 
   /** So we can know if things are unicode or not */
   private TextPieceTable tpt;
@@ -85,33 +85,33 @@ public final class CHPBinTable
     int endMark = offset + length;
     int endIndex = listIndex;
 
-    CHPX chpx = (CHPX)_textRuns.get(endIndex);
+    CHPX chpx = _textRuns.get(endIndex);
     while (chpx.getEnd() < endMark)
     {
-      chpx = (CHPX)_textRuns.get(++endIndex);
+      chpx = _textRuns.get(++endIndex);
     }
     if (listIndex == endIndex)
     {
-      chpx = (CHPX)_textRuns.get(endIndex);
+      chpx = _textRuns.get(endIndex);
       chpx.setEnd((chpx.getEnd() - endMark) + offset);
     }
     else
     {
-      chpx = (CHPX)_textRuns.get(listIndex);
+      chpx = _textRuns.get(listIndex);
       chpx.setEnd(offset);
       for (int x = listIndex + 1; x < endIndex; x++)
       {
-        chpx = (CHPX)_textRuns.get(x);
+        chpx = _textRuns.get(x);
         chpx.setStart(offset);
         chpx.setEnd(offset);
       }
-      chpx = (CHPX)_textRuns.get(endIndex);
+      chpx = _textRuns.get(endIndex);
       chpx.setEnd((chpx.getEnd() - endMark) + offset);
     }
 
     for (int x = endIndex + 1; x < size; x++)
     {
-      chpx = (CHPX)_textRuns.get(x);
+      chpx = _textRuns.get(x);
       chpx.setStart(chpx.getStart() - length);
       chpx.setEnd(chpx.getEnd() - length);
     }
@@ -132,7 +132,7 @@ public final class CHPBinTable
     }
     else
     {
-      CHPX chpx = (CHPX)_textRuns.get(listIndex);
+      CHPX chpx = _textRuns.get(listIndex);
       if (chpx.getStart() < cpStart)
       {
     	// Copy the properties of the one before to afterwards
@@ -160,18 +160,18 @@ public final class CHPBinTable
   public void adjustForInsert(int listIndex, int length)
   {
     int size = _textRuns.size();
-    CHPX chpx = (CHPX)_textRuns.get(listIndex);
+    CHPX chpx = _textRuns.get(listIndex);
     chpx.setEnd(chpx.getEnd() + length);
 
     for (int x = listIndex + 1; x < size; x++)
     {
-      chpx = (CHPX)_textRuns.get(x);
+      chpx = _textRuns.get(x);
       chpx.setStart(chpx.getStart() + length);
       chpx.setEnd(chpx.getEnd() + length);
     }
   }
 
-  public List getTextRuns()
+  public List<CHPX> getTextRuns()
   {
     return _textRuns;
   }
@@ -203,7 +203,7 @@ public final class CHPBinTable
     endingFc += fcMin;
 
 
-    ArrayList overflow = _textRuns;
+    ArrayList<CHPX> overflow = _textRuns;
     do
     {
       PropertyNode startingProp = (PropertyNode)overflow.get(0);
@@ -230,9 +230,4 @@ public final class CHPBinTable
     while (overflow != null);
     tableStream.write(binTable.toByteArray());
   }
-
-
-
-
-
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java?rev=959335&r1=959334&r2=959335&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java Wed Jun
30 14:41:03 2010
@@ -42,8 +42,8 @@ public final class CHPFormattedDiskPage 
 {
     private static final int FC_SIZE = 4;
 
-    private ArrayList _chpxList = new ArrayList();
-    private ArrayList _overFlow;
+    private ArrayList<CHPX> _chpxList = new ArrayList<CHPX>();
+    private ArrayList<CHPX> _overFlow;
 
 
     public CHPFormattedDiskPage()
@@ -68,15 +68,15 @@ public final class CHPFormattedDiskPage 
 
     public CHPX getCHPX(int index)
     {
-      return (CHPX)_chpxList.get(index);
+      return _chpxList.get(index);
     }
 
-    public void fill(List filler)
+    public void fill(List<CHPX> filler)
     {
       _chpxList.addAll(filler);
     }
 
-    public ArrayList getOverflow()
+    public ArrayList<CHPX> getOverflow()
     {
       return _overFlow;
     }
@@ -119,7 +119,7 @@ public final class CHPFormattedDiskPage 
       int index = 0;
       for (; index < size; index++)
       {
-        int grpprlLength = ((CHPX)_chpxList.get(index)).getGrpprl().length;
+        int grpprlLength = (_chpxList.get(index)).getGrpprl().length;
 
         // check to see if we have enough room for an FC, the grpprl offset,
         // the grpprl size byte and the grpprl.
@@ -142,7 +142,7 @@ public final class CHPFormattedDiskPage 
       // see if we couldn't fit some
       if (index != size)
       {
-        _overFlow = new ArrayList();
+        _overFlow = new ArrayList<CHPX>();
         _overFlow.addAll(_chpxList.subList(index, size));
       }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java?rev=959335&r1=959334&r2=959335&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java Wed Jun 30
14:41:03 2010
@@ -17,15 +17,14 @@
 
 package org.apache.poi.hwpf.model;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
-import org.apache.poi.poifs.common.POIFSConstants;
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 
+import org.apache.poi.hwpf.model.io.HWPFOutputStream;
+import org.apache.poi.poifs.common.POIFSConstants;
+
 /**
  * The piece table for matching up character positions to bits of text. This
  * mostly works in bytes, but the TextPieces themselves work in characters. This
@@ -34,7 +33,7 @@ import java.util.List;
  * @author Ryan Ackley
  */
 public final class TextPieceTable implements CharIndexTranslator {
-	protected ArrayList _textPieces = new ArrayList();
+	protected ArrayList<TextPiece> _textPieces = new ArrayList<TextPiece>();
 	// int _multiple;
 	int _cpMin;
 
@@ -97,7 +96,7 @@ public final class TextPieceTable implem
 
 		// In the interest of our sanity, now sort the text pieces
 		// into order, if they're not already
-		TextPiece[] tp = (TextPiece[]) _textPieces.toArray(new TextPiece[_textPieces.size()]);
+		TextPiece[] tp = _textPieces.toArray(new TextPiece[_textPieces.size()]);
 		Arrays.sort(tp);
 		for (int i = 0; i < tp.length; i++) {
 			_textPieces.set(i, tp[i]);
@@ -108,7 +107,7 @@ public final class TextPieceTable implem
 		return _cpMin;
 	}
 
-	public List getTextPieces() {
+	public List<TextPiece> getTextPieces() {
 		return _textPieces;
 	}
 
@@ -123,9 +122,7 @@ public final class TextPieceTable implem
 	public boolean isUnicodeAtCharOffset(int cp) {
 		boolean lastWas = false;
 
-		Iterator it = _textPieces.iterator();
-		while (it.hasNext()) {
-			TextPiece tp = (TextPiece) it.next();
+		for(TextPiece tp : _textPieces) {
 			// If the text piece covers the character, all good
 			if (tp.getStart() <= cp && tp.getEnd() >= cp) {
 				return tp.isUnicode();
@@ -141,9 +138,7 @@ public final class TextPieceTable implem
 	public boolean isUnicodeAtByteOffset(int bytePos) {
 		boolean lastWas = false;
 
-		Iterator it = _textPieces.iterator();
-		while (it.hasNext()) {
-			TextPiece tp = (TextPiece) it.next();
+        for(TextPiece tp : _textPieces) {
 			int curByte = tp.getPieceDescriptor().getFilePosition();
 			int pieceEnd = curByte + tp.bytesLength();
 
@@ -168,7 +163,7 @@ public final class TextPieceTable implem
 
 		int size = _textPieces.size();
 		for (int x = 0; x < size; x++) {
-			TextPiece next = (TextPiece) _textPieces.get(x);
+			TextPiece next = _textPieces.get(x);
 			PieceDescriptor pd = next.getPieceDescriptor();
 
 			int offset = docStream.getOffset();
@@ -209,7 +204,7 @@ public final class TextPieceTable implem
 	public int adjustForInsert(int listIndex, int length) {
 		int size = _textPieces.size();
 
-		TextPiece tp = (TextPiece) _textPieces.get(listIndex);
+		TextPiece tp = _textPieces.get(listIndex);
 
 		// Update with the new end
 		tp.setEnd(tp.getEnd() + length);
@@ -243,9 +238,7 @@ public final class TextPieceTable implem
 	public int getCharIndex(int bytePos) {
 		int charCount = 0;
 
-		Iterator it = _textPieces.iterator();
-		while (it.hasNext()) {
-			TextPiece tp = (TextPiece) it.next();
+        for(TextPiece tp : _textPieces) {
 			int pieceStart = tp.getPieceDescriptor().getFilePosition();
 			if (pieceStart >= bytePos) {
 				break;



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


Mime
View raw message