diff --git a/src/examples/src/org/apache/poi/hpsf/examples/ReadCustomPropertySets.java b/src/examples/src/org/apache/poi/hpsf/examples/ReadCustomPropertySets.java index bf6bcd1f8..8d1a0a9c8 100644 --- a/src/examples/src/org/apache/poi/hpsf/examples/ReadCustomPropertySets.java +++ b/src/examples/src/org/apache/poi/hpsf/examples/ReadCustomPropertySets.java @@ -93,12 +93,12 @@ public class ReadCustomPropertySets out(" No. of sections: " + sectionCount); /* Print the list of sections: */ - List sections = ps.getSections(); + List
sections = ps.getSections(); int nr = 0; - for (Iterator i = sections.iterator(); i.hasNext();) + for (Iterator
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); diff --git a/src/scratchpad/src/org/apache/poi/hdf/event/EventBridge.java b/src/scratchpad/src/org/apache/poi/hdf/event/EventBridge.java index d4f69476b..c38805c41 100644 --- a/src/scratchpad/src/org/apache/poi/hdf/event/EventBridge.java +++ b/src/scratchpad/src/org/apache/poi/hdf/event/EventBridge.java @@ -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 _hdrs = new ArrayList(); private boolean _holdParagraph = false; private int _endHoldIndex = -1; - private ArrayList _onHold; + private List _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(); } } @@ -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 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 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 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 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 list, int start, int end) { int size = list.size(); diff --git a/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java b/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java index 848e74a80..96cc51d6c 100644 --- a/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java +++ b/src/scratchpad/src/org/apache/poi/hdf/model/util/BTreeSet.java @@ -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 { /* * Instance Variables */ public BTreeNode root; - private Comparator comparator = null; + private Comparator 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 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 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 iterator() { return new Iterator(); } - public static ArrayList findProperties(int start, int end, BTreeSet.BTreeNode root) + public static List findProperties(int start, int end, BTreeSet.BTreeNode root) { - ArrayList results = new ArrayList(); + List results = new ArrayList(); 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 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 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 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 { private int index = 0; - private Stack parentIndex = new Stack(); // Contains all parentIndicies for currentNode - private Object lastReturned = null; - private Object next; + private Stack parentIndex = new Stack(); // 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; } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java index 95da85020..0c68acef4 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java @@ -1034,7 +1034,6 @@ public abstract class AbstractWordConverter } } - @SuppressWarnings( "unused" ) protected boolean processOle2( HWPFDocument wordDocument, Element block, Entry entry ) throws Exception { diff --git a/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java b/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java index 1d5ec6336..5807740d7 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java @@ -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 { diff --git a/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java b/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java index dc06fb926..ee0a615eb 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java @@ -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(); + } } /** 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 6b1410071..ee50fb55f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java @@ -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 ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java index fd6d631c7..3c5e25fb6 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java @@ -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; diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java index d02f8ae9b..4181c197f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java @@ -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; } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/HWPFList.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/HWPFList.java index 41bcb9652..6f69f7172 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/HWPFList.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/HWPFList.java @@ -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; diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/ParagraphProperties.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/ParagraphProperties.java index 7583b5904..1dbeae4f8 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/ParagraphProperties.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/ParagraphProperties.java @@ -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; } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableCellDescriptor.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableCellDescriptor.java index 812e3b661..4d01ec891 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableCellDescriptor.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableCellDescriptor.java @@ -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()); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableProperties.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableProperties.java index 31c3d974e..001b3cfb2 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableProperties.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableProperties.java @@ -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() );