]> source.dussan.org Git - poi.git/commitdiff
fix generic warnings
authorSergey Vladimirov <sergey@apache.org>
Sun, 10 Jul 2011 18:00:06 +0000 (18:00 +0000)
committerSergey Vladimirov <sergey@apache.org>
Sun, 10 Jul 2011 18:00:06 +0000 (18:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1144920 13f79535-47bb-0310-9956-ffa450edef68

19 files changed:
src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
src/scratchpad/src/org/apache/poi/hwpf/model/CachedPropertyNode.java
src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java
src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java
src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java
src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/SavedByTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/ShapesTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFFileSystem.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SectionSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmUtils.java
src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java

index 86e38f34675690e933da60be0803c2d02ef3c958..69013820952604e2c1b993b6d23dff8d1fb2b0a2 100644 (file)
@@ -37,7 +37,6 @@ import org.apache.poi.hwpf.model.FontTable;
 import org.apache.poi.hwpf.model.ListTables;
 import org.apache.poi.hwpf.model.PAPBinTable;
 import org.apache.poi.hwpf.model.PicturesTable;
-import org.apache.poi.hwpf.model.PropertyNode;
 import org.apache.poi.hwpf.model.RevisionMarkAuthorTable;
 import org.apache.poi.hwpf.model.SavedByTable;
 import org.apache.poi.hwpf.model.SectionTable;
@@ -286,7 +285,7 @@ public final class HWPFDocument extends HWPFDocumentCore
 
   public Range getOverallRange() {
          // hack to get the ending cp of the document, Have to revisit this.
-      PropertyNode p =  _tpt.getTextPieces().get(_tpt.getTextPieces().size() - 1);
+      TextPiece p =  _tpt.getTextPieces().get(_tpt.getTextPieces().size() - 1);
 
       return new Range(0, p.getEnd(), this);
   }
index 097fd58a670e37e0b60c90eb22457cb06c10c56d..3097e000482f1fb793abcf47dfbcc41a66d06d03 100644 (file)
@@ -229,7 +229,7 @@ public class CHPBinTable
     int pageNum = docOffset/POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
 
     // get the ending fc
-    PropertyNode lastRun = (PropertyNode)_textRuns.get(_textRuns.size() - 1); 
+    CHPX lastRun = _textRuns.get(_textRuns.size() - 1); 
     int endingFc = lastRun.getEnd();
     endingFc += fcMin;
 
@@ -237,7 +237,7 @@ public class CHPBinTable
     ArrayList<CHPX> overflow = _textRuns;
     do
     {
-      PropertyNode startingProp = (PropertyNode)overflow.get(0);
+      CHPX startingProp = overflow.get(0);
       int start = startingProp.getStart() + fcMin;
 
       CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage();
@@ -250,7 +250,7 @@ public class CHPBinTable
       int end = endingFc;
       if (overflow != null)
       {
-        end = ((PropertyNode)overflow.get(0)).getStart() + fcMin;
+        end = overflow.get(0).getStart() + fcMin;
       }
 
       byte[] intHolder = new byte[4];
index 5de4e53e98d9c1114c00239f218ef8a61fbca0ab..68615dd4ff15116fad4895aad3a8c2335da6a9a1 100644 (file)
@@ -178,7 +178,7 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
       CHPX chpx = null;
       for (int x = 0; x < index; x++)
       {
-        chpx = (CHPX)_chpxList.get(x);
+        chpx = _chpxList.get(x);
         byte[] grpprl = chpx.getGrpprl();
 
             LittleEndian.putInt( buf, fcOffset,
index 51928e6cd5dc290e227da917296fdb1a34029742..ebc3a5f2e5140d495c09c83ffbb03f48f120c4f0 100644 (file)
@@ -24,7 +24,7 @@ import org.apache.poi.hwpf.sprm.SprmBuffer;
 public final class CachedPropertyNode
   extends PropertyNode<CachedPropertyNode>
 {
-  protected SoftReference _propCache;
+  protected SoftReference<Object> _propCache;
 
   public CachedPropertyNode(int start, int end, SprmBuffer buf)
   {
@@ -33,7 +33,7 @@ public final class CachedPropertyNode
 
   protected void fillCache(Object ref)
   {
-    _propCache = new SoftReference(ref);
+    _propCache = new SoftReference<Object>(ref);
   }
 
   protected Object getCacheContents()
index 52e9bbd51c16ff6fb17ef2346669f683b845ac7d..8ec2f79fca716020af81cd2aaf6f8f0a35c3b296 100644 (file)
 
 package org.apache.poi.hwpf.model;
 
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Arrays;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
 
 import org.apache.poi.hwpf.model.io.HWPFOutputStream;
-
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -128,12 +128,12 @@ public final class FIBFieldHandler
 
   private static final int FIELD_SIZE = LittleEndian.INT_SIZE * 2;
 
-  private HashMap _unknownMap = new HashMap();
+  private Map<Integer, UnhandledDataStructure> _unknownMap = new HashMap<Integer, UnhandledDataStructure>();
   private int[] _fields;
 
 
   public FIBFieldHandler(byte[] mainStream, int offset, byte[] tableStream,
-                         HashSet offsetList, boolean areKnown)
+                         HashSet<Integer> offsetList, boolean areKnown)
   {
     int numFields = LittleEndian.getShort(mainStream, offset);
     offset += LittleEndian.SHORT_SIZE;
@@ -208,7 +208,7 @@ public final class FIBFieldHandler
 
     for (int x = 0; x < length; x++)
     {
-      UnhandledDataStructure ds = (UnhandledDataStructure)_unknownMap.get(Integer.valueOf(x));
+      UnhandledDataStructure ds = _unknownMap.get(Integer.valueOf(x));
       if (ds != null)
       {
         LittleEndian.putInt(mainStream, offset, tableStream.getOffset());
index b1578e386976c4c671ec370dddadaffd2138f8f8..40a4fb944690a9513314fda03ccb124d56768161 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hwpf.model;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -30,11 +29,11 @@ import java.util.Map;
  */
 public final class FSPATable
 {
-    private final List _shapes = new ArrayList();
-    private final Map _shapeIndexesByPropertyStart = new HashMap();
-    private final List _text;
+    private final List<FSPA> _shapes = new ArrayList<FSPA>();
+    private final Map<Integer, Integer> _shapeIndexesByPropertyStart = new HashMap<Integer, Integer>();
+    private final List<TextPiece> _text;
 
-    public FSPATable(byte[] tableStream, int fcPlcspa, int lcbPlcspa, List tpt)
+    public FSPATable(byte[] tableStream, int fcPlcspa, int lcbPlcspa, List<TextPiece> tpt)
     {
         _text = tpt;
         // Will be 0 if no drawing objects in document
@@ -54,11 +53,11 @@ public final class FSPATable
 
     public FSPA getFspaFromCp(int cp)
     {
-        Integer idx = (Integer)_shapeIndexesByPropertyStart.get(Integer.valueOf(cp));
+        Integer idx = _shapeIndexesByPropertyStart.get(Integer.valueOf(cp));
         if (idx == null) {
             return null;
         }
-        return (FSPA)_shapes.get(idx.intValue());
+        return _shapes.get(idx.intValue());
     }
 
     public FSPA[] getShapes()
@@ -72,10 +71,10 @@ public final class FSPATable
     {
         StringBuffer buf = new StringBuffer();
         buf.append("[FPSA PLC size=").append(_shapes.size()).append("]\n");
-        for (Iterator it = _shapeIndexesByPropertyStart.keySet().iterator(); it.hasNext(); )
-        {
-            Integer i = (Integer) it.next();
-            FSPA fspa = (FSPA) _shapes.get(((Integer)_shapeIndexesByPropertyStart.get(i)).intValue());
+
+        for (Map.Entry<Integer, Integer> entry: _shapeIndexesByPropertyStart.entrySet()) {
+            Integer i = entry.getKey();
+            FSPA fspa = _shapes.get((entry.getValue()).intValue());
             buf.append("  [FC: ").append(i.toString()).append("] ");
             buf.append(fspa.toString());
             buf.append("\n");
index cc00b7391cdbb6fd88c6e431eac04d9ebc6f25c6..8444c69877c8fd50afcdedb533de7e69480766b9 100644 (file)
 
 package org.apache.poi.hwpf.model;
 
-import java.util.HashSet;
 import java.io.IOException;
+import java.util.HashSet;
 
-import org.apache.poi.hwpf.model.io.*;
-
-
+import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.hwpf.model.types.FIBAbstractType;
 
 /**
@@ -57,7 +55,7 @@ public final class FileInformationBlock extends FIBAbstractType
 
     public void fillVariableFields(byte[] mainDocument, byte[] tableStream)
     {
-      HashSet fieldSet = new HashSet();
+      HashSet<Integer> fieldSet = new HashSet<Integer>();
       fieldSet.add(Integer.valueOf(FIBFieldHandler.STSHF));
       fieldSet.add(Integer.valueOf(FIBFieldHandler.CLX));
       fieldSet.add(Integer.valueOf(FIBFieldHandler.DOP));
index 502e9e6def396bef3f903f3d5ab18d977396483d..8dc28a45a863e47caa44a7dfad74ba8f3aca30e6 100644 (file)
@@ -186,12 +186,12 @@ public class PAPBinTable
   public void adjustForInsert(int listIndex, int length)
   {
     int size = _paragraphs.size();
-    PAPX papx = (PAPX)_paragraphs.get(listIndex);
+    PAPX papx = _paragraphs.get(listIndex);
     papx.setEnd(papx.getEnd() + length);
 
     for (int x = listIndex + 1; x < size; x++)
     {
-      papx = (PAPX)_paragraphs.get(x);
+      papx = _paragraphs.get(x);
       papx.setStart(papx.getStart() + length);
       papx.setEnd(papx.getEnd() + length);
     }
@@ -226,14 +226,14 @@ public class PAPBinTable
     int pageNum = docOffset/POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
 
     // get the ending fc
-    int endingFc = ((PropertyNode)_paragraphs.get(_paragraphs.size() - 1)).getEnd();
+    int endingFc = _paragraphs.get(_paragraphs.size() - 1).getEnd();
     endingFc += fcMin;
 
 
     ArrayList<PAPX> overflow = _paragraphs;
     do
     {
-      PropertyNode startingProp = (PropertyNode)overflow.get(0);
+      PAPX startingProp = overflow.get(0);
       int start = startingProp.getStart() + fcMin;
 
       PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage(_dataStream);
@@ -246,7 +246,7 @@ public class PAPBinTable
       int end = endingFc;
       if (overflow != null)
       {
-        end = ((PropertyNode)overflow.get(0)).getStart() + fcMin;
+        end = overflow.get(0).getStart() + fcMin;
       }
 
       byte[] intHolder = new byte[4];
index f7ffc81db8eba84c6a6566cfaeed411f2f74ac38..91f8c5fb3c988dc8da61eefc3f5803210f4678ad 100644 (file)
@@ -22,11 +22,10 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.StringUtil;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
-
 /**
  * String table containing the history of the last few revisions ("saves") of the document.
  * Read-only for the time being.
@@ -83,7 +82,7 @@ public final class SavedByTable
    *
    * @return the list of entries.
    */
-  public List getEntries()
+  public List<SavedByEntry> getEntries()
   {
     return Collections.unmodifiableList(Arrays.asList(entries));
   }
index 426a24dfec3ff655d79bfc56024b6d0746371e0a..3d42b8866b42d171c8721a61b2861e7b2d0f577e 100644 (file)
@@ -23,15 +23,15 @@ import java.util.List;
 import org.apache.poi.hwpf.usermodel.Shape;
 
 public final class ShapesTable {
-        private List _shapes;
-        private List _shapesVisibili;  //holds visible shapes
+        private List<Shape> _shapes;
+        private List<Shape> _shapesVisibili;  //holds visible shapes
 
         public ShapesTable(byte [] tblStream, FileInformationBlock fib) {
                 PlexOfCps binTable = new PlexOfCps(tblStream,
                      fib.getFcPlcspaMom(), fib.getLcbPlcspaMom(), 26);
 
-                _shapes = new ArrayList();
-                _shapesVisibili = new ArrayList();
+                _shapes = new ArrayList<Shape>();
+                _shapesVisibili = new ArrayList<Shape>();
 
 
                 for(int i = 0; i < binTable.length(); i++) {
@@ -44,11 +44,11 @@ public final class ShapesTable {
                 }
         }
 
-        public List getAllShapes() {
+        public List<Shape> getAllShapes() {
                 return _shapes;
         }
 
-        public List getVisibleShapes() {
+        public List<Shape> getVisibleShapes() {
                 return _shapesVisibili;
         }
 }
index c8e3db2f83ac216c1523b4c32b377c65834dc4e7..09ab2372f6eb726d82af8d5c4468d84636e3704d 100644 (file)
@@ -70,7 +70,7 @@ public class TextPieceTable implements CharIndexTranslator {
                // using the PieceDescriptors, build our list of TextPieces.
                for (int x = 0; x < pieces.length; x++) {
                        int start = pieces[x].getFilePosition();
-                       PropertyNode node = pieceTable.getProperty(x);
+                       GenericPropertyNode node = pieceTable.getProperty(x);
 
                        // Grab the start and end, which are in characters
                        int nodeStartChars = node.getStart();
@@ -173,7 +173,7 @@ public class TextPieceTable implements CharIndexTranslator {
 
                // Now change all subsequent ones
                for (int x = listIndex + 1; x < size; x++) {
-                       tp = (TextPiece) _textPieces.get(x);
+                       tp = _textPieces.get(x);
                        tp.setStart(tp.getStart() + length);
                        tp.setEnd(tp.getEnd() + length);
                }
index eb76f503c81a618fc3c2a208bd4b112440f92da7..79e9b8d62b4630c67991cd0dfa5e49456c4ccd86 100644 (file)
@@ -19,10 +19,11 @@ package org.apache.poi.hwpf.model.io;
 
 
 import java.util.HashMap;
+import java.util.Map;
 
 public final class HWPFFileSystem
 {
-  HashMap _streams = new HashMap();
+  Map<String, HWPFOutputStream> _streams = new HashMap<String, HWPFOutputStream>();
 
   public HWPFFileSystem()
   {
@@ -33,7 +34,7 @@ public final class HWPFFileSystem
 
   public HWPFOutputStream getStream(String name)
   {
-    return (HWPFOutputStream)_streams.get(name);
+    return _streams.get(name);
   }
 
 }
index 9f65d0d485a273dcfd229a481169cf348e35afb7..e65382781919b18d0bd38fa2d69e9f320455509e 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.hwpf.sprm;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.poi.hwpf.usermodel.CharacterProperties;
 import org.apache.poi.util.LittleEndian;
@@ -29,7 +30,7 @@ public final class CharacterSprmCompressor
   }
   public static byte[] compressCharacterProperty(CharacterProperties newCHP, CharacterProperties oldCHP)
   {
-    ArrayList sprmList = new ArrayList();
+    List<byte[]> sprmList = new ArrayList<byte[]>();
     int size = 0;
 
     if (newCHP.isFRMarkDel() != oldCHP.isFRMarkDel())
index 9682847c35f50ac0691cc96cf25a21fc6995ea1b..a35842285dfae0c2520b22d74f52d62e80e4230d 100644 (file)
@@ -35,7 +35,7 @@ public final class ParagraphSprmCompressor
   {
     // page numbers links to Word97-2007BinaryFileFormat(doc)Specification.pdf, accessible from microsoft.com 
 
-    List sprmList = new ArrayList();
+    List<byte[]> sprmList = new ArrayList<byte[]>();
     int size = 0;
 
     // Page 50 of public specification begins
index bce5f59aa2bc76110f4148fefdf347fec2681b30..355dea837443f85032706310094aa4025ab81fe0 100644 (file)
@@ -20,7 +20,8 @@ package org.apache.poi.hwpf.sprm;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.poi.hwpf.usermodel.BorderCode;
 import org.apache.poi.hwpf.usermodel.DateAndTime;
@@ -426,7 +427,7 @@ public final class ParagraphSprmUncompressor
     int[] tabPositions = pap.getRgdxaTab();
     byte[] tabDescriptors = pap.getRgtbd();
 
-    HashMap tabMap = new HashMap();
+    Map<Integer, Byte> tabMap = new HashMap<Integer, Byte>();
     for (int x = 0; x < tabPositions.length; x++)
     {
       tabMap.put(Integer.valueOf(tabPositions[x]), Byte.valueOf(tabDescriptors[x]));
@@ -450,20 +451,15 @@ public final class ParagraphSprmUncompressor
 
     tabPositions = new int[tabMap.size()];
     tabDescriptors = new byte[tabPositions.length];
-    ArrayList list = new ArrayList();
-
-    Iterator keyIT = tabMap.keySet().iterator();
-    while (keyIT.hasNext())
-    {
-      list.add(keyIT.next());
-    }
+    
+    List<Integer> list = new ArrayList<Integer>(tabMap.keySet());
     Collections.sort(list);
 
     for (int x = 0; x < tabPositions.length; x++)
     {
-      Integer key = ((Integer)list.get(x));
+      Integer key = list.get(x);
       tabPositions[x] = key.intValue();
-      tabDescriptors[x] = ((Byte)tabMap.get(key)).byteValue();
+      tabDescriptors[x] = tabMap.get(key).byteValue();
     }
 
     pap.setRgdxaTab(tabPositions);
index aa7502a41e018c0f5cb6ba71dcad61bf8609b86f..552856bcb65cf1d2802c2138807d3a8020195153 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.hwpf.sprm;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 import org.apache.poi.hwpf.usermodel.SectionProperties;
 import org.apache.poi.util.LittleEndian;
@@ -33,7 +34,7 @@ public final class SectionSprmCompressor
   public static byte[] compressSectionProperty(SectionProperties newSEP)
   {
     int size = 0;
-    ArrayList sprmList = new ArrayList();
+    List<byte[]> sprmList = new ArrayList<byte[]>();
 
     if (newSEP.getCnsPgn() != DEFAULT_SEP.getCnsPgn())
     {
index 9f0abda0f924c9b4d2ca9ce9fad82003889556d3..51bc629dc93d1206b629da13173c6ac37cbd4eda 100644 (file)
@@ -40,7 +40,7 @@ public final class SprmUtils
     return buf;
   }
 
-  public static int addSpecialSprm(short instruction, byte[] varParam, List list)
+  public static int addSpecialSprm(short instruction, byte[] varParam, List<byte[]> list)
   {
     byte[] sprm = new byte[varParam.length + 4];
     System.arraycopy(varParam, 0, sprm, 4, varParam.length);
@@ -50,7 +50,7 @@ public final class SprmUtils
     return sprm.length;
   }
 
-  public static int addSprm(short instruction, int param, byte[] varParam, List list)
+  public static int addSprm(short instruction, int param, byte[] varParam, List<byte[]> list)
   {
     int type = (instruction & 0xe000) >> 13;
 
@@ -96,7 +96,7 @@ public final class SprmUtils
     return sprm.length;
   }
 
-  public static byte[] getGrpprl(List sprmList, int size)
+  public static byte[] getGrpprl(List<byte[]> sprmList, int size)
   {
     // spit out the final grpprl
     byte[] grpprl = new byte[size];
@@ -104,7 +104,7 @@ public final class SprmUtils
     int index = 0;
     for (; listSize >= 0; listSize--)
     {
-      byte[] sprm = (byte[])sprmList.remove(0);
+      byte[] sprm = sprmList.remove(0);
       System.arraycopy(sprm, 0, grpprl, index, sprm.length);
       index += sprm.length;
     }
index 195fed56535a118ced34bbc25793b1f450cfbd0f..995179b0700fec0fff2c168c21e0975a7feb0a80 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.hwpf.sprm;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 import org.apache.poi.hwpf.usermodel.BorderCode;
 import org.apache.poi.hwpf.usermodel.TableAutoformatLookSpecifier;
@@ -34,7 +35,7 @@ public final class TableSprmCompressor
   public static byte[] compressTableProperty(TableProperties newTAP)
   {
     int size = 0;
-    ArrayList sprmList = new ArrayList();
+    List<byte[]> sprmList = new ArrayList<byte[]>();
 
     if (newTAP.getJc() != 0)
     {
index 68bdc127f370f8278dd046f4ae670ccf10534800..8fd0cfe7d93fa1f9c77bdfc4013514bbe8c40415 100644 (file)
@@ -998,13 +998,13 @@ public class Range { // TODO -instantiable superclass
         * @return An int array of length 2. The first int is the start index and
         *         the second int is the end index.
         */
-       private int[] findRange(List<? extends PropertyNode> rpl, int min, int start, int end) {
+       private int[] findRange(List<? extends PropertyNode<?>> rpl, int min, int start, int end) {
                int x = min;
 
         if ( rpl.size() == min )
             return new int[] { min, min };
 
-        PropertyNode node = rpl.get( x );
+        PropertyNode<?> node = rpl.get( x );
 
                while (node==null || (node.getEnd() <= start && x < rpl.size() - 1)) {
                        x++;