Fix more HSLF generics warnings

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1024420 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2010-10-19 21:25:41 +00:00
parent 392a97fef4
commit d2d0c131c0
3 changed files with 30 additions and 32 deletions

View File

@ -227,8 +227,8 @@ public final class HSLFSlideShow extends POIDocument {
} }
private Record[] read(byte[] docstream, int usrOffset){ private Record[] read(byte[] docstream, int usrOffset){
ArrayList lst = new ArrayList(); ArrayList<Integer> lst = new ArrayList<Integer>();
HashMap offset2id = new HashMap(); HashMap<Integer,Integer> offset2id = new HashMap<Integer,Integer>();
while (usrOffset != 0){ while (usrOffset != 0){
UserEditAtom usr = (UserEditAtom) Record.buildRecordAtOffset(docstream, usrOffset); UserEditAtom usr = (UserEditAtom) Record.buildRecordAtOffset(docstream, usrOffset);
lst.add(Integer.valueOf(usrOffset)); lst.add(Integer.valueOf(usrOffset));
@ -236,11 +236,9 @@ public final class HSLFSlideShow extends POIDocument {
PersistPtrHolder ptr = (PersistPtrHolder)Record.buildRecordAtOffset(docstream, psrOffset); PersistPtrHolder ptr = (PersistPtrHolder)Record.buildRecordAtOffset(docstream, psrOffset);
lst.add(Integer.valueOf(psrOffset)); lst.add(Integer.valueOf(psrOffset));
Hashtable entries = ptr.getSlideLocationsLookup(); Hashtable<Integer,Integer> entries = ptr.getSlideLocationsLookup();
for (Iterator it = entries.keySet().iterator(); it.hasNext(); ) { for(Integer id : entries.keySet()) {
Integer id = (Integer)it.next(); Integer offset = entries.get(id);
Integer offset = (Integer)entries.get(id);
lst.add(offset); lst.add(offset);
offset2id.put(offset, id); offset2id.put(offset, id);
} }
@ -249,15 +247,15 @@ public final class HSLFSlideShow extends POIDocument {
} }
//sort found records by offset. //sort found records by offset.
//(it is not necessary but SlideShow.findMostRecentCoreRecords() expects them sorted) //(it is not necessary but SlideShow.findMostRecentCoreRecords() expects them sorted)
Object a[] = lst.toArray(); Integer a[] = lst.toArray(new Integer[lst.size()]);
Arrays.sort(a); Arrays.sort(a);
Record[] rec = new Record[lst.size()]; Record[] rec = new Record[lst.size()];
for (int i = 0; i < a.length; i++) { for (int i = 0; i < a.length; i++) {
Integer offset = (Integer)a[i]; Integer offset = a[i];
rec[i] = Record.buildRecordAtOffset(docstream, offset.intValue()); rec[i] = Record.buildRecordAtOffset(docstream, offset.intValue());
if(rec[i] instanceof PersistRecord) { if(rec[i] instanceof PersistRecord) {
PersistRecord psr = (PersistRecord)rec[i]; PersistRecord psr = (PersistRecord)rec[i];
Integer id = (Integer)offset2id.get(offset); Integer id = offset2id.get(offset);
psr.setPersistId(id.intValue()); psr.setPersistId(id.intValue());
} }
} }
@ -379,7 +377,7 @@ public final class HSLFSlideShow extends POIDocument {
POIFSFileSystem outFS = new POIFSFileSystem(); POIFSFileSystem outFS = new POIFSFileSystem();
// The list of entries we've written out // The list of entries we've written out
List writtenEntries = new ArrayList(1); List<String> writtenEntries = new ArrayList<String>(1);
// Write out the Property Streams // Write out the Property Streams
writeProperties(outFS, writtenEntries); writeProperties(outFS, writtenEntries);
@ -388,7 +386,7 @@ public final class HSLFSlideShow extends POIDocument {
// For position dependent records, hold where they were and now are // For position dependent records, hold where they were and now are
// As we go along, update, and hand over, to any Position Dependent // As we go along, update, and hand over, to any Position Dependent
// records we happen across // records we happen across
Hashtable oldToNewPositions = new Hashtable(); Hashtable<Integer,Integer> oldToNewPositions = new Hashtable<Integer,Integer>();
// First pass - figure out where all the position dependent // First pass - figure out where all the position dependent
// records are going to end up, in the new scheme // records are going to end up, in the new scheme
@ -549,13 +547,13 @@ public final class HSLFSlideShow extends POIDocument {
*/ */
public ObjectData[] getEmbeddedObjects() { public ObjectData[] getEmbeddedObjects() {
if (_objects == null) { if (_objects == null) {
List objects = new ArrayList(); List<ObjectData> objects = new ArrayList<ObjectData>();
for (int i = 0; i < _records.length; i++) { for (int i = 0; i < _records.length; i++) {
if (_records[i] instanceof ExOleObjStg) { if (_records[i] instanceof ExOleObjStg) {
objects.add(new ObjectData((ExOleObjStg) _records[i])); objects.add(new ObjectData((ExOleObjStg) _records[i]));
} }
} }
_objects = (ObjectData[]) objects.toArray(new ObjectData[objects.size()]); _objects = objects.toArray(new ObjectData[objects.size()]);
} }
return _objects; return _objects;
} }

View File

@ -209,7 +209,7 @@ public final class Fill {
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
java.util.List lst = bstore.getChildRecords(); java.util.List<EscherRecord> lst = bstore.getChildRecords();
int idx = p.getPropertyValue(); int idx = p.getPropertyValue();
if (idx == 0){ if (idx == 0){
logger.log(POILogger.WARN, "no reference to picture data found "); logger.log(POILogger.WARN, "no reference to picture data found ");

View File

@ -62,7 +62,7 @@ public final class SlideShow {
private Record[] _mostRecentCoreRecords; private Record[] _mostRecentCoreRecords;
// Lookup between the PersitPtr "sheet" IDs, and the position // Lookup between the PersitPtr "sheet" IDs, and the position
// in the mostRecentCoreRecords array // in the mostRecentCoreRecords array
private Hashtable _sheetIdToCoreRecordsLookup; private Hashtable<Integer,Integer> _sheetIdToCoreRecordsLookup;
// Records that are interesting // Records that are interesting
private Document _documentRecord; private Document _documentRecord;
@ -131,7 +131,7 @@ public final class SlideShow {
*/ */
private void findMostRecentCoreRecords() { private void findMostRecentCoreRecords() {
// To start with, find the most recent in the byte offset domain // To start with, find the most recent in the byte offset domain
Hashtable mostRecentByBytes = new Hashtable(); Hashtable<Integer,Integer> mostRecentByBytes = new Hashtable<Integer,Integer>();
for (int i = 0; i < _records.length; i++) { for (int i = 0; i < _records.length; i++) {
if (_records[i] instanceof PersistPtrHolder) { if (_records[i] instanceof PersistPtrHolder) {
PersistPtrHolder pph = (PersistPtrHolder) _records[i]; PersistPtrHolder pph = (PersistPtrHolder) _records[i];
@ -147,7 +147,7 @@ public final class SlideShow {
} }
// Now, update the byte level locations with their latest values // Now, update the byte level locations with their latest values
Hashtable thisSetOfLocations = pph.getSlideLocationsLookup(); Hashtable<Integer,Integer> thisSetOfLocations = pph.getSlideLocationsLookup();
for (int j = 0; j < ids.length; j++) { for (int j = 0; j < ids.length; j++) {
Integer id = Integer.valueOf(ids[j]); Integer id = Integer.valueOf(ids[j]);
mostRecentByBytes.put(id, thisSetOfLocations.get(id)); mostRecentByBytes.put(id, thisSetOfLocations.get(id));
@ -161,11 +161,11 @@ public final class SlideShow {
// We'll also want to be able to turn the slide IDs into a position // We'll also want to be able to turn the slide IDs into a position
// in this array // in this array
_sheetIdToCoreRecordsLookup = new Hashtable(); _sheetIdToCoreRecordsLookup = new Hashtable<Integer,Integer>();
int[] allIDs = new int[_mostRecentCoreRecords.length]; int[] allIDs = new int[_mostRecentCoreRecords.length];
Enumeration ids = mostRecentByBytes.keys(); Enumeration<Integer> ids = mostRecentByBytes.keys();
for (int i = 0; i < allIDs.length; i++) { for (int i = 0; i < allIDs.length; i++) {
Integer id = (Integer) ids.nextElement(); Integer id = ids.nextElement();
allIDs[i] = id.intValue(); allIDs[i] = id.intValue();
} }
Arrays.sort(allIDs); Arrays.sort(allIDs);
@ -182,11 +182,11 @@ public final class SlideShow {
// Is it one we care about? // Is it one we care about?
for (int j = 0; j < allIDs.length; j++) { for (int j = 0; j < allIDs.length; j++) {
Integer thisID = Integer.valueOf(allIDs[j]); Integer thisID = Integer.valueOf(allIDs[j]);
Integer thatRecordAt = (Integer) mostRecentByBytes.get(thisID); Integer thatRecordAt = mostRecentByBytes.get(thisID);
if (thatRecordAt.equals(recordAt)) { if (thatRecordAt.equals(recordAt)) {
// Bingo. Now, where do we store it? // Bingo. Now, where do we store it?
Integer storeAtI = (Integer) _sheetIdToCoreRecordsLookup.get(thisID); Integer storeAtI = _sheetIdToCoreRecordsLookup.get(thisID);
int storeAt = storeAtI.intValue(); int storeAt = storeAtI.intValue();
// Tell it its Sheet ID, if it cares // Tell it its Sheet ID, if it cares
@ -236,7 +236,7 @@ public final class SlideShow {
* the refID * the refID
*/ */
private Record getCoreRecordForRefID(int refID) { private Record getCoreRecordForRefID(int refID) {
Integer coreRecordId = (Integer) _sheetIdToCoreRecordsLookup.get(Integer.valueOf(refID)); Integer coreRecordId = _sheetIdToCoreRecordsLookup.get(Integer.valueOf(refID));
if (coreRecordId != null) { if (coreRecordId != null) {
Record r = _mostRecentCoreRecords[coreRecordId.intValue()]; Record r = _mostRecentCoreRecords[coreRecordId.intValue()];
return r; return r;
@ -289,8 +289,8 @@ public final class SlideShow {
if (masterSLWT != null) { if (masterSLWT != null) {
masterSets = masterSLWT.getSlideAtomsSets(); masterSets = masterSLWT.getSlideAtomsSets();
ArrayList mmr = new ArrayList(); ArrayList<SlideMaster> mmr = new ArrayList<SlideMaster>();
ArrayList tmr = new ArrayList(); ArrayList<TitleMaster> tmr = new ArrayList<TitleMaster>();
for (int i = 0; i < masterSets.length; i++) { for (int i = 0; i < masterSets.length; i++) {
Record r = getCoreRecordForSAS(masterSets[i]); Record r = getCoreRecordForSAS(masterSets[i]);
@ -314,7 +314,6 @@ public final class SlideShow {
_titleMasters = new TitleMaster[tmr.size()]; _titleMasters = new TitleMaster[tmr.size()];
tmr.toArray(_titleMasters); tmr.toArray(_titleMasters);
} }
// Having sorted out the masters, that leaves the notes and slides // Having sorted out the masters, that leaves the notes and slides
@ -323,14 +322,15 @@ public final class SlideShow {
// notesSLWT // notesSLWT
org.apache.poi.hslf.record.Notes[] notesRecords; org.apache.poi.hslf.record.Notes[] notesRecords;
SlideAtomsSet[] notesSets = new SlideAtomsSet[0]; SlideAtomsSet[] notesSets = new SlideAtomsSet[0];
Hashtable slideIdToNotes = new Hashtable(); Hashtable<Integer,Integer> slideIdToNotes = new Hashtable<Integer,Integer>();
if (notesSLWT == null) { if (notesSLWT == null) {
// None // None
notesRecords = new org.apache.poi.hslf.record.Notes[0]; notesRecords = new org.apache.poi.hslf.record.Notes[0];
} else { } else {
// Match up the records and the SlideAtomSets // Match up the records and the SlideAtomSets
notesSets = notesSLWT.getSlideAtomsSets(); notesSets = notesSLWT.getSlideAtomsSets();
ArrayList notesRecordsL = new ArrayList(); ArrayList<org.apache.poi.hslf.record.Notes> notesRecordsL =
new ArrayList<org.apache.poi.hslf.record.Notes>();
for (int i = 0; i < notesSets.length; i++) { for (int i = 0; i < notesSets.length; i++) {
// Get the right core record // Get the right core record
Record r = getCoreRecordForSAS(notesSets[i]); Record r = getCoreRecordForSAS(notesSets[i]);
@ -352,7 +352,7 @@ public final class SlideShow {
} }
} }
notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()]; notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()];
notesRecords = (org.apache.poi.hslf.record.Notes[]) notesRecordsL.toArray(notesRecords); notesRecords = notesRecordsL.toArray(notesRecords);
} }
// Now, do the same thing for our slides // Now, do the same thing for our slides
@ -560,7 +560,7 @@ public final class SlideShow {
sas[oldSlideNumber - 1] = sas[newSlideNumber - 1]; sas[oldSlideNumber - 1] = sas[newSlideNumber - 1];
sas[newSlideNumber - 1] = tmp; sas[newSlideNumber - 1] = tmp;
ArrayList lst = new ArrayList(); ArrayList<Record> lst = new ArrayList<Record>();
for (int i = 0; i < sas.length; i++) { for (int i = 0; i < sas.length; i++) {
lst.add(sas[i].getSlidePersistAtom()); lst.add(sas[i].getSlidePersistAtom());
Record[] r = sas[i].getSlideRecords(); Record[] r = sas[i].getSlideRecords();
@ -569,7 +569,7 @@ public final class SlideShow {
} }
_slides[i].setSlideNumber(i + 1); _slides[i].setSlideNumber(i + 1);
} }
Record[] r = (Record[]) lst.toArray(new Record[lst.size()]); Record[] r = lst.toArray(new Record[lst.size()]);
slwt.setChildRecord(r); slwt.setChildRecord(r);
} }