diff options
Diffstat (limited to 'xmerge/source/pexcel/java/org')
18 files changed, 165 insertions, 164 deletions
diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java index 3a76673e9b99..219670fdfedc 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java @@ -31,6 +31,7 @@ import org.openoffice.xmerge.converter.xml.sxc.ColumnRowInfo; import org.openoffice.xmerge.converter.xml.sxc.Format; import org.openoffice.xmerge.converter.xml.sxc.NameDefinition; import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.BIFFRecord; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.CellValue; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.ColInfo; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.DefinedName; @@ -58,7 +59,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { private int maxRows = 0; private int maxCols = 0; private int wsIndex; - private Iterator cellValue; + private Iterator<BIFFRecord> cellValue; private Format fmt = null; /** @@ -90,7 +91,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { */ public void addDeviceContent(ConvertData cd) throws IOException { - Iterator e = cd.getDocumentEnumeration(); + Iterator<Object> e = cd.getDocumentEnumeration(); wb = (Workbook) e.next(); } @@ -103,7 +104,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { */ public int getNumberOfSheets() { - ArrayList v = wb.getWorksheetNames(); + ArrayList<Object> v = wb.getWorksheetNames(); Debug.log(Debug.TRACE,"Total Number of Sheets : " + v.size()); return (v.size()); } @@ -114,12 +115,12 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * * @return The number of sheets in the WorkBook. */ - public Iterator getNameDefinitions() { + public Iterator<NameDefinition> getNameDefinitions() { - Iterator e = wb.getDefinedNames(); - ArrayList nameDefinitionVector = new ArrayList(); + Iterator<DefinedName> e = wb.getDefinedNames(); + ArrayList<NameDefinition> nameDefinitionVector = new ArrayList<NameDefinition>(); while(e.hasNext()) { - DefinedName dn = (DefinedName)e.next(); + DefinedName dn = e.next(); NameDefinition nameDefinitionEntry = dn.getNameDefinition(); nameDefinitionVector.add(nameDefinitionEntry); } @@ -143,13 +144,13 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * * @return The number of sheets in the WorkBook. */ - public Iterator getColumnRowInfos() { + public Iterator<ColumnRowInfo> getColumnRowInfos() { - ArrayList colRowVector = new ArrayList(); + ArrayList<ColumnRowInfo> colRowVector = new ArrayList<ColumnRowInfo>(); // Collect Columns from worksheet and add them to the vector - for(Iterator e = ws.getColInfos();e.hasNext();) { - ColInfo ci = (ColInfo)e.next(); + for(Iterator<ColInfo> e = ws.getColInfos();e.hasNext();) { + ColInfo ci = e.next(); int repeated = ci.getLast() - ci.getFirst() + 1; ColumnRowInfo colInfo = new ColumnRowInfo( ci.getColWidth(), repeated, @@ -158,8 +159,8 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { } // Collect Rows from worksheet and add them to the vector - for(Iterator e = ws.getRows();e.hasNext();) { - Row rw = (Row)e.next(); + for(Iterator<Row> e = ws.getRows();e.hasNext();) { + Row rw = e.next(); // We will use the repeat field for number (unlike columns rows // cannot be repeated, we have unique record for each row in pxl int repeated = rw.getRowNumber(); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java index 88ddfdb60749..a7b64d94bd2e 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import org.openoffice.xmerge.util.Debug; +import org.openoffice.xmerge.converter.xml.sxc.ColumnRowInfo; import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetEncoder; import org.openoffice.xmerge.converter.xml.sxc.Format; import org.openoffice.xmerge.converter.xml.sxc.BookSettings; @@ -77,7 +78,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { */ public int getNumberOfSheets() { - ArrayList v = wb.getWorksheetNames(); + ArrayList<Object> v = wb.getWorksheetNames(); return (v.size()); } @@ -202,7 +203,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { * @param columnWidths An <code>IntArrayList</code> of column * widths. */ - public void setColumnRows(ArrayList columnRows) throws IOException { + public void setColumnRows(ArrayList<ColumnRowInfo> columnRows) throws IOException { wb.addColInfo(columnRows); } @@ -268,7 +269,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { * @param sheet The required sheet. */ public String getSheetName(int sheet) { - ArrayList v = wb.getWorksheetNames(); + ArrayList<Object> v = wb.getWorksheetNames(); String wsName = (String) (v.get(sheet)); return wsName; diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java index 7c59af8005d5..3a7fc7c5f689 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java @@ -83,7 +83,7 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { protected String getWorkbookName(ConvertData cd) throws IOException { - Iterator e = cd.getDocumentEnumeration(); + Iterator<Object> e = cd.getDocumentEnumeration(); Workbook wb = (Workbook) e.next(); String workbookName = wb.getName(); @@ -102,9 +102,9 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { protected String[] getWorksheetNames(ConvertData cd) throws IOException { - Iterator e = cd.getDocumentEnumeration(); + Iterator<Object> e = cd.getDocumentEnumeration(); Workbook wb = (Workbook) e.next(); - ArrayList v = wb.getWorksheetNames(); + ArrayList<Object> v = wb.getWorksheetNames(); e = v.iterator(); String worksheetNames[] = new String[v.size()]; int i = 0; diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java index ed99b65b061d..89663e0bdeb0 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java @@ -55,7 +55,7 @@ public class FloatNumber extends CellValue { setIxfe(ixfe); setRow(row); setCol(column); - double cellLong = (double) Double.parseDouble(cellContents); + double cellLong = Double.parseDouble(cellContents); num = EndianConverter.writeDouble(cellLong); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java index 777e07dc826d..18fb06030b9c 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java @@ -82,7 +82,7 @@ public class Formula extends CellValue implements OfficeConstants { num = EndianConverter.writeDouble(toExcelSerialTime(fmt.getValue())); } else if(category.equalsIgnoreCase(CELLTYPE_PERCENT)) { Debug.log(Debug.TRACE,"Percent Formula"); - double percent = (double) Double.parseDouble(fmt.getValue()); + double percent = Double.parseDouble(fmt.getValue()); num = EndianConverter.writeDouble(percent); } else if(category.equalsIgnoreCase(CELLTYPE_CURRENCY)) { Debug.log(Debug.TRACE,"Currency Formula"); @@ -98,7 +98,7 @@ public class Formula extends CellValue implements OfficeConstants { num[7]=(byte)0xFF; } else { Debug.log(Debug.TRACE,"Float Formula"); - double cellLong = (double) Double.parseDouble(fmt.getValue()); + double cellLong = Double.parseDouble(fmt.getValue()); num = EndianConverter.writeDouble(cellLong); } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java index 11cbc44723c5..194272bbccb8 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java @@ -35,7 +35,7 @@ public class Row implements BIFFRecord { private byte[] miyRw = new byte[2]; private byte[] grbit = new byte[2]; private byte[] ixfe = new byte[2]; - private float scale = (float) 1; + private float scale = 1; /** * Constructs a pocket Excel Document from the diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java index d3ebde40a97e..9fe4c4fa4f8c 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java @@ -43,14 +43,14 @@ import org.openoffice.xmerge.util.Debug; public class Workbook implements org.openoffice.xmerge.Document, OfficeConstants { - private ArrayList fonts = new ArrayList(); - private ArrayList extendedFormats = new ArrayList(); - private ArrayList worksheets = new ArrayList(); - private ArrayList boundsheets = new ArrayList(); - private ArrayList definedNames = new ArrayList(); + private ArrayList<FontDescription> fonts = new ArrayList<FontDescription>(); + private ArrayList<ExtendedFormat> extendedFormats = new ArrayList<ExtendedFormat>(); + private ArrayList<Worksheet> worksheets = new ArrayList<Worksheet>(); + private ArrayList<BoundSheet> boundsheets = new ArrayList<BoundSheet>(); + private ArrayList<DefinedName> definedNames = new ArrayList<DefinedName>(); private static final CodePage cp; private static final Window1 win1; - private static final BeginningOfFile bof;; + private static final BeginningOfFile bof; private static final Eof eof; private String fileName; @@ -99,27 +99,27 @@ OfficeConstants { public void write(OutputStream os) throws IOException { bof.write(os); cp.write(os); - for(Iterator e = definedNames.iterator();e.hasNext();) { - DefinedName dn = (DefinedName) e.next(); + for(Iterator<DefinedName> e = definedNames.iterator();e.hasNext();) { + DefinedName dn = e.next(); dn.write(os); } win1.write(os); - for(Iterator e = fonts.iterator();e.hasNext();) { - FontDescription fd = (FontDescription) e.next(); + for(Iterator<FontDescription> e = fonts.iterator();e.hasNext();) { + FontDescription fd = e.next(); fd.write(os); } - for(Iterator e = extendedFormats.iterator();e.hasNext();) { - ExtendedFormat xf = (ExtendedFormat) e.next(); + for(Iterator<ExtendedFormat> e = extendedFormats.iterator();e.hasNext();) { + ExtendedFormat xf = e.next(); xf.write(os); } - for(Iterator e = boundsheets.iterator();e.hasNext();) { - BoundSheet bs = (BoundSheet) e.next(); + for(Iterator<BoundSheet> e = boundsheets.iterator();e.hasNext();) { + BoundSheet bs = e.next(); bs.write(os); } eof.write(os); - for(Iterator e = worksheets.iterator();e.hasNext();) { - Worksheet ws = (Worksheet) e.next(); + for(Iterator<Worksheet> e = worksheets.iterator();e.hasNext();) { + Worksheet ws = e.next(); ws.write(os); } } @@ -214,8 +214,8 @@ OfficeConstants { boolean alreadyExists = false; int i = 0; - for(Iterator e = fonts.iterator();e.hasNext();) { - FontDescription fd = (FontDescription) e.next(); + for(Iterator<FontDescription> e = fonts.iterator();e.hasNext();) { + FontDescription fd = e.next(); if(fd.compareTo(f)) { alreadyExists = true; break; @@ -244,8 +244,8 @@ OfficeConstants { boolean alreadyExists = false; int i = 0; - for(Iterator e = extendedFormats.iterator();e.hasNext();) { - ExtendedFormat currentXF = (ExtendedFormat) e.next(); + for(Iterator<ExtendedFormat> e = extendedFormats.iterator();e.hasNext();) { + ExtendedFormat currentXF = e.next(); if(xf.compareTo(currentXF)) { alreadyExists = true; break; @@ -267,7 +267,7 @@ OfficeConstants { */ public Worksheet getWorksheet(int index) { - return ((Worksheet) worksheets.get(index)); + return worksheets.get(index); } /** @@ -279,7 +279,7 @@ OfficeConstants { */ public FontDescription getFontDescription(int ixfnt) { - return (FontDescription) fonts.get(ixfnt); + return fonts.get(ixfnt); } /** @@ -291,7 +291,7 @@ OfficeConstants { */ public ExtendedFormat getExtendedFormat(int ixfe) { - return (ExtendedFormat) extendedFormats.get(ixfe); + return extendedFormats.get(ixfe); } /** @@ -299,7 +299,7 @@ OfficeConstants { * * @return Enumeration for the DefinedNames */ - public Iterator getDefinedNames() { + public Iterator<DefinedName> getDefinedNames() { return definedNames.iterator(); } @@ -311,10 +311,10 @@ OfficeConstants { */ public BookSettings getSettings() { - ArrayList settingsVector = new ArrayList(); + ArrayList<SheetSettings> settingsVector = new ArrayList<SheetSettings>(); int index = 0; - for(Iterator e = worksheets.iterator();e.hasNext();) { - Worksheet ws = (Worksheet) e.next(); + for(Iterator<Worksheet> e = worksheets.iterator();e.hasNext();) { + Worksheet ws = e.next(); SheetSettings s = ws.getSettings(); s.setSheetName(getSheetName(index++)); settingsVector.add(s); @@ -330,9 +330,9 @@ OfficeConstants { * * @return a <code>Vector</code> containing all the worksheet Names */ - public ArrayList getWorksheetNames() { + public ArrayList<Object> getWorksheetNames() { - ArrayList wsNames = new ArrayList(); + ArrayList<Object> wsNames = new ArrayList<Object>(); for(int i = 0;i < boundsheets.size();i++) { wsNames.add(getSheetName(i)); @@ -347,7 +347,7 @@ OfficeConstants { * @return a <code>String</code> containing the name of the worksheet */ public String getSheetName(int index) { - BoundSheet bs = (BoundSheet) boundsheets.get(index); + BoundSheet bs = boundsheets.get(index); return bs.getSheetName(); } @@ -377,7 +377,7 @@ OfficeConstants { public void addCell(int row,int col, Format fmt, String cellContents) throws IOException { - Worksheet currentWS = (Worksheet) worksheets.get(worksheets.size()-1); + Worksheet currentWS = worksheets.get(worksheets.size()-1); int ixfe = addExtendedFormat(fmt); String category = fmt.getCategory(); @@ -429,16 +429,16 @@ OfficeConstants { * * @param columnRows <code>Vector</code> of <code>ColumnRowInfo</code> */ - public void addColInfo(ArrayList columnRows) throws IOException { + public void addColInfo(ArrayList<ColumnRowInfo> columnRows) throws IOException { - Worksheet currentWS = (Worksheet) worksheets.get(worksheets.size()-1); + Worksheet currentWS = worksheets.get(worksheets.size()-1); int nCols = 0; int nRows = 0; Debug.log(Debug.TRACE,"Workbook: addColInfo()"); - for(Iterator e = columnRows.iterator();e.hasNext();) { - ColumnRowInfo cri =(ColumnRowInfo) e.next(); + for(Iterator<ColumnRowInfo> e = columnRows.iterator();e.hasNext();) { + ColumnRowInfo cri =e.next(); int ixfe = 0; int size = cri.getSize(); int repeated = cri.getRepeated(); @@ -485,17 +485,17 @@ OfficeConstants { public void addSettings(BookSettings book) throws IOException { int index = 0; - ArrayList sheetSettings = book.getSheetSettings(); + ArrayList<SheetSettings> sheetSettings = book.getSheetSettings(); String activeSheetName = book.getActiveSheet(); - for(Iterator e = worksheets.iterator();e.hasNext();) { - Worksheet ws = (Worksheet) e.next(); + for(Iterator<Worksheet> e = worksheets.iterator();e.hasNext();) { + Worksheet ws = e.next(); String name = getSheetName(index++); if(activeSheetName.equals(name)) { win1.setActiveSheet(index-1); } - for(Iterator eSettings = sheetSettings.iterator();eSettings.hasNext();) { - SheetSettings s = (SheetSettings) eSettings.next(); + for(Iterator<SheetSettings> eSettings = sheetSettings.iterator();eSettings.hasNext();) { + SheetSettings s = eSettings.next(); if(name.equals(s.getSheetName())) { ws.addSettings(s); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java index ee050f6a7b94..23650d110ab3 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java @@ -40,9 +40,9 @@ public class Worksheet { private String name; private Workbook wb; - private ArrayList rows = new ArrayList(); - private ArrayList colInfo = new ArrayList(); - private ArrayList cells = new ArrayList(); + private ArrayList<Row> rows = new ArrayList<Row>(); + private ArrayList<ColInfo> colInfo = new ArrayList<ColInfo>(); + private ArrayList<BIFFRecord> cells = new ArrayList<BIFFRecord>(); private DefColWidth dcw = new DefColWidth(); private DefRowHeight drh = new DefRowHeight(); private Window2 win2 = new Window2(); @@ -76,17 +76,17 @@ public class Worksheet { bof = new BeginningOfFile(false); bof.write(os); dcw.write(os); - for(Iterator e = colInfo.iterator();e.hasNext();) { - ColInfo ci = (ColInfo) e.next(); + for(Iterator<ColInfo> e = colInfo.iterator();e.hasNext();) { + ColInfo ci = e.next(); ci.write(os); } drh.write(os); - for(Iterator e = rows.iterator();e.hasNext();) { - Row rw = (Row) e.next(); + for(Iterator<Row> e = rows.iterator();e.hasNext();) { + Row rw = e.next(); rw.write(os); } - for(Iterator e = cells.iterator();e.hasNext();) { - BIFFRecord cv = (BIFFRecord) e.next(); + for(Iterator<BIFFRecord> e = cells.iterator();e.hasNext();) { + BIFFRecord cv = e.next(); cv.write(os); } win2.write(os); @@ -215,7 +215,7 @@ public class Worksheet { * * @return an enumerator to the worksheet cells */ - public Iterator getCellEnumerator() throws IOException { + public Iterator<BIFFRecord> getCellEnumerator() throws IOException { return (cells.iterator()); } @@ -271,7 +271,7 @@ public class Worksheet { * * @return an <code>Enumeration</code> to the ColInfo's */ - public Iterator getColInfos() { + public Iterator<ColInfo> getColInfos() { return (colInfo.iterator()); } @@ -301,7 +301,7 @@ public class Worksheet { * * @return an <code>Enumeration</code> to the Rows */ - public Iterator getRows() { + public Iterator<Row> getRows() { return (rows.iterator()); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java index a08bebd57270..cc9f5806a354 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java @@ -91,16 +91,15 @@ public class FormulaCompiler { * @param tokens The tokens in RPN form * @return The vector of tokens re-ordered in Infix notation */ - public ArrayList RPN2Infix(ArrayList tokens) { - ArrayList infixExpr = new ArrayList(15); - ListIterator iter = tokens.listIterator(); - Stack evalStack = new Stack(); - Stack args = new Stack(); + public ArrayList<Token> RPN2Infix(ArrayList<Token> tokens) { + ListIterator<Token> iter = tokens.listIterator(); + Stack<ArrayList<Token>> evalStack = new Stack<ArrayList<Token>>(); + Stack<ArrayList<Token>> args = new Stack<ArrayList<Token>>(); while (iter.hasNext()) { - Token pt = (Token)iter.next(); + Token pt = iter.next(); if (pt.isOperand()) { - ArrayList expr = new ArrayList(5); + ArrayList<Token> expr = new ArrayList<Token>(5); expr.add(pt); evalStack.push(expr); } else if (pt.isOperator() || pt.isFunction()) { @@ -111,7 +110,7 @@ public class FormulaCompiler { evalStack.push(makeExpression(pt, args)); } } - return (ArrayList)evalStack.elementAt(0); + return evalStack.elementAt(0); } /** @@ -123,12 +122,12 @@ public class FormulaCompiler { * * @return A vector of tokens for the expression in Reverse Polish Notation order */ - public ArrayList infix2RPN(ArrayList tokens) { - ArrayList rpnExpr = new ArrayList(15); - Stack evalStack = new Stack(); - ListIterator iter = tokens.listIterator(); + public ArrayList<Token> infix2RPN(ArrayList<Token> tokens) { + ArrayList<Token> rpnExpr = new ArrayList<Token>(15); + Stack<Token> evalStack = new Stack<Token>(); + ListIterator<Token> iter = tokens.listIterator(); while (iter.hasNext()) { - Token pt = (Token)iter.next(); + Token pt = iter.next(); if (pt.isOperand()) { //Operands are output immediately rpnExpr.add(pt); @@ -137,7 +136,7 @@ public class FormulaCompiler { if (pt.isFunction()) { iter.next(); } - ArrayList param = extractParameter(iter); + ArrayList<Token> param = extractParameter(iter); Debug.log(Debug.TRACE, "Extracted parameter " + param); rpnExpr.addAll(infix2RPN(param)); } else if (isCloseBrace(pt)) { //Pop off stack till you meet a function or an open bracket @@ -147,7 +146,7 @@ public class FormulaCompiler { if (evalStack.isEmpty()) { bPop = false; } else { - tmpTok = (Token)evalStack.pop(); + tmpTok = evalStack.pop(); if (!isParamDelimiter(tmpTok)) { //Don't output commas rpnExpr.add(tmpTok); } @@ -159,8 +158,8 @@ public class FormulaCompiler { } else { if (!evalStack.isEmpty()) { while (!evalStack.isEmpty() && - (((Token)evalStack.peek()).getTokenPriority() >=pt.getTokenPriority())) { - Token topTok = (Token)evalStack.peek(); + (evalStack.peek().getTokenPriority() >=pt.getTokenPriority())) { + Token topTok = evalStack.peek(); if (topTok.isFunction() || isOpenBrace(topTok)) { break; } @@ -172,7 +171,7 @@ public class FormulaCompiler { } while (!evalStack.isEmpty()) { - Token topTok = (Token)evalStack.peek(); + Token topTok = evalStack.peek(); if (!(isOpenBrace(topTok) || isParamDelimiter(topTok))) { //Don't output brackets and commas rpnExpr.add(evalStack.pop()); } @@ -189,12 +188,12 @@ public class FormulaCompiler { * @param iter an iterator into the list * @return A complete sub-expression */ - protected ArrayList extractParameter(ListIterator iter) { - ArrayList param = new ArrayList(5); + protected ArrayList<Token> extractParameter(ListIterator<Token> iter) { + ArrayList<Token> param = new ArrayList<Token>(5); int subExprCount = 0; while (iter.hasNext()) { - Token pt = (Token)iter.next(); + Token pt = iter.next(); Debug.log(Debug.TRACE, "Token is " + pt + " and subExprCount is " + subExprCount); if (isOpenBrace(pt)) { subExprCount++; @@ -223,21 +222,21 @@ public class FormulaCompiler { * @param args The arguments for this operator * @return A correctly ordered expression */ - protected ArrayList<Object> makeExpression(Token pt, Stack<ArrayList> args) { - ArrayList<Object> tmp = new ArrayList<Object>(5); + protected ArrayList<Token> makeExpression(Token pt, Stack<ArrayList<Token>> args) { + ArrayList<Token> tmp = new ArrayList<Token>(5); TokenFactory tf = new TokenFactory(); if (pt.isOperator()) { if (pt.getNumArgs()==2) { //Binary operator - tmp.addAll((ArrayList)args.pop()); + tmp.addAll(args.pop()); tmp.add(pt); - tmp.addAll((ArrayList)args.pop()); + tmp.addAll(args.pop()); } else if (pt.getNumArgs() == 1) { if(isPercent(pt)) { - tmp.addAll((ArrayList)args.elementAt(0)); + tmp.addAll(args.elementAt(0)); tmp.add(pt); } else { tmp.add(pt); - tmp.addAll((ArrayList)args.elementAt(0)); + tmp.addAll(args.elementAt(0)); } if (isOpenBrace(pt)) { tmp.add(tf.getOperatorToken(")",1)); @@ -247,12 +246,12 @@ public class FormulaCompiler { tmp.add(pt); tmp.add(tf.getOperatorToken("(",1)); if (!args.isEmpty()) { - ArrayList v = (ArrayList)args.pop(); + ArrayList<Token> v = args.pop(); tmp.addAll(v); } while (!args.isEmpty()) { tmp.add(tf.getOperatorToken(",",1)); - ArrayList v = (ArrayList)args.pop(); + ArrayList<Token> v = args.pop(); tmp.addAll(v); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java index defda65e9881..fa3a183413d2 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java @@ -70,14 +70,14 @@ public class FormulaHelper { */ public byte[] convertCalcToPXL(String formula) throws UnsupportedFunctionException, FormulaParsingException { - ArrayList parseTokens = parser.parse(formula); - ArrayList rpnTokens = compiler.infix2RPN(parseTokens); + ArrayList<Token> parseTokens = parser.parse(formula); + ArrayList<Token> rpnTokens = compiler.infix2RPN(parseTokens); ByteArrayOutputStream bytes = null; try { bytes = new ByteArrayOutputStream(); - for (Iterator e = rpnTokens.iterator(); e.hasNext();) { - Token t = (Token)e.next(); + for (Iterator<Token> e = rpnTokens.iterator(); e.hasNext();) { + Token t = e.next(); bytes.write(encoder.getByte(t)); } } catch (IOException e) { @@ -93,12 +93,12 @@ public class FormulaHelper { */ public String convertPXLToCalc(byte[] formula) { - ArrayList parseTokens = decoder.getTokenVector(formula); - ArrayList infixTokens = compiler.RPN2Infix(parseTokens); + ArrayList<Token> parseTokens = decoder.getTokenVector(formula); + ArrayList<Token> infixTokens = compiler.RPN2Infix(parseTokens); StringBuffer buff = new StringBuffer(); - for (Iterator e = infixTokens.iterator();e.hasNext();) { - Token t = (Token)e.next(); + for (Iterator<Token> e = infixTokens.iterator();e.hasNext();) { + Token t = e.next(); buff.append(t.toString()); // If we are parsing a Name definition we need to know if it is of // type range or expression diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java index 76e01c407dda..9dd327354078 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java @@ -41,7 +41,7 @@ public class FormulaParser { private String formulaStr; private int index = 1; private TokenFactory tokenFactory; - private ArrayList tokenVector; + private ArrayList<Token> tokenVector; private Workbook wb; /** @@ -51,7 +51,7 @@ public class FormulaParser { Debug.log(Debug.TRACE,"Creating a Formula Parser"); tokenFactory = new TokenFactory(); - tokenVector = new ArrayList(); + tokenVector = new ArrayList<Token>(); } /** @@ -69,7 +69,7 @@ public class FormulaParser { * starting with the '=' character * @return A <code>Vector</code> containing the parsed <code>Token</code>s */ - public ArrayList parse(String formula) throws FormulaParsingException { + public ArrayList<Token> parse(String formula) throws FormulaParsingException { index = 1; look = ' '; diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java index dfb8648889d2..a0cba9e566c8 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java @@ -22,7 +22,7 @@ import java.util.HashMap; public class FunctionLookup extends SymbolLookup { - private HashMap stringToArgs = null; + private HashMap<String, Integer> stringToArgs = null; /** * The default constructor - invokes {@link #initialize() initialize()} @@ -38,9 +38,9 @@ public class FunctionLookup extends SymbolLookup { if ((stringToID != null) || (idToString != null) || (stringToArgs !=null)) { return; } - stringToID = new HashMap(); - idToString = new HashMap(); - stringToArgs = new HashMap(); + stringToID = new HashMap<String, Integer>(); + idToString = new HashMap<Integer, String>(); + stringToArgs = new HashMap<String, Integer>(); // Functions with Variable number of Arguments // Math and Trig @@ -190,6 +190,6 @@ public class FunctionLookup extends SymbolLookup { * @return The number of arguments required by this function */ public int getArgCountFromString(String symbol) { - return ((Integer)stringToArgs.get(symbol)).intValue(); + return stringToArgs.get(symbol).intValue(); } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java index 0c836b07ff68..bc4176e8db1a 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java @@ -38,8 +38,8 @@ public class OperandLookup extends SymbolLookup { if ((stringToID != null) || (idToString != null)) { return; } - stringToID = new HashMap(); - idToString = new HashMap(); + stringToID = new HashMap<String, Integer>(); + idToString = new HashMap<Integer, String>(); addEntry("CELL_REFERENCE", TokenConstants.TREF); addEntry("CELL_AREA_REFERENCE", TokenConstants.TAREA); addEntry("INTEGER", TokenConstants.TNUM); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java index 164119cf1e73..73d1a850a33a 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java @@ -39,8 +39,8 @@ public class OperatorLookup extends SymbolLookup { if ((stringToID != null) || (idToString != null)) { return; } - stringToID = new HashMap(); - idToString = new HashMap(); + stringToID = new HashMap<String, Integer>(); + idToString = new HashMap<Integer, String>(); addEntry("UNARY_PLUS", TokenConstants.TUPLUS); addEntry("UNARY_MINUS", TokenConstants.TUMINUS); addEntry("%", TokenConstants.TPERCENT); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java index 5739276d3566..35407090e86d 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java @@ -37,9 +37,9 @@ public class PrecedenceTable { public static final int FUNCTION_PRECEDENCE = 8; public static final int COMMA_PRECEDENCE = 8; - private static HashMap map; + private static HashMap<String,Integer> map; static { - map = new HashMap(); + map = new HashMap<String,Integer>(); map.put("%", new Integer(UNARY_PRECEDENCE)); map.put("+", new Integer(ADDOP_PRECEDENCE)); diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java index 417f800725de..251a6e2869da 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java @@ -26,8 +26,8 @@ import java.util.HashMap; */ public abstract class SymbolLookup { - protected HashMap stringToID = null; - protected HashMap idToString = null; + protected HashMap<String, Integer> stringToID = null; + protected HashMap<Integer, String> idToString = null; /** * Perform lookup table specific initialization. This would typically entail loading values into @@ -53,7 +53,7 @@ public abstract class SymbolLookup { * @return The string associated with this identifier in the lookup table. */ public String getStringFromID(int id) { - return (String)idToString.get(new Integer(id)); + return idToString.get(new Integer(id)); } /** @@ -63,10 +63,10 @@ public abstract class SymbolLookup { * @return The identifier associated with this string in the lookup table. */ public int getIDFromString(String symbol) throws UnsupportedFunctionException { - Integer i = (Integer)stringToID.get(symbol); + Integer i = stringToID.get(symbol); if (i == null) throw new UnsupportedFunctionException("Token '" + symbol + "' not supported by Pocket Excel"); - return ((Integer)stringToID.get(symbol)).intValue(); + return stringToID.get(symbol).intValue(); } } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java index 019197748809..171abb0fdbb1 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java @@ -80,9 +80,9 @@ public class TokenDecoder { * @param formula A Pocket Excel Formula byte[] * @return A <code>Vector</code> of deoded <code>Token</code> */ - public ArrayList getTokenVector(byte[] formula) { + public ArrayList<Token> getTokenVector(byte[] formula) { - ArrayList v = new ArrayList(); + ArrayList<Token> v = new ArrayList<Token>(); ByteArrayInputStream bis = new ByteArrayInputStream(formula); int b = 0 ; @@ -159,7 +159,7 @@ public class TokenDecoder { return v; } - private static Object last(ArrayList list) + private static Object last(ArrayList<Token> list) { return list.get(list.size() - 1); } @@ -184,8 +184,8 @@ public class TokenDecoder { */ private Token readStringToken(ByteArrayInputStream bis) { - int len = ((int)bis.read())*2; - int options = (int)bis.read(); + int len = bis.read()*2; + int options = bis.read(); Debug.log(Debug.TRACE,"String length is " + len + " and Options Flag is " + options); byte [] stringBytes = new byte[len]; int numRead =0; @@ -219,14 +219,14 @@ public class TokenDecoder { buffer[1] = (byte) bis.read(); int nameIndex = EndianConverter.readShort(buffer); bis.skip(12); // the next 12 bytes are unused - Iterator e = wb.getDefinedNames(); + Iterator<DefinedName> e = wb.getDefinedNames(); int i = 1; while(i<nameIndex) { e.next(); i++; } Debug.log(Debug.TRACE,"Name index is " + nameIndex); - DefinedName dn = (DefinedName)e.next(); + DefinedName dn = e.next(); Debug.log(Debug.TRACE,"DefinedName is " + dn.getName()); return (tf.getOperandToken(dn.getName(), "NAME")); } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java index a705d23c322c..d597b2292dbb 100644 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java +++ b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java @@ -75,7 +75,7 @@ public class TokenEncoder { */ public byte[] getByte(Token t) throws IOException { - ArrayList tmpByteArray = null; // we use this cause we don't know till after + ArrayList<Byte> tmpByteArray = null; // we use this cause we don't know till after // the encoding takes place how big the byte [] will be //index=0; // This class is declared static in // FormulaHelper so better make sure our index is 0 @@ -114,8 +114,8 @@ public class TokenEncoder { byte cellRefArray[] = new byte[tmpByteArray.size()]; int i = 0; String s = new String(); - for(Iterator e = tmpByteArray.iterator();e.hasNext();) { - Byte tmpByte = (Byte) e.next(); + for(Iterator<Byte> e = tmpByteArray.iterator();e.hasNext();) { + Byte tmpByte = e.next(); s = s + tmpByte + " "; cellRefArray[i] = tmpByte.byteValue(); i++; @@ -130,9 +130,9 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList operatorEncoder(Token t) { + private ArrayList<Byte> operatorEncoder(Token t) { - ArrayList tmpByteArray = new ArrayList(); + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); tmpByteArray.add(new Byte((byte)t.getTokenID())); return tmpByteArray; } @@ -144,9 +144,9 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList stringEncoder(Token t) throws IOException{ + private ArrayList<Byte> stringEncoder(Token t) throws IOException{ - ArrayList tmpByteArray = new ArrayList(); + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); tmpByteArray.add(new Byte((byte)t.getTokenID())); tmpByteArray.add(new Byte((byte)(t.getValue().length()))); tmpByteArray.add(new Byte((byte)0x01)); @@ -164,11 +164,11 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList numEncoder(Token t) { + private ArrayList<Byte> numEncoder(Token t) { - ArrayList tmpByteArray = new ArrayList(); + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - double cellLong = (double) Double.parseDouble(t.getValue()); + double cellLong = Double.parseDouble(t.getValue()); tmpByteArray.add(new Byte((byte)t.getTokenID())); byte[] tempByte = EndianConverter.writeDouble(cellLong); for(int byteIter=0;byteIter<tempByte.length;byteIter++) { @@ -313,19 +313,19 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList nameDefinitionEncoder(Token t) { + private ArrayList<Byte> nameDefinitionEncoder(Token t) { - ArrayList tmpByteArray = new ArrayList(); + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); String nameString = t.getValue(); Debug.log(Debug.TRACE,"NameDefinitionEncoder : " + nameString); tmpByteArray.add(new Byte((byte)t.getTokenID())); - Iterator e = wb.getDefinedNames(); + Iterator<DefinedName> e = wb.getDefinedNames(); DefinedName dn; String name; int definedNameIndex = 0; do { - dn = (DefinedName)e.next(); + dn = e.next(); name = dn.getName(); Debug.log(Debug.TRACE,"Name pulled from DefinedName : " + name); definedNameIndex++; @@ -347,9 +347,9 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList cellRefEncoder(Token t) { + private ArrayList<Byte> cellRefEncoder(Token t) { - ArrayList tmpByteArray = new ArrayList(); + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); tmpByteArray.add(new Byte((byte)t.getTokenID())); byte cellRefBytes[] = encodeCellCoordinates(t.getValue()); @@ -376,8 +376,8 @@ public class TokenEncoder { sheetName = s.substring(0,s.length()); } Debug.log(Debug.TRACE,"Searching for Worksheet : " + sheetName); - ArrayList names = wb.getWorksheetNames(); - Iterator e = names.iterator(); + ArrayList<Object> names = wb.getWorksheetNames(); + Iterator<Object> e = names.iterator(); do { savedName = (String) e.next(); sheetIndex++; @@ -393,9 +393,9 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList threeDCellRefEncoder(Token t) { + private ArrayList<Byte> threeDCellRefEncoder(Token t) { - ArrayList tmpByteArray = new ArrayList(); + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); parseString = t.getValue(); Debug.log(Debug.TRACE,"Encoding 3D Cell reference " + t); tmpByteArray.add(new Byte((byte)t.getTokenID())); @@ -437,9 +437,9 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList threeDAreaRefEncoder(Token t) { + private ArrayList<Byte> threeDAreaRefEncoder(Token t) { - ArrayList tmpByteArray = new ArrayList(); + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); parseString = t.getValue(); Debug.log(Debug.TRACE,"Encoding 3D Area reference " + t); tmpByteArray.add(new Byte((byte)t.getTokenID())); @@ -494,9 +494,9 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList areaRefEncoder(Token t) { + private ArrayList<Byte> areaRefEncoder(Token t) { - ArrayList tmpByteArray = new ArrayList(); + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); tmpByteArray.add(new Byte((byte)t.getTokenID())); String param = t.getValue(); @@ -530,8 +530,8 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private ArrayList functionEncoder(Token t) { - ArrayList tmpByteArray = new ArrayList(); + private ArrayList<Byte> functionEncoder(Token t) { + ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); int id = t.getTokenID(); if(t.getTokenType()==ParseToken.TOKEN_FUNCTION_VARIABLE) { |