Eclipse warnings, Generics, unused members in some exapmles and scratchpad classes.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1668480 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2015-03-22 21:45:03 +00:00
parent d6f8268e56
commit b983911836
13 changed files with 61 additions and 67 deletions

View File

@ -93,12 +93,12 @@ public class ReadCustomPropertySets
out(" No. of sections: " + sectionCount);
/* Print the list of sections: */
List sections = ps.getSections();
List<Section> sections = ps.getSections();
int nr = 0;
for (Iterator i = sections.iterator(); i.hasNext();)
for (Iterator<Section> i = sections.iterator(); i.hasNext();)
{
/* Print a single section: */
Section sec = (Section) i.next();
Section sec = i.next();
out(" Section " + nr++ + ":");
String s = hex(sec.getFormatID().getBytes());
s = s.substring(0, s.length() - 1);

View File

@ -21,10 +21,10 @@ package org.apache.poi.hdf.event;
import org.apache.poi.hdf.model.util.BTreeSet;
import org.apache.poi.hdf.model.util.NumberFormatter;
import org.apache.poi.hdf.model.hdftypes.*;
import org.apache.poi.util.LittleEndian;
import java.util.ArrayList;
import java.util.List;
@Deprecated
public final class EventBridge implements HDFLowLevelParsingListener
@ -71,11 +71,11 @@ public final class EventBridge implements HDFLowLevelParsingListener
BTreeSet _hdrCharacterRuns = new BTreeSet();
int _sectionCounter = 1;
ArrayList _hdrs = new ArrayList();
List<HeaderFooter[]> _hdrs = new ArrayList<HeaderFooter[]>();
private boolean _holdParagraph = false;
private int _endHoldIndex = -1;
private ArrayList _onHold;
private List<PropertyNode> _onHold;
public EventBridge(HDFParsingListener listener)
{
@ -119,7 +119,7 @@ public final class EventBridge implements HDFLowLevelParsingListener
{
for (int x = 1; x < _sectionCounter; x++)
{
HeaderFooter[] hdrArray = (HeaderFooter[])_hdrs.get(x-1);
HeaderFooter[] hdrArray = _hdrs.get(x-1);
HeaderFooter hf = null;
if (!hdrArray[HeaderFooter.HEADER_EVEN - 1].isEmpty())
@ -210,7 +210,7 @@ public final class EventBridge implements HDFLowLevelParsingListener
_holdParagraph = false;
_endHoldIndex = -1;
flushHeldParagraph();
_onHold = new ArrayList();
_onHold = new ArrayList<PropertyNode>();
}
}
@ -219,7 +219,7 @@ public final class EventBridge implements HDFLowLevelParsingListener
CharacterProperties chp = (CharacterProperties)StyleSheet.uncompressProperty(byteChpx, _currentStd.getCHP(), _stsh);
ArrayList textList = BTreeSet.findProperties(start, end, _text.root);
List<PropertyNode> textList = BTreeSet.findProperties(start, end, _text.root);
String text = getTextFromNodes(textList, start, end);
_listener.characterRun(chp, text, start - _fcMin, end - _fcMin);
@ -241,7 +241,7 @@ public final class EventBridge implements HDFLowLevelParsingListener
}
private void flushHeaderProps(int start, int end)
{
ArrayList list = BTreeSet.findProperties(start, end, _hdrSections.root);
List<PropertyNode> list = BTreeSet.findProperties(start, end, _hdrSections.root);
int size = list.size();
for (int x = 0; x < size; x++)
@ -253,7 +253,7 @@ public final class EventBridge implements HDFLowLevelParsingListener
//SepxNode node = new SepxNode(-1, secStart, secEnd, oldNode.getSepx());
//bodySection(node);
ArrayList parList = BTreeSet.findProperties(secStart, secEnd, _hdrParagraphs.root);
List<PropertyNode> parList = BTreeSet.findProperties(secStart, secEnd, _hdrParagraphs.root);
int parSize = parList.size();
for (int y = 0; y < parSize; y++)
@ -265,7 +265,7 @@ public final class EventBridge implements HDFLowLevelParsingListener
PapxNode parNode = new PapxNode(parStart, parEnd, oldParNode.getPapx());
paragraph(parNode);
ArrayList charList = BTreeSet.findProperties(parStart, parEnd, _hdrCharacterRuns.root);
List<PropertyNode> charList = BTreeSet.findProperties(parStart, parEnd, _hdrCharacterRuns.root);
int charSize = charList.size();
for (int z = 0; z < charSize; z++)
@ -282,7 +282,7 @@ public final class EventBridge implements HDFLowLevelParsingListener
}
}
private String getTextFromNodes(ArrayList list, int start, int end)
private String getTextFromNodes(List<PropertyNode> list, int start, int end)
{
int size = list.size();

View File

@ -36,14 +36,14 @@ import org.apache.poi.hdf.model.hdftypes.PropertyNode;
*
*/
@Deprecated
public final class BTreeSet extends AbstractSet
public final class BTreeSet extends AbstractSet<PropertyNode>
{
/*
* Instance Variables
*/
public BTreeNode root;
private Comparator comparator = null;
private Comparator<PropertyNode> comparator = null;
private int order;
int size = 0;
@ -59,7 +59,7 @@ public final class BTreeSet extends AbstractSet
this(6); // Default order for a BTreeSet is 32
}
public BTreeSet(Collection c)
public BTreeSet(Collection<PropertyNode> c)
{
this(6); // Default order for a BTreeSet is 32
addAll(c);
@ -70,7 +70,7 @@ public final class BTreeSet extends AbstractSet
this(order, null);
}
public BTreeSet(int order, Comparator comparator)
public BTreeSet(int order, Comparator<PropertyNode> comparator)
{
this.order = order;
this.comparator = comparator;
@ -81,18 +81,18 @@ public final class BTreeSet extends AbstractSet
/*
* Public Methods
*/
public boolean add(Object x) throws IllegalArgumentException
public boolean add(PropertyNode x) throws IllegalArgumentException
{
if (x == null) throw new IllegalArgumentException();
return root.insert(x, -1);
}
public boolean contains(Object x)
public boolean contains(PropertyNode x)
{
return root.includes(x);
}
public boolean remove(Object x)
public boolean remove(PropertyNode x)
{
if (x == null) return false;
return root.delete(x, -1);
@ -109,14 +109,14 @@ public final class BTreeSet extends AbstractSet
size = 0;
}
public java.util.Iterator iterator()
public java.util.Iterator<PropertyNode> iterator()
{
return new Iterator();
}
public static ArrayList findProperties(int start, int end, BTreeSet.BTreeNode root)
public static List<PropertyNode> findProperties(int start, int end, BTreeSet.BTreeNode root)
{
ArrayList results = new ArrayList();
List<PropertyNode> results = new ArrayList<PropertyNode>();
BTreeSet.Entry[] entries = root.entries;
for(int x = 0; x < entries.length; x++)
@ -124,7 +124,7 @@ public final class BTreeSet extends AbstractSet
if(entries[x] != null)
{
BTreeSet.BTreeNode child = entries[x].child;
PropertyNode xNode = (PropertyNode)entries[x].element;
PropertyNode xNode = entries[x].element;
if(xNode != null)
{
int xStart = xNode.getStart();
@ -135,7 +135,7 @@ public final class BTreeSet extends AbstractSet
{
if(child != null)
{
ArrayList beforeItems = findProperties(start, end, child);
List<PropertyNode> beforeItems = findProperties(start, end, child);
results.addAll(beforeItems);
}
results.add(xNode);
@ -150,7 +150,7 @@ public final class BTreeSet extends AbstractSet
{
if(child != null)
{
ArrayList beforeItems = findProperties(start, end, child);
List<PropertyNode> beforeItems = findProperties(start, end, child);
results.addAll(beforeItems);
}
break;
@ -158,7 +158,7 @@ public final class BTreeSet extends AbstractSet
}
else if(child != null)
{
ArrayList afterItems = findProperties(start, end, child);
List<PropertyNode> afterItems = findProperties(start, end, child);
results.addAll(afterItems);
}
}
@ -172,9 +172,9 @@ public final class BTreeSet extends AbstractSet
/*
* Private methods
*/
int compare(Object x, Object y)
int compare(PropertyNode x, PropertyNode y)
{
return (comparator == null ? ((Comparable)x).compareTo(y) : comparator.compare(x, y));
return (comparator == null ? x.compareTo(y) : comparator.compare(x, y));
}
@ -192,12 +192,12 @@ public final class BTreeSet extends AbstractSet
* chance of receiving a NullPointerException. The Iterator.delete method is supported.
*/
private class Iterator implements java.util.Iterator
private class Iterator implements java.util.Iterator<PropertyNode>
{
private int index = 0;
private Stack parentIndex = new Stack(); // Contains all parentIndicies for currentNode
private Object lastReturned = null;
private Object next;
private Stack<Integer> parentIndex = new Stack<Integer>(); // Contains all parentIndicies for currentNode
private PropertyNode lastReturned = null;
private PropertyNode next;
private BTreeNode currentNode;
Iterator()
@ -211,7 +211,7 @@ public final class BTreeSet extends AbstractSet
return next != null;
}
public Object next()
public PropertyNode next()
{
if (next == null) throw new NoSuchElementException();
@ -241,7 +241,7 @@ public final class BTreeSet extends AbstractSet
return temp;
}
private Object nextElement()
private PropertyNode nextElement()
{
if (currentNode.isLeaf())
{
@ -250,13 +250,13 @@ public final class BTreeSet extends AbstractSet
else if (!parentIndex.empty())
{ //All elements have been returned, return successor of lastReturned if it exists
currentNode = currentNode.parent;
index = ((Integer)parentIndex.pop()).intValue();
index = parentIndex.pop().intValue();
while (index == currentNode.nrElements)
{
if (parentIndex.empty()) break;
currentNode = currentNode.parent;
index = ((Integer)parentIndex.pop()).intValue();
index = parentIndex.pop().intValue();
}
if (index == currentNode.nrElements) return null; //Reached root and he has no more children
@ -289,7 +289,7 @@ public final class BTreeSet extends AbstractSet
public static class Entry
{
public Object element;
public PropertyNode element;
public BTreeNode child;
}
@ -309,11 +309,11 @@ public final class BTreeSet extends AbstractSet
entries[0] = new Entry();
}
boolean insert(Object x, int parentIndex)
boolean insert(PropertyNode x, int parentIndex)
{
if (isFull())
{ // If full, you must split and promote splitNode before inserting
Object splitNode = entries[nrElements / 2].element;
PropertyNode splitNode = entries[nrElements / 2].element;
BTreeNode rightSibling = split();
if (isRoot())
@ -354,7 +354,7 @@ public final class BTreeSet extends AbstractSet
return false;
}
boolean includes(Object x)
boolean includes(PropertyNode x)
{
int index = childToInsertAt(x, true);
if (index == -1) return true;
@ -362,7 +362,7 @@ public final class BTreeSet extends AbstractSet
return entries[index].child.includes(x);
}
boolean delete(Object x, int parentIndex)
boolean delete(PropertyNode x, int parentIndex)
{
int i = childToInsertAt(x, true);
int priorParentIndex = parentIndex;
@ -438,7 +438,7 @@ public final class BTreeSet extends AbstractSet
* Creates a new BTreeSet.root which contains only the splitNode and pointers
* to it's left and right child.
*/
private void splitRoot(Object splitNode, BTreeNode left, BTreeNode right)
private void splitRoot(PropertyNode splitNode, BTreeNode left, BTreeNode right)
{
BTreeNode newRoot = new BTreeNode(null);
newRoot.entries[0].element = splitNode;
@ -450,7 +450,7 @@ public final class BTreeSet extends AbstractSet
BTreeSet.this.root = newRoot;
}
private void insertSplitNode(Object splitNode, BTreeNode left, BTreeNode right, int insertAt)
private void insertSplitNode(PropertyNode splitNode, BTreeNode left, BTreeNode right, int insertAt)
{
for (int i = nrElements; i >= insertAt; i--) entries[i + 1] = entries[i];
@ -462,7 +462,7 @@ public final class BTreeSet extends AbstractSet
nrElements++;
}
private void insertNewElement(Object x, int insertAt)
private void insertNewElement(PropertyNode x, int insertAt)
{
for (int i = nrElements; i > insertAt; i--) entries[i] = entries[i - 1];
@ -482,7 +482,7 @@ public final class BTreeSet extends AbstractSet
* element is contained in the calling BTreeNode than the position of the element
* in entries[] is returned.
*/
private int childToInsertAt(Object x, boolean position)
private int childToInsertAt(PropertyNode x, boolean position)
{
int index = nrElements / 2;
@ -509,7 +509,7 @@ public final class BTreeSet extends AbstractSet
}
private void deleteElement(Object x)
private void deleteElement(PropertyNode x)
{
int index = childToInsertAt(x, false);
for (; index < (nrElements - 1); index++) entries[index] = entries[index + 1];
@ -568,12 +568,12 @@ public final class BTreeSet extends AbstractSet
}
}
private void switchWithSuccessor(Object x)
private void switchWithSuccessor(PropertyNode x)
{
int index = childToInsertAt(x, false);
BTreeNode temp = entries[index + 1].child;
while (temp.entries[0] != null && temp.entries[0].child != null) temp = temp.entries[0].child;
Object successor = temp.entries[0].element;
PropertyNode successor = temp.entries[0].element;
temp.entries[0].element = entries[index].element;
entries[index].element = successor;
}

View File

@ -1034,7 +1034,6 @@ public abstract class AbstractWordConverter
}
}
@SuppressWarnings( "unused" )
protected boolean processOle2( HWPFDocument wordDocument, Element block,
Entry entry ) throws Exception
{

View File

@ -38,7 +38,6 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
* @author Nick Burch
*/
public final class Word6Extractor extends POIOLE2TextExtractor {
private POIFSFileSystem fs;
private HWPFOldDocument doc;
/**
@ -64,7 +63,6 @@ public final class Word6Extractor extends POIOLE2TextExtractor {
* @deprecated Use {@link #Word6Extractor(DirectoryNode)} instead
*/
@Deprecated
@SuppressWarnings( "unused" )
public Word6Extractor( DirectoryNode dir, POIFSFileSystem fs )
throws IOException
{

View File

@ -68,7 +68,6 @@ public final class WordExtractor extends POIOLE2TextExtractor
* @deprecated Use {@link #WordExtractor(DirectoryNode)} instead
*/
@Deprecated
@SuppressWarnings( "unused" )
public WordExtractor( DirectoryNode dir, POIFSFileSystem fs )
throws IOException
{
@ -109,7 +108,11 @@ public final class WordExtractor extends POIOLE2TextExtractor
// Process the first argument as a file
FileInputStream fin = new FileInputStream( args[0] );
WordExtractor extractor = new WordExtractor( fin );
System.out.println( extractor.getText() );
try {
System.out.println( extractor.getText() );
} finally {
extractor.close();
}
}
/**

View File

@ -62,7 +62,6 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
* {@link #CHPFormattedDiskPage(byte[], int, CharIndexTranslator)}
* instead
*/
@SuppressWarnings( "unused" )
public CHPFormattedDiskPage( byte[] documentStream, int offset, int fcMin,
TextPieceTable tpt )
{
@ -145,7 +144,6 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
* @deprecated Use {@link #toByteArray(CharIndexTranslator)} instead
*/
@Deprecated
@SuppressWarnings( "unused" )
protected byte[] toByteArray(CharIndexTranslator translator, int fcMin)
{
return toByteArray( translator );

View File

@ -382,7 +382,7 @@ public final class CharacterProperties
cp.setDttmPropRMark( (DateAndTime) getDttmPropRMark().clone() );
cp.setDttmDispFldRMark( (DateAndTime) getDttmDispFldRMark().clone() );
cp.setXstDispFldRMark( getXstDispFldRMark().clone() );
cp.setShd( (ShadingDescriptor) getShd().clone() );
cp.setShd( getShd().clone() );
cp.setBrc( (BorderCode) getBrc().clone() );
return cp;

View File

@ -570,7 +570,7 @@ public final class CharacterRun extends Range
cp._props.setDttmDispFldRMark((DateAndTime)_props.getDttmDispFldRMark().
clone());
cp._props.setXstDispFldRMark(_props.getXstDispFldRMark().clone());
cp._props.setShd((ShadingDescriptor)_props.getShd().clone());
cp._props.setShd(_props.getShd().clone());
return cp;
}

View File

@ -17,10 +17,6 @@
package org.apache.poi.hwpf.usermodel;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.hwpf.model.ListTables;
import org.apache.poi.util.Internal;
@ -52,7 +48,7 @@ import org.apache.poi.hwpf.sprm.ParagraphSprmCompressor;
*/
public final class HWPFList
{
private static POILogger log = POILogFactory.getLogger( HWPFList.class );
//private static POILogger log = POILogFactory.getLogger( HWPFList.class );
private boolean _ignoreLogicalLeftIdentation = false;
private LFO _lfo;

View File

@ -43,7 +43,7 @@ public final class ParagraphProperties extends PAPAbstractType implements
pp.setBrcBar( (BorderCode) getBrcBar().clone() );
pp.setDcs( getDcs().clone() );
pp.setLspd( (LineSpacingDescriptor) getLspd().clone() );
pp.setShd( (ShadingDescriptor) getShd().clone() );
pp.setShd( getShd().clone() );
pp.setPhe( getPhe().clone() );
return pp;
}

View File

@ -53,7 +53,7 @@ public final class TableCellDescriptor extends TCAbstractType implements
throws CloneNotSupportedException
{
TableCellDescriptor tc = (TableCellDescriptor)super.clone();
tc.setShd( (ShadingDescriptor) getShd().clone() );
tc.setShd( getShd().clone() );
tc.setBrcTop((BorderCode)getBrcTop().clone());
tc.setBrcLeft((BorderCode)getBrcLeft().clone());
tc.setBrcBottom((BorderCode)getBrcBottom().clone());

View File

@ -71,7 +71,7 @@ public final class TableProperties extends TAPAbstractType implements Cloneable
tap.setRgshd( new ShadingDescriptor[getRgshd().length] );
for ( int x = 0; x < getRgshd().length; x++ )
{
tap.getRgshd()[x] = (ShadingDescriptor) getRgshd()[x].clone();
tap.getRgshd()[x] = getRgshd()[x].clone();
}
tap.setBrcBottom( (BorderCode) getBrcBottom().clone() );
@ -81,7 +81,7 @@ public final class TableProperties extends TAPAbstractType implements Cloneable
tap.setBrcTop( (BorderCode) getBrcTop().clone() );
tap.setBrcVertical( (BorderCode) getBrcVertical().clone() );
tap.setShdTable( (ShadingDescriptor) getShdTable().clone() );
tap.setShdTable( getShdTable().clone() );
tap.setRgbrcInsideDefault_0( (BorderCode) getRgbrcInsideDefault_0()
.clone() );