From 7ae1a20f0760c044a6b2a91330c9b31fe7572671 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 30 Jun 2010 14:41:03 +0000 Subject: [PATCH] Fix generics warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@959335 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hwpf/model/CHPBinTable.java | 31 ++++++++----------- .../poi/hwpf/model/CHPFormattedDiskPage.java | 14 ++++----- .../apache/poi/hwpf/model/TextPieceTable.java | 29 +++++++---------- 3 files changed, 31 insertions(+), 43 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java index e19f99fde2..840f7c249d 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java @@ -35,7 +35,7 @@ import org.apache.poi.hwpf.sprm.SprmBuffer; public final class CHPBinTable { /** List of character properties.*/ - protected ArrayList _textRuns = new ArrayList(); + protected ArrayList _textRuns = new ArrayList(); /** 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 getTextRuns() { return _textRuns; } @@ -203,7 +203,7 @@ public final class CHPBinTable endingFc += fcMin; - ArrayList overflow = _textRuns; + ArrayList overflow = _textRuns; do { PropertyNode startingProp = (PropertyNode)overflow.get(0); @@ -230,9 +230,4 @@ public final class CHPBinTable while (overflow != null); tableStream.write(binTable.toByteArray()); } - - - - - } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java index 9f5d724bdd..628fb75d14 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java @@ -42,8 +42,8 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage { private static final int FC_SIZE = 4; - private ArrayList _chpxList = new ArrayList(); - private ArrayList _overFlow; + private ArrayList _chpxList = new ArrayList(); + private ArrayList _overFlow; public CHPFormattedDiskPage() @@ -68,15 +68,15 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage public CHPX getCHPX(int index) { - return (CHPX)_chpxList.get(index); + return _chpxList.get(index); } - public void fill(List filler) + public void fill(List filler) { _chpxList.addAll(filler); } - public ArrayList getOverflow() + public ArrayList getOverflow() { return _overFlow; } @@ -119,7 +119,7 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage 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 extends FormattedDiskPage // see if we couldn't fit some if (index != size) { - _overFlow = new ArrayList(); + _overFlow = new ArrayList(); _overFlow.addAll(_chpxList.subList(index, size)); } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java index 0bc2119755..81849c6fb4 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java @@ -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 _textPieces = new ArrayList(); // int _multiple; int _cpMin; @@ -97,7 +96,7 @@ public final class TextPieceTable implements CharIndexTranslator { // 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 implements CharIndexTranslator { return _cpMin; } - public List getTextPieces() { + public List getTextPieces() { return _textPieces; } @@ -123,9 +122,7 @@ public final class TextPieceTable implements CharIndexTranslator { 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 implements CharIndexTranslator { 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 implements CharIndexTranslator { 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 implements CharIndexTranslator { 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 implements CharIndexTranslator { 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; -- 2.39.5