return s.toString();
}
private static String byteToHex(byte b) {
- int i = (int)b;
+ int i = b;
if(i<0) {
i += 256;
}
* @throws HSSFUserException User exception condition
*/
protected short processRecord(Record rec) throws HSSFUserException {
- Object obj = _records.get(Short.valueOf(rec.getSid()));
+ List<HSSFListener> listeners = _records.get(Short.valueOf(rec.getSid()));
short userCode = 0;
- if (obj != null) {
- List listeners = (List) obj;
+ if (listeners != null) {
for (int k = 0; k < listeners.size(); k++) {
Object listenObj = listeners.get(k);
* @deprecated Use {@link #EventBasedExcelExtractor(DirectoryNode)} instead
*/
@Deprecated
- @SuppressWarnings( "unused" )
public EventBasedExcelExtractor( DirectoryNode dir, POIFSFileSystem fs )
{
this( dir );
* @deprecated Use {@link #ExcelExtractor(DirectoryNode)} instead
*/
@Deprecated
- @SuppressWarnings( "unused" )
public ExcelExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
this( dir );
}
extractor.setIncludeBlankCells(cmdArgs.shouldShowBlankCells());
extractor.setIncludeHeadersFooters(cmdArgs.shouldIncludeHeadersFooters());
System.out.println(extractor.getText());
+ extractor.close();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
public class DrawingManager
{
EscherDggRecord dgg;
- Map dgMap = new HashMap(); // key = Short(drawingId), value=EscherDgRecord
+ Map<Short, EscherDgRecord> dgMap = new HashMap<Short, EscherDgRecord>(); // key = Short(drawingId), value=EscherDgRecord
public DrawingManager( EscherDggRecord dgg )
{
dg.setLastMSOSPID( -1 );
dgg.addCluster( dgId, 0 );
dgg.setDrawingsSaved( dgg.getDrawingsSaved() + 1 );
- dgMap.put( Short.valueOf( dgId ), dg );
+ dgMap.put( dgId, dg );
return dg;
}
public int allocateShapeId(short drawingGroupId)
{
// Get the last shape id for this drawing group.
- EscherDgRecord dg = (EscherDgRecord) dgMap.get(Short.valueOf(drawingGroupId));
+ EscherDgRecord dg = dgMap.get(drawingGroupId);
int lastShapeId = dg.getLastMSOSPID();
*/
public final class RowBlocksReader {
- private final List _plainRecords;
+ private final List<Record> _plainRecords;
private final SharedValueManager _sfm;
private final MergeCellsRecord[] _mergedCellsRecords;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.NullEscherSerializationListener;
-import org.apache.poi.util.ArrayUtil;
import org.apache.poi.util.LittleEndian;
import java.util.Iterator;
}
byte[] buffer = new byte[getRawDataSize()];
int pos = 0;
- for ( Iterator iterator = getEscherRecords().iterator(); iterator.hasNext(); )
+ for ( Iterator<EscherRecord> iterator = getEscherRecords().iterator(); iterator.hasNext(); )
{
- EscherRecord r = (EscherRecord) iterator.next();
+ EscherRecord r = iterator.next();
pos += r.serialize(pos, buffer, new NullEscherSerializationListener() );
}
}
private int getRawDataSize() {
- List escherRecords = getEscherRecords();
+ List<EscherRecord> escherRecords = getEscherRecords();
byte[] rawData = getRawData();
if (escherRecords.size() == 0 && rawData != null)
{
return rawData.length;
}
int size = 0;
- for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
+ for ( Iterator<EscherRecord> iterator = escherRecords.iterator(); iterator.hasNext(); )
{
- EscherRecord r = (EscherRecord) iterator.next();
+ EscherRecord r = iterator.next();
size += r.getRecordSize();
}
return size;
public Object clone() {
PageBreakRecord result = new HorizontalPageBreakRecord();
- Iterator iterator = getBreaksIterator();
+ Iterator<Break> iterator = getBreaksIterator();
while (iterator.hasNext()) {
- Break original = (Break) iterator.next();
+ Break original = iterator.next();
result.addBreak(original.main, original.subFrom, original.subTo);
}
return result;
public Object clone() {
PageBreakRecord result = new VerticalPageBreakRecord();
- Iterator iterator = getBreaksIterator();
+ Iterator<Break> iterator = getBreaksIterator();
while (iterator.hasNext()) {
- Break original = (Break) iterator.next();
+ Break original = iterator.next();
result.addBreak(original.main, original.subFrom, original.subTo);
}
return result;
public final class MergedCellsTable extends RecordAggregate {
private static int MAX_MERGED_REGIONS = 1027; // enforced by the 8224 byte limit
- private final List _mergedRegions;
+ private final List<CellRangeAddress> _mergedRegions;
/**
* Creates an empty aggregate
*/
public MergedCellsTable() {
- _mergedRegions = new ArrayList();
+ _mergedRegions = new ArrayList<CellRangeAddress>();
}
/**
* @param rs
*/
public void read(RecordStream rs) {
- List temp = _mergedRegions;
+ List<CellRangeAddress> temp = _mergedRegions;
while (rs.peekNextClass() == MergeCellsRecord.class) {
MergeCellsRecord mcr = (MergeCellsRecord) rs.getNext();
int nRegions = mcr.getNumAreas();
public CellRangeAddress get(int index) {
checkIndex(index);
- return (CellRangeAddress) _mergedRegions.get(index);
+ return _mergedRegions.get(index);
}
public void remove(int index) {
private int _offset;
private int _fontIndex;
- protected CTFormat(short offset,short fontIdx){
- _offset = offset;
- _fontIndex = fontIdx;
- }
-
public CTFormat(RecordInputStream in) {
_offset = in.readShort();
_fontIndex = in.readShort();
g2D = (Graphics2D)img.getGraphics();\r
}\r
\r
- public void addRenderingHints(Map hints)\r
+ public void addRenderingHints(Map<?,?> hints)\r
{\r
System.out.println( "addRenderingHinds(Map):" );\r
System.out.println( " hints = " + hints );\r
g2D.setRenderingHint( hintKey, hintValue );\r
}\r
\r
- public void setRenderingHints(Map hints)\r
+ public void setRenderingHints(Map<?,?> hints)\r
{\r
System.out.println( "setRenderingHints(Map):" );\r
System.out.println( "hints = " + hints );\r
return null;
}
- @SuppressWarnings("deprecation")
public Rectangle getClipRect()
{
return getClipBounds();
setColor(Color.black);
}
- public void addRenderingHints(Map map)
+ public void addRenderingHints(Map<?, ?> map)
{
getG2D().addRenderingHints(map);
}
getG2D().setRenderingHint(key, obj);
}
- public void setRenderingHints(Map map)
+ public void setRenderingHints(Map<?, ?> map)
{
getG2D().setRenderingHints(map);
}
HSSFDataFormat(InternalWorkbook workbook) {
_workbook = workbook;
- @SuppressWarnings("unchecked")
Iterator<FormatRecord> i = workbook.getFormats().iterator();
while (i.hasNext()) {
FormatRecord r = i.next();
{
byte charset = font.getCharset();
if(charset >= 0) {
- return (int)charset;
+ return charset;
} else {
return charset + 256;
}
* 0 and 255, so distance calculations work as expected.
*/
private int unsignedInt(byte b) {
- return 0xFF & ((int) b);
+ return 0xFF & b;
}
/**
* Alias for {@link #cellIterator} to allow
* foreach loops
*/
- public Iterator iterator() {
+ public Iterator<Cell> iterator() {
return cellIterator();
}
*/
public int countOfAllChildren() {
int count = shapes.size();
- for (Iterator iterator = shapes.iterator(); iterator.hasNext(); ) {
- HSSFShape shape = (HSSFShape) iterator.next();
+ for (Iterator<HSSFShape> iterator = shapes.iterator(); iterator.hasNext(); ) {
+ HSSFShape shape = iterator.next();
count += shape.countOfAllChildren();
}
return count;
Integer index1 = Integer.valueOf(color.getIndex());
if (result.containsKey(index1)) {
- HSSFColor prevColor = (HSSFColor)result.get(index1);
+ HSSFColor prevColor = result.get(index1);
throw new RuntimeException("Dup color index (" + index1
+ ") for colors (" + prevColor.getClass().getName()
+ "),(" + color.getClass().getName() + ")");
return ErrorEval.VALUE_INVALID;\r
}\r
\r
- int code = (int)text.charAt(0);\r
+ int code = text.charAt(0);\r
\r
return new StringEval(String.valueOf(code));\r
}\r
\r
package org.apache.poi.ss.formula.functions;\r
\r
-import org.apache.poi.ss.formula.OperationEvaluationContext;\r
-import org.apache.poi.ss.formula.eval.*;\r
-\r
import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
+\r
+import org.apache.poi.ss.formula.OperationEvaluationContext;\r
+import org.apache.poi.ss.formula.eval.ErrorEval;\r
+import org.apache.poi.ss.formula.eval.EvaluationException;\r
+import org.apache.poi.ss.formula.eval.OperandResolver;\r
+import org.apache.poi.ss.formula.eval.StringEval;\r
+import org.apache.poi.ss.formula.eval.ValueEval;\r
\r
/**\r
* Implementation for Excel ImReal() function.<p/>\r
package org.apache.poi.ss.formula.functions;
-import org.apache.poi.ss.formula.*;
-import org.apache.poi.ss.formula.functions.*;
import org.apache.poi.ss.formula.eval.*;
/**
* @return whether the character is printable
*/
private boolean isPrintable(char c){
- int charCode = (int)c ;
+ int charCode = c;
return charCode >= 32;
}
};
if (exactDenom > 0){\r
fract = SimpleFraction.buildFractionExactDenominator(decPart, exactDenom);\r
} else {\r
- fract = SimpleFraction.buildFractionMaxDenominator((double)decPart, maxDenom);\r
+ fract = SimpleFraction.buildFractionMaxDenominator(decPart, maxDenom);\r
}\r
} catch (RuntimeException e){\r
e.printStackTrace();\r
*/
public class SheetReferences
{
- Map map;
+ Map<Integer, String> map;
public SheetReferences()
{
- map = new HashMap(5);
+ map = new HashMap<Integer, String>(5);
}
public void addSheetReference(String sheetName, int number) {
- map.put(Integer.valueOf(number), sheetName);
+ map.put(number, sheetName);
}
public String getSheetName(int number) {
- return (String)map.get(Integer.valueOf(number));
+ return map.get(number);
}
}