Fix generics warnings

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@959335 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2010-06-30 14:41:03 +00:00
parent da6d33456f
commit 0910eb1ab5
3 changed files with 31 additions and 43 deletions

View File

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

View File

@ -42,8 +42,8 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
{ {
private static final int FC_SIZE = 4; private static final int FC_SIZE = 4;
private ArrayList _chpxList = new ArrayList(); private ArrayList<CHPX> _chpxList = new ArrayList<CHPX>();
private ArrayList _overFlow; private ArrayList<CHPX> _overFlow;
public CHPFormattedDiskPage() public CHPFormattedDiskPage()
@ -68,15 +68,15 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
public CHPX getCHPX(int index) 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); _chpxList.addAll(filler);
} }
public ArrayList getOverflow() public ArrayList<CHPX> getOverflow()
{ {
return _overFlow; return _overFlow;
} }
@ -119,7 +119,7 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
int index = 0; int index = 0;
for (; index < size; index++) 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, // check to see if we have enough room for an FC, the grpprl offset,
// the grpprl size byte and the grpprl. // the grpprl size byte and the grpprl.
@ -142,7 +142,7 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
// see if we couldn't fit some // see if we couldn't fit some
if (index != size) if (index != size)
{ {
_overFlow = new ArrayList(); _overFlow = new ArrayList<CHPX>();
_overFlow.addAll(_chpxList.subList(index, size)); _overFlow.addAll(_chpxList.subList(index, size));
} }

View File

@ -17,15 +17,14 @@
package org.apache.poi.hwpf.model; 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.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator;
import java.util.List; 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 * 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 * mostly works in bytes, but the TextPieces themselves work in characters. This
@ -34,7 +33,7 @@ import java.util.List;
* @author Ryan Ackley * @author Ryan Ackley
*/ */
public final class TextPieceTable implements CharIndexTranslator { public final class TextPieceTable implements CharIndexTranslator {
protected ArrayList _textPieces = new ArrayList(); protected ArrayList<TextPiece> _textPieces = new ArrayList<TextPiece>();
// int _multiple; // int _multiple;
int _cpMin; int _cpMin;
@ -97,7 +96,7 @@ public final class TextPieceTable implements CharIndexTranslator {
// In the interest of our sanity, now sort the text pieces // In the interest of our sanity, now sort the text pieces
// into order, if they're not already // 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); Arrays.sort(tp);
for (int i = 0; i < tp.length; i++) { for (int i = 0; i < tp.length; i++) {
_textPieces.set(i, tp[i]); _textPieces.set(i, tp[i]);
@ -108,7 +107,7 @@ public final class TextPieceTable implements CharIndexTranslator {
return _cpMin; return _cpMin;
} }
public List getTextPieces() { public List<TextPiece> getTextPieces() {
return _textPieces; return _textPieces;
} }
@ -123,9 +122,7 @@ public final class TextPieceTable implements CharIndexTranslator {
public boolean isUnicodeAtCharOffset(int cp) { public boolean isUnicodeAtCharOffset(int cp) {
boolean lastWas = false; boolean lastWas = false;
Iterator it = _textPieces.iterator(); for(TextPiece tp : _textPieces) {
while (it.hasNext()) {
TextPiece tp = (TextPiece) it.next();
// If the text piece covers the character, all good // If the text piece covers the character, all good
if (tp.getStart() <= cp && tp.getEnd() >= cp) { if (tp.getStart() <= cp && tp.getEnd() >= cp) {
return tp.isUnicode(); return tp.isUnicode();
@ -141,9 +138,7 @@ public final class TextPieceTable implements CharIndexTranslator {
public boolean isUnicodeAtByteOffset(int bytePos) { public boolean isUnicodeAtByteOffset(int bytePos) {
boolean lastWas = false; boolean lastWas = false;
Iterator it = _textPieces.iterator(); for(TextPiece tp : _textPieces) {
while (it.hasNext()) {
TextPiece tp = (TextPiece) it.next();
int curByte = tp.getPieceDescriptor().getFilePosition(); int curByte = tp.getPieceDescriptor().getFilePosition();
int pieceEnd = curByte + tp.bytesLength(); int pieceEnd = curByte + tp.bytesLength();
@ -168,7 +163,7 @@ public final class TextPieceTable implements CharIndexTranslator {
int size = _textPieces.size(); int size = _textPieces.size();
for (int x = 0; x < size; x++) { for (int x = 0; x < size; x++) {
TextPiece next = (TextPiece) _textPieces.get(x); TextPiece next = _textPieces.get(x);
PieceDescriptor pd = next.getPieceDescriptor(); PieceDescriptor pd = next.getPieceDescriptor();
int offset = docStream.getOffset(); int offset = docStream.getOffset();
@ -209,7 +204,7 @@ public final class TextPieceTable implements CharIndexTranslator {
public int adjustForInsert(int listIndex, int length) { public int adjustForInsert(int listIndex, int length) {
int size = _textPieces.size(); int size = _textPieces.size();
TextPiece tp = (TextPiece) _textPieces.get(listIndex); TextPiece tp = _textPieces.get(listIndex);
// Update with the new end // Update with the new end
tp.setEnd(tp.getEnd() + length); tp.setEnd(tp.getEnd() + length);
@ -243,9 +238,7 @@ public final class TextPieceTable implements CharIndexTranslator {
public int getCharIndex(int bytePos) { public int getCharIndex(int bytePos) {
int charCount = 0; int charCount = 0;
Iterator it = _textPieces.iterator(); for(TextPiece tp : _textPieces) {
while (it.hasNext()) {
TextPiece tp = (TextPiece) it.next();
int pieceStart = tp.getPieceDescriptor().getFilePosition(); int pieceStart = tp.getPieceDescriptor().getFilePosition();
if (pieceStart >= bytePos) { if (pieceStart >= bytePos) {
break; break;