You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/10/19 22:12:19 UTC

svn commit: r1024390 - /poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/

Author: nick
Date: Tue Oct 19 20:12:19 2010
New Revision: 1024390

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

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjList.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MainMaster.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PositionDependentRecordContainer.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjList.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjList.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjList.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExObjList.java Tue Oct 19 20:12:19 2010
@@ -43,14 +43,14 @@ public class ExObjList extends RecordCon
 	 * Returns all the ExHyperlinks
 	 */
 	public ExHyperlink[] getExHyperlinks() {
-		ArrayList links = new ArrayList();
+		ArrayList<ExHyperlink> links = new ArrayList<ExHyperlink>();
 		for(int i=0; i<_children.length; i++) {
 			if(_children[i] instanceof ExHyperlink) {
-				links.add(_children[i]);
+				links.add( (ExHyperlink)_children[i] );
 			}
 		}
 
-		return (ExHyperlink[])links.toArray(new ExHyperlink[links.size()]);
+		return links.toArray(new ExHyperlink[links.size()]);
 	}
 
 	/** 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java Tue Oct 19 20:12:19 2010
@@ -165,7 +165,7 @@ public class ExOleObjStg extends RecordA
         myLastOnDiskOffset = offset;
     }
 
-    public void updateOtherRecordReferences(Hashtable oldToNewReferencesLookup) {
+    public void updateOtherRecordReferences(Hashtable<Integer,Integer> oldToNewReferencesLookup) {
         return;
     }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java Tue Oct 19 20:12:19 2010
@@ -30,8 +30,8 @@ import java.util.*;
  */
 
 public final class FontCollection extends RecordContainer {
-    private List fonts;
-	private byte[] _header;
+    private List<String> fonts;
+    private byte[] _header;
 
 	protected FontCollection(byte[] source, int start, int len) {
 		// Grab the header
@@ -41,7 +41,7 @@ public final class FontCollection extend
 		_children = Record.findChildRecords(source,start+8,len-8);
 
 		// Save font names into <code>List</code>
-		fonts = new ArrayList();
+		fonts = new ArrayList<String>();
 		for (int i = 0; i < _children.length; i++){
 			if(_children[i] instanceof FontEntityAtom) {
 	            FontEntityAtom atom = (FontEntityAtom)_children[i];
@@ -123,6 +123,6 @@ public final class FontCollection extend
 			// No font with that id
 			return null;
 		}
-		return (String)fonts.get(id);
+		return fonts.get(id);
 	}
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MainMaster.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MainMaster.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MainMaster.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MainMaster.java Tue Oct 19 20:12:19 2010
@@ -63,8 +63,8 @@ public final class MainMaster extends Sh
 		// Find our children
 		_children = Record.findChildRecords(source,start+8,len-8);
 
-		ArrayList tx = new ArrayList();
-		ArrayList clr = new ArrayList();
+		ArrayList<TxMasterStyleAtom> tx = new ArrayList<TxMasterStyleAtom>();
+		ArrayList<ColorSchemeAtom> clr = new ArrayList<ColorSchemeAtom>();
 		// Find the interesting ones in there
 		for(int i=0; i<_children.length; i++) {
 			if(_children[i] instanceof SlideAtom) {
@@ -72,9 +72,9 @@ public final class MainMaster extends Sh
 			} else if(_children[i] instanceof PPDrawing) {
 				ppDrawing = (PPDrawing)_children[i];
 			} else if(_children[i] instanceof TxMasterStyleAtom) {
-				tx.add(_children[i]);
+				tx.add( (TxMasterStyleAtom)_children[i] );
 			} else if(_children[i] instanceof ColorSchemeAtom) {
-				clr.add(_children[i]);
+				clr.add( (ColorSchemeAtom)_children[i] );
 			}
 
 			if(ppDrawing != null && _children[i] instanceof ColorSchemeAtom) {
@@ -82,8 +82,8 @@ public final class MainMaster extends Sh
 			}
 
 		}
-		txmasters = (TxMasterStyleAtom[])tx.toArray(new TxMasterStyleAtom[tx.size()]);
-		clrscheme = (ColorSchemeAtom[])clr.toArray(new ColorSchemeAtom[clr.size()]);
+		txmasters = tx.toArray(new TxMasterStyleAtom[tx.size()]);
+		clrscheme = clr.toArray(new ColorSchemeAtom[clr.size()]);
 	}
 
 	/**

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PositionDependentRecordContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PositionDependentRecordContainer.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PositionDependentRecordContainer.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PositionDependentRecordContainer.java Tue Oct 19 20:12:19 2010
@@ -60,7 +60,7 @@ public abstract class PositionDependentR
 	 * Since we're a container, we don't mind if other records move about.
 	 * If we're told they have, just return straight off.
 	 */
-	public void updateOtherRecordReferences(Hashtable oldToNewReferencesLookup) {
+	public void updateOtherRecordReferences(Hashtable<Integer,Integer> oldToNewReferencesLookup) {
 		return;
 	}
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java Tue Oct 19 20:12:19 2010
@@ -19,11 +19,13 @@ package org.apache.poi.hslf.record;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
 import org.apache.poi.util.POILogFactory;
-import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
+import org.apache.poi.util.POILogger;
 
 /**
  * This abstract class represents a record in the PowerPoint document.
@@ -105,7 +107,7 @@ public abstract class Record
 	 * Default method for finding child records of a container record
 	 */
 	public static Record[] findChildRecords(byte[] b, int start, int len) {
-		Vector children = new Vector(5);
+		List<Record> children = new ArrayList<Record>(5);
 
 		// Jump our little way along, creating records as we go
 		int pos = start;
@@ -134,10 +136,7 @@ public abstract class Record
 		}
 
 		// Turn the vector into an array, and return
-		Record[] cRecords = new Record[children.size()];
-		for(int i=0; i < children.size(); i++) {
-			cRecords[i] = (Record)children.get(i);
-		}
+		Record[] cRecords = children.toArray( new Record[children.size()] );
 		return cRecords;
 	}
 
@@ -165,7 +164,7 @@ public abstract class Record
 		// A spot of reflection gets us the (byte[],int,int) constructor
 		// From there, we instanciate the class
 		// Any special record handling occurs once we have the class
-		Class c = null;
+		Class<? extends Record> c = null;
 		try {
 			c = RecordTypes.recordHandlingClass((int)type);
 			if(c == null) {
@@ -177,9 +176,9 @@ public abstract class Record
 			}
 
 			// Grab the right constructor
-			java.lang.reflect.Constructor con = c.getDeclaredConstructor(new Class[] { byte[].class, Integer.TYPE, Integer.TYPE });
+			java.lang.reflect.Constructor<? extends Record> con = c.getDeclaredConstructor(new Class[] { byte[].class, Integer.TYPE, Integer.TYPE });
 			// Instantiate
-			toReturn = (Record)(con.newInstance(new Object[] { b, Integer.valueOf(start), Integer.valueOf(len) }));
+			toReturn = con.newInstance(new Object[] { b, Integer.valueOf(start), Integer.valueOf(len) });
 		} catch(InstantiationException ie) {
 			throw new RuntimeException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ie, ie);
 		} catch(java.lang.reflect.InvocationTargetException ite) {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java Tue Oct 19 20:12:19 2010
@@ -31,8 +31,8 @@ import java.lang.reflect.Field;
  * @author Nick Burch
  */
 public final class RecordTypes {
-    public static HashMap typeToName;
-    public static HashMap typeToClass;
+    public static HashMap<Integer,String> typeToName;
+    public static HashMap<Integer,Class<? extends Record>> typeToClass;
 
     public static final Type Unknown = new Type(0,null);
     public static final Type Document = new Type(1000,Document.class);
@@ -217,7 +217,7 @@ public final class RecordTypes {
      * @return name of the record
      */
     public static String recordName(int type) {
-        String name = (String)typeToName.get(Integer.valueOf(type));
+        String name = typeToName.get(Integer.valueOf(type));
         if (name == null) name = "Unknown" + type;
         return name;
     }
@@ -231,33 +231,33 @@ public final class RecordTypes {
      * @param type section of the record header
      * @return class to handle the record, or null if an unknown (eg Escher) record
      */
-	public static Class recordHandlingClass(int type) {
-		Class c = (Class)typeToClass.get(Integer.valueOf(type));
+	public static Class<? extends Record> recordHandlingClass(int type) {
+		Class<? extends Record> c = typeToClass.get(Integer.valueOf(type));
 		return c;
 	}
 
     static {
-		typeToName = new HashMap();
-		typeToClass = new HashMap();
+		typeToName = new HashMap<Integer,String>();
+		typeToClass = new HashMap<Integer,Class<? extends Record>>();
         try {
             Field[] f = RecordTypes.class.getFields();
             for (int i = 0; i < f.length; i++){
-                Object val = f[i].get(null);
+               Object val = f[i].get(null);
 
-				// Escher record, only store ID -> Name
-                if (val instanceof Integer) {
-                    typeToName.put(val, f[i].getName());
-                }
-				// PowerPoint record, store ID -> Name and ID -> Class
-				if (val instanceof Type) {
-					Type t = (Type)val;
-					Class c = t.handlingClass;
-					Integer id = Integer.valueOf(t.typeID);
-					if(c == null) { c = UnknownRecordPlaceholder.class; }
-
-                    typeToName.put(id, f[i].getName());
-                    typeToClass.put(id, c);
-				}
+               // Escher record, only store ID -> Name
+               if (val instanceof Integer) {
+                  typeToName.put((Integer)val, f[i].getName());
+               }
+               // PowerPoint record, store ID -> Name and ID -> Class
+               if (val instanceof Type) {
+                  Type t = (Type)val;
+                  Class<? extends Record> c = t.handlingClass;
+                  Integer id = Integer.valueOf(t.typeID);
+                  if(c == null) { c = UnknownRecordPlaceholder.class; }
+
+                  typeToName.put(id, f[i].getName());
+                  typeToClass.put(id, c);
+               }
             }
         } catch (IllegalAccessException e){
             throw new RuntimeException("Failed to initialize records types");
@@ -272,8 +272,8 @@ public final class RecordTypes {
 	 */
 	public static class Type {
 		public int typeID;
-		public Class handlingClass;
-		public Type(int typeID, Class handlingClass) {
+		public Class<? extends Record> handlingClass;
+		public Type(int typeID, Class<? extends Record> handlingClass) {
 			this.typeID = typeID;
 			this.handlingClass = handlingClass;
 		}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java Tue Oct 19 20:12:19 2010
@@ -82,7 +82,7 @@ public final class SlideListWithText ext
 		// Group our children together into SlideAtomsSets
 		// That way, model layer code can just grab the sets to use,
 		//  without having to try to match the children together
-		Vector sets = new Vector();
+		Vector<SlideAtomsSet> sets = new Vector<SlideAtomsSet>();
 		for(int i=0; i<_children.length; i++) {
 			if(_children[i] instanceof SlidePersistAtom) {
 				// Find where the next SlidePersistAtom is
@@ -108,10 +108,7 @@ public final class SlideListWithText ext
 		}
 
 		// Turn the vector into an array
-		slideAtomsSets = new SlideAtomsSet[sets.size()];
-		for(int i=0; i<slideAtomsSets.length; i++) {
-			slideAtomsSets[i] = (SlideAtomsSet)sets.get(i);
-		}
+		slideAtomsSets = sets.toArray( new SlideAtomsSet[sets.size()] );
 	}
 
 	/**

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java Tue Oct 19 20:12:19 2010
@@ -115,7 +115,7 @@ public final class TextSpecInfoAtom exte
     }
 
     public TextSpecInfoRun[] getTextSpecInfoRuns(){
-        ArrayList lst = new ArrayList();
+        ArrayList<TextSpecInfoRun> lst = new ArrayList<TextSpecInfoRun>();
         int pos = 0;
         int[] bits = {1, 0, 2};
         while(pos < _data.length) {
@@ -139,8 +139,7 @@ public final class TextSpecInfoAtom exte
             }
             lst.add(run);
         }
-        return (TextSpecInfoRun[])lst.toArray(new TextSpecInfoRun[lst.size()]);
-
+        return lst.toArray(new TextSpecInfoRun[lst.size()]);
     }
 
     public static class TextSpecInfoRun {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java?rev=1024390&r1=1024389&r2=1024390&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java Tue Oct 19 20:12:19 2010
@@ -121,10 +121,10 @@ public final class UserEditAtom extends 
 	 * At write-out time, update the references to PersistPtrs and
 	 *  other UserEditAtoms to point to their new positions
 	 */
-	public void updateOtherRecordReferences(Hashtable oldToNewReferencesLookup) {
+	public void updateOtherRecordReferences(Hashtable<Integer,Integer> oldToNewReferencesLookup) {
 		// Look up the new positions of our preceding UserEditAtomOffset
 		if(lastUserEditAtomOffset != 0) {
-			Integer newLocation = (Integer)oldToNewReferencesLookup.get(Integer.valueOf(lastUserEditAtomOffset));
+			Integer newLocation = oldToNewReferencesLookup.get(Integer.valueOf(lastUserEditAtomOffset));
 			if(newLocation == null) {
 				throw new RuntimeException("Couldn't find the new location of the UserEditAtom that used to be at " + lastUserEditAtomOffset);
 			}
@@ -132,7 +132,7 @@ public final class UserEditAtom extends 
 		}
 
 		// Ditto for our PersistPtr
-		Integer newLocation = (Integer)oldToNewReferencesLookup.get(Integer.valueOf(persistPointersOffset));
+		Integer newLocation = oldToNewReferencesLookup.get(Integer.valueOf(persistPointersOffset));
 		if(newLocation == null) {
 			throw new RuntimeException("Couldn't find the new location of the PersistPtr that used to be at " + persistPointersOffset);
 		}



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