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 6eb0601159
commit 7ae1a20f07
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
{
/** 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 */
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<CHPX> getTextRuns()
{
return _textRuns;
}
@ -203,7 +203,7 @@ public final class CHPBinTable
endingFc += fcMin;
ArrayList overflow = _textRuns;
ArrayList<CHPX> overflow = _textRuns;
do
{
PropertyNode startingProp = (PropertyNode)overflow.get(0);
@ -230,9 +230,4 @@ public final class CHPBinTable
while (overflow != null);
tableStream.write(binTable.toByteArray());
}
}

View File

@ -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<CHPX> _chpxList = new ArrayList<CHPX>();
private ArrayList<CHPX> _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<CHPX> filler)
{
_chpxList.addAll(filler);
}
public ArrayList getOverflow()
public ArrayList<CHPX> 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<CHPX>();
_overFlow.addAll(_chpxList.subList(index, size));
}

View File

@ -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<TextPiece> _textPieces = new ArrayList<TextPiece>();
// 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<TextPiece> 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;