diff options
author | Noel Grandin <noel@peralex.com> | 2012-06-27 18:20:18 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-06-29 22:03:02 +0200 |
commit | 30d4c3c7ce75ed2180a439c2a3526dae7f4660d5 (patch) | |
tree | a057e459dc9b975ed0b34bd4785b52acdd2f12b9 /xmerge | |
parent | b9e203cb95e78782262c078891d4f0ac99850e1e (diff) |
Java5 update - convert to using generics where feasible
Change-Id: I65b8a40aff54a1128d66e7c46bbcdea459bcc2ce
Diffstat (limited to 'xmerge')
72 files changed, 443 insertions, 441 deletions
diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java index 281e3b83ec99..8ad9434a9835 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java @@ -231,10 +231,10 @@ final class DocDecoder implements DocConstants { } // read the number of records - unsigned 2 bytes - header.textRecordCount = ((int) dis.readShort()) & 0x0000ffff; + header.textRecordCount = dis.readShort() & 0x0000ffff; // read the record size - unsigned 2 bytes - header.textRecordSize = ((int) dis.readShort()) & 0x0000ffff; + header.textRecordSize = dis.readShort() & 0x0000ffff; // read extra 4 unused bytes dis.readInt(); diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java index 377d95d8716a..657784fe7684 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java @@ -114,7 +114,7 @@ final class DocEncoder implements DocConstants { byte recBytes[] = new byte[TEXT_RECORD_SIZE]; int pos = 0; - List textRecords = new ArrayList(textRecCount + 1); + List<Record> textRecords = new ArrayList<Record>(textRecCount + 1); // split textBytes into chunks of Record objects // and store in textRecords object. @@ -147,7 +147,7 @@ final class DocEncoder implements DocConstants { for (int i = 1; i < allRecords.length; i++) { - allRecords[i] = (Record) textRecords.get(i-1); + allRecords[i] = textRecords.get(i-1); } return allRecords; diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java index 10a28c7f2e4f..959a092e4e5a 100644 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java +++ b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java @@ -87,7 +87,7 @@ public final class DocumentDeserializerImpl Document doc = null; int i=0; ConvertData cdOut; - Iterator e = cd.getDocumentEnumeration(); + Iterator<Object> e = cd.getDocumentEnumeration(); while (e.hasNext()) { PalmDocument palmDoc = (PalmDocument) e.next(); PalmDB pdb = palmDoc.getPdb(); diff --git a/xmerge/source/bridge/java/XMergeBridge.java b/xmerge/source/bridge/java/XMergeBridge.java index 6c52a79ee003..494396cdedf2 100644 --- a/xmerge/source/bridge/java/XMergeBridge.java +++ b/xmerge/source/bridge/java/XMergeBridge.java @@ -184,21 +184,21 @@ public class XMergeBridge { try{ Object xCfgMgrObj=xMSF.createInstance("com.sun.star.config.SpecialConfigManager"); - XConfigManager xCfgMgr = (XConfigManager) UnoRuntime.queryInterface( + XConfigManager xCfgMgr = UnoRuntime.queryInterface( XConfigManager.class , xCfgMgrObj ); String PathString=xCfgMgr.substituteVariables("$(progurl)" ); PathString= PathString.concat("/"); udJarPath= PathString.concat(udJarPath); Object xPipeObj=xMSF.createInstance("com.sun.star.io.Pipe"); - xInStream = (XInputStream) UnoRuntime.queryInterface( + xInStream = UnoRuntime.queryInterface( XInputStream.class , xPipeObj ); - xOutStream = (XOutputStream) UnoRuntime.queryInterface( + xOutStream = UnoRuntime.queryInterface( XOutputStream.class , xPipeObj ); convert (xis,xOutStream,false,udJarPath,sFileName,offMime,sdMime); Object xSaxParserObj=xMSF.createInstance("com.sun.star.xml.sax.Parser"); - XParser xParser = (XParser) UnoRuntime.queryInterface( + XParser xParser = UnoRuntime.queryInterface( XParser.class , xSaxParserObj ); if (xParser==null){ System.out.println("\nParser creation Failed"); @@ -275,7 +275,7 @@ public class XMergeBridge { try{ Object xCfgMgrObj=xMSF.createInstance("com.sun.star.config.SpecialConfigManager"); - XConfigManager xCfgMgr = (XConfigManager) UnoRuntime.queryInterface( + XConfigManager xCfgMgr = UnoRuntime.queryInterface( XConfigManager.class , xCfgMgrObj ); String PathString=xCfgMgr.substituteVariables("$(progurl)" ); @@ -283,9 +283,9 @@ public class XMergeBridge { udJarPath= PathString.concat(udJarPath); Object xPipeObj=xMSF.createInstance("com.sun.star.io.Pipe"); - xInStream = (XInputStream) UnoRuntime.queryInterface( + xInStream = UnoRuntime.queryInterface( XInputStream.class , xPipeObj ); - xOutStream = (XOutputStream) UnoRuntime.queryInterface( + xOutStream = UnoRuntime.queryInterface( XOutputStream.class , xPipeObj ); } catch (Exception e){ @@ -435,7 +435,7 @@ public class XMergeBridge { String name= getFileName(FileName); ConverterInfo converterInfo = null; - Iterator ciEnum= null; + Iterator<ConverterInfo> ciEnum= null; XInputStreamToInputStreamAdapter xis =new XInputStreamToInputStreamAdapter(xml); @@ -472,10 +472,10 @@ public class XMergeBridge { } else { - cv.addInputStream(name,(InputStream)xis,false); + cv.addInputStream(name,xis,false); ConvertData dataOut = cv.convert(); - Iterator docEnum = dataOut.getDocumentEnumeration(); + Iterator<Object> docEnum = dataOut.getDocumentEnumeration(); if (docEnum.hasNext()){ Document docOut = (Document)docEnum.next(); @@ -536,9 +536,9 @@ public class XMergeBridge { else { - cv.addInputStream(name,(InputStream)xis,false); + cv.addInputStream(name,xis,false); ConvertData dataIn = cv.convert(); - Iterator docEnum = dataIn.getDocumentEnumeration(); + Iterator<Object> docEnum = dataIn.getDocumentEnumeration(); while (docEnum.hasNext()) { OfficeDocument docIn = (OfficeDocument)docEnum.next(); 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) { diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java index a306b53930b0..18a50c8a546f 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java @@ -46,10 +46,10 @@ class DocumentDescriptor { private short length = 0; private short numLines = 0; - private ArrayList paragraphDesc = null; + private ArrayList<ParagraphDescriptor> paragraphDesc = null; DocumentDescriptor() { - paragraphDesc = new ArrayList(0); + paragraphDesc = new ArrayList<ParagraphDescriptor>(0); } @@ -98,7 +98,7 @@ class DocumentDescriptor { descStream.write(EndianConverter.writeShort(numParagraphs)); descStream.write(EndianConverter.writeShort((short)0)); - descStream.write(EndianConverter.writeShort((short)length)); + descStream.write(EndianConverter.writeShort(length)); descStream.write(EndianConverter.writeShort((short)0)); descStream.write(EndianConverter.writeShort(numLines)); @@ -106,7 +106,7 @@ class DocumentDescriptor { 0x00, 0x00, 0x00, 0x00 } ); for (int i = 0; i < paragraphDesc.size(); i++) { - ParagraphDescriptor pd = (ParagraphDescriptor)paragraphDesc.get(i); + ParagraphDescriptor pd = paragraphDesc.get(i); descStream.write(pd.getDescriptor()); } diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java index b067ea0ed4f2..313054c9adaa 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java @@ -72,7 +72,7 @@ public final class DocumentDeserializerImpl * for conversion. */ public DocumentDeserializerImpl(ConvertData cd) { - Iterator e = cd.getDocumentEnumeration(); + Iterator<Object> e = cd.getDocumentEnumeration(); // A Pocket Word file is composed of one binary file while (e.hasNext()) { @@ -98,7 +98,7 @@ public final class DocumentDeserializerImpl * @throws IOException If any I/O error occurs. */ public Document deserialize() throws IOException, ConvertException { - Iterator pe = pswDoc.getParagraphEnumeration(); + Iterator<Paragraph> pe = pswDoc.getParagraphEnumeration(); sxwDoc = new SxwDocument (docName); sxwDoc.initContentDOM(); @@ -129,7 +129,7 @@ public final class DocumentDeserializerImpl * * @throws IOException If any I/O errors occur. */ - private void buildDocument(Iterator data) throws IOException { + private void buildDocument(Iterator<Paragraph> data) throws IOException { org.w3c.dom.Document doc = sxwDoc.getContentDOM(); @@ -158,7 +158,7 @@ public final class DocumentDeserializerImpl // Down to business ... while (data.hasNext()) { - Paragraph p = (Paragraph)data.next(); + Paragraph p = data.next(); Element paraNode = doc.createElement(TAG_PARAGRAPH); // Set paragraph style information here @@ -179,11 +179,11 @@ public final class DocumentDeserializerImpl * For each of the paragraphs, process each segment. * There will always be at least one. */ - Iterator paraData = p.getSegmentsEnumerator(); - ArrayList textSpans = new ArrayList(0); + Iterator<ParagraphTextSegment> paraData = p.getSegmentsEnumerator(); + ArrayList<Element> textSpans = new ArrayList<Element>(0); do { - ParagraphTextSegment pts = (ParagraphTextSegment)paraData.next(); + ParagraphTextSegment pts = paraData.next(); Element span = doc.createElement(OfficeConstants.TAG_SPAN); TextStyle ts = pts.getStyle(); @@ -217,7 +217,7 @@ public final class DocumentDeserializerImpl * it shouldn't be a span, so just add its children with style * set as standard. */ - Element firstSpan = (Element)textSpans.get(0); + Element firstSpan = textSpans.get(0); String styleName = firstSpan.getAttribute(ATTRIBUTE_TEXT_STYLE_NAME); if (styleName.equals(PocketWordConstants.DEFAULT_STYLE)) { NodeList nl = firstSpan.getChildNodes(); @@ -240,7 +240,7 @@ public final class DocumentDeserializerImpl // The rest are spans, so just add them for (int i = 1; i < textSpans.size(); i++) { - paraNode.appendChild((Node)textSpans.get(i)); + paraNode.appendChild(textSpans.get(i)); } diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java index 7e3ae7f58c64..969c09e07b32 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java @@ -124,7 +124,7 @@ public final class DocumentSerializerImpl String families[] = new String[] { PocketWordConstants.TEXT_STYLE_FAMILY, PocketWordConstants.PARAGRAPH_STYLE_FAMILY, PocketWordConstants.PARAGRAPH_STYLE_FAMILY }; - Class classes[] = new Class[] { TextStyle.class, + Class<?> classes[] = new Class[] { TextStyle.class, ParaStyle.class, TextStyle.class }; diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java index dc56c635c275..feb991a5d65c 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java @@ -71,9 +71,9 @@ class Paragraph implements PocketWordConstants { * representation. */ - private ArrayList textSegments = null; + private ArrayList<ParagraphTextSegment> textSegments = null; - private ArrayList lineDescriptors = null; + private ArrayList<LineDescriptor> lineDescriptors = null; private ParaStyle pStyle = null; @@ -85,7 +85,7 @@ class Paragraph implements PocketWordConstants { * initialisation of the Vector storing the paragraph's text. */ private Paragraph () { - textSegments = new ArrayList(); + textSegments = new ArrayList<ParagraphTextSegment>(); } @@ -99,7 +99,7 @@ class Paragraph implements PocketWordConstants { public Paragraph (ParaStyle style) { this(); - lineDescriptors = new ArrayList(); + lineDescriptors = new ArrayList<LineDescriptor>(); pStyle = style; } @@ -471,7 +471,7 @@ class Paragraph implements PocketWordConstants { try { for (int i = 0; i < textSegments.size(); i++) { - ParagraphTextSegment pts = (ParagraphTextSegment)textSegments.get(i); + ParagraphTextSegment pts = textSegments.get(i); segs.write(pts.getData()); } } @@ -603,7 +603,7 @@ class Paragraph implements PocketWordConstants { // Now write out the line descriptors for (int i = 0; i < lineDescriptors.size(); i++) { - LineDescriptor ld = (LineDescriptor)lineDescriptors.get(i); + LineDescriptor ld = lineDescriptors.get(i); bos.write(ld.getDescriptorInfo()); } @@ -651,11 +651,11 @@ class Paragraph implements PocketWordConstants { StringBuffer sb = new StringBuffer(""); // Line Descriptor info should be eliminated each time - lineDescriptors = new ArrayList(); + lineDescriptors = new ArrayList<LineDescriptor>(); lines = 0; for (int i = 0; i < textSegments.size(); i++) { - ParagraphTextSegment pts = (ParagraphTextSegment)textSegments.get(i); + ParagraphTextSegment pts = textSegments.get(i); sb.append(pts.getText()); } @@ -763,7 +763,7 @@ class Paragraph implements PocketWordConstants { * * @return An <code>Enumeration</code> of the text segments. */ - public Iterator getSegmentsEnumerator () { + public Iterator<ParagraphTextSegment> getSegmentsEnumerator () { return textSegments.iterator(); } diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java index c59c6715ad68..909dc25b5530 100644 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java +++ b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java @@ -45,9 +45,9 @@ public class PocketWordDocument implements Document, PocketWordConstants { private String docName; private byte[] preamble; - private ArrayList fonts; + private ArrayList<Object> fonts; private DocumentDescriptor descriptor; - private ArrayList paragraphs; + private ArrayList<Paragraph> paragraphs; private ParaStyle pStyle; private Paragraph currentPara; @@ -85,9 +85,9 @@ public class PocketWordDocument implements Document, PocketWordConstants { docName = trimDocumentName(name); preamble = new byte[52]; - fonts = new ArrayList(); + fonts = new ArrayList<Object>(); descriptor = new DocumentDescriptor(); - paragraphs = new ArrayList(); + paragraphs = new ArrayList<Paragraph>(); } @@ -205,7 +205,7 @@ public class PocketWordDocument implements Document, PocketWordConstants { * * @return <code>Enumeration</code> over the paragraphs in the document. */ - public Iterator getParagraphEnumeration() { + public Iterator<Paragraph> getParagraphEnumeration() { return paragraphs.iterator(); } @@ -258,13 +258,13 @@ public class PocketWordDocument implements Document, PocketWordConstants { for (int i = 0; i < paragraphs.size(); i++) { - Paragraph para = (Paragraph)paragraphs.get(i); + Paragraph para = paragraphs.get(i); descriptor.addParagraph((short)para.getTextLength(), para.getLines()); } dos.write(descriptor.getDescriptor()); for (int i = 0; i < paragraphs.size(); i++ ) { - Paragraph para = (Paragraph)paragraphs.get(i); + Paragraph para = paragraphs.get(i); // Last paragraph has some extra data if (i + 1 == paragraphs.size()) { diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java index 83071b21254f..20ef21e3cb61 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java @@ -104,7 +104,7 @@ implements DOCConstants, OfficeConstants, DocumentDeserializer { Document doc = null; PalmDocument palmDoc = null; - Iterator e = cd.getDocumentEnumeration(); + Iterator<Object> e = cd.getDocumentEnumeration(); while(e.hasNext()) { palmDoc = (PalmDocument) e.next(); @@ -138,7 +138,7 @@ implements DOCConstants, OfficeConstants, DocumentDeserializer { families[0] = "text"; families[1] = "paragraph"; families[2] = "paragraph"; - Class classes[] = new Class[3]; + Class<?> classes[] = new Class<?>[3]; classes[0] = TextStyle.class; classes[1] = ParaStyle.class; classes[2] = TextStyle.class; @@ -171,7 +171,7 @@ implements DOCConstants, OfficeConstants, DocumentDeserializer { private ParaStyle matchParaByText(Style paraStyles[], TextStyle tStyle) { int matchIndex = -1; int matchCount = 0; - Style txtMatches[] = (Style[]) oldStyleCat.getMatching(tStyle); + Style txtMatches[] = oldStyleCat.getMatching(tStyle); if (txtMatches.length >= 1) { for (int j = 0; j < txtMatches.length; j++) { TextStyle t = (TextStyle)txtMatches[j]; @@ -203,7 +203,7 @@ implements DOCConstants, OfficeConstants, DocumentDeserializer { * @return Array of <code>Node</code> objects. */ private Node[] parseText(String text, org.w3c.dom.Document parentDoc) { - ArrayList nodeVec = new ArrayList(); + ArrayList<Node> nodeVec = new ArrayList<Node>(); // Break up the text from the WordSmith text run into Open // Office text runs. There may be more runs in OO because @@ -274,7 +274,7 @@ implements DOCConstants, OfficeConstants, DocumentDeserializer { // Now create and populate an array to return the nodes in. Node nodes[] = new Node[nodeVec.size()]; for (int i = 0; i < nodeVec.size(); i++) - nodes[i] = (Node)nodeVec.get(i); + nodes[i] = nodeVec.get(i); return nodes; } diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java index fa8e85e6fb45..bea4b6581a21 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java @@ -128,7 +128,7 @@ implements OfficeConstants, DocumentSerializer { families[0] = "text"; families[1] = "paragraph"; families[2] = "paragraph"; - Class classes[] = new Class[3]; + Class<?> classes[] = new Class[3]; classes[0] = TextStyle.class; classes[1] = ParaStyle.class; classes[2] = TextStyle.class; diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java index 4ed64f04e4ac..2b86395d1bc8 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java @@ -120,7 +120,7 @@ final class WSDecoder implements DOCConstants { */ Wse[] parseDocument(Record[] recs) throws IOException { - java.util.ArrayList v = new java.util.ArrayList(20); + java.util.ArrayList<Wse> v = new java.util.ArrayList<Wse>(20); WseFontTable fontTable = null; WseColorTable colorTable = null; @@ -160,7 +160,7 @@ final class WSDecoder implements DOCConstants { } } - return (Wse[])v.toArray(new Wse[2]); + return v.toArray(new Wse[2]); } @@ -290,10 +290,10 @@ final class WSDecoder implements DOCConstants { } // read the number of records - unsigned 2 bytes - header.textRecordCount = ((int) dis.readShort()) & 0x0000ffff; + header.textRecordCount = dis.readShort() & 0x0000ffff; // read the record size - unsigned 2 bytes - header.textRecordSize = ((int) dis.readShort()) & 0x0000ffff; + header.textRecordSize = dis.readShort() & 0x0000ffff; // read extra 4 unused bytes dis.readInt(); diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java index 2d9c13a3c198..3d7cec7b259b 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java @@ -58,7 +58,7 @@ final class WSEncoder { WseHeader header = null; WseFontTable ft = null; WseColorTable ct = null; - private ArrayList elements; // paragraphs & text runs + private ArrayList<Wse> elements; // paragraphs & text runs /* Totals for the WordSmith document. */ int nrParagraphs = 0; @@ -75,7 +75,7 @@ final class WSEncoder { version = 1; textLen = 0; maxRecSize = 4096; - elements = new ArrayList(); + elements = new ArrayList<Wse>(); } @@ -106,13 +106,13 @@ final class WSEncoder { */ Record[] getRecords() throws IOException { - ArrayList allRecs = new ArrayList(); + ArrayList<Record> allRecs = new ArrayList<Record>(); int nElements = elements.size(); // Count up the number of paragraphs, atoms, and characters. int currElement = 0; while (currElement < nElements) { - Wse e = (Wse)elements.get(currElement++); + Wse e = elements.get(currElement++); if (e.getClass() == WsePara.class) nrParagraphs++; if (e.getClass() == WseTextRun.class) { @@ -144,7 +144,7 @@ final class WSEncoder { currElement = 0; while (currElement < nElements) { - Wse e = (Wse)elements.get(currElement++); + Wse e = elements.get(currElement++); int length = e.getByteCount(); if ((length + currRecLen) <= 4096) { System.arraycopy(e.getBytes(), 0, currRec, currRecLen, length); @@ -192,7 +192,7 @@ final class WSEncoder { int nRecs = allRecs.size(); Record recs[] = new Record[nRecs]; for (int i = 0; i < nRecs; i++) - recs[i] = (Record)allRecs.get(i); + recs[i] = allRecs.get(i); return recs; } diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java index cb5bd581de6c..c6b5e8325464 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java @@ -67,15 +67,15 @@ class WseColorTable extends Wse { i += 2; // Skip leading "64" and table length field. for (int k = 0; k < 16; k++) { - fgColors[k] = new Color(((int)dataArray[i+1]) & 0xFF, - ((int)dataArray[i+2]) & 0xFF, - ((int)dataArray[i+3]) & 0xFF); + fgColors[k] = new Color(dataArray[i+1] & 0xFF, + dataArray[i+2] & 0xFF, + dataArray[i+3] & 0xFF); i += 4; } for (int k = 0; k < 16; k++) { - bgColors[k] = new Color(((int)dataArray[i+1]) & 0xFF, - ((int)dataArray[i+2]) & 0xFF, - ((int)dataArray[i+3]) & 0xFF); + bgColors[k] = new Color(dataArray[i+1] & 0xFF, + dataArray[i+2] & 0xFF, + dataArray[i+3] & 0xFF); i += 4; } @@ -117,7 +117,7 @@ class WseColorTable extends Wse { return false; int len = dataArray[startIndex + 1]; len &= 0xFF; // eliminate problems with sign-extension - int temp = dataArray[startIndex + (int)len + 2]; // probe end of table + int temp = dataArray[startIndex + len + 2]; // probe end of table } catch (ArrayIndexOutOfBoundsException e) { return false; } diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java index 88afab707cd4..6ff84492d340 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java @@ -44,7 +44,7 @@ import org.openoffice.xmerge.converter.xml.*; */ class WseFontTable extends Wse { - java.util.ArrayList fontNames = new java.util.ArrayList(10); + java.util.ArrayList<String> fontNames = new java.util.ArrayList<String>(10); /** @@ -94,7 +94,7 @@ class WseFontTable extends Wse { */ public String getFontName(int index) { try { - return (String)fontNames.get(index); + return fontNames.get(index); } catch (ArrayIndexOutOfBoundsException e) { return null; } @@ -110,7 +110,7 @@ class WseFontTable extends Wse { public int getFontIndex(String fontName) { int len = fontNames.size(); for (int i = 0; i < len; i++) { - String name = (String) fontNames.get(i); + String name = fontNames.get(i); if (name.equals(fontName)) return i; } @@ -175,7 +175,7 @@ class WseFontTable extends Wse { int length = 3; // leading "3" plus 2 bytes for length. int nFonts = fontNames.size(); for (int i = 0; i < nFonts; i++) { - String name = (String)fontNames.get(i); + String name = fontNames.get(i); length += name.length() + 1; // extra byte is for trailing "0" } return length; @@ -197,7 +197,7 @@ class WseFontTable extends Wse { b[2] = (byte)(length & 0xFF); int indx = 3; for (int i = 0; i < nFonts; i++) { - String name = (String)fontNames.get(i); + String name = fontNames.get(i); byte bname[] = name.getBytes(); System.arraycopy(bname, 0, b, indx, bname.length); indx += bname.length; diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java index 7553b2728fe2..de596d4b8ec9 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java @@ -282,7 +282,7 @@ class WseTextRun extends Wse { | TextStyle.SUBSCRIPT; TextStyle x = new TextStyle(null, "text", null, mask, - mod, (int)(fontSize/2), fontName, sc); + mod, (fontSize/2), fontName, sc); // If color table is available, set the colors. if (ct != null) { diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java index f71e5faddd7c..7632320cbe7d 100644 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java +++ b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java @@ -34,14 +34,14 @@ import java.io.ByteArrayOutputStream; class textRecord { - java.util.ArrayList elements; + java.util.ArrayList<Wse> elements; /** * Default constructor */ textRecord() { - elements = new java.util.ArrayList(10); + elements = new java.util.ArrayList<Wse>(10); } @@ -66,7 +66,7 @@ class textRecord { int totalBytes = 0; int nElements = elements.size(); for (int i = 0; i < nElements; i++) { - Wse e = (Wse)elements.get(i); + Wse e = elements.get(i); totalBytes += e.getByteCount(); } return totalBytes; @@ -89,7 +89,7 @@ class textRecord { os = new DataOutputStream(bs); int nElements = elements.size(); for (int i = 0; i < nElements; i++) { - Wse e = (Wse)elements.get(i); + Wse e = elements.get(i); os.write(e.getBytes()); } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java index 1629f768b9dc..3dec93a56481 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java @@ -212,7 +212,7 @@ public class Convert implements Cloneable { DocumentSerializerFactory myDocSerializerFactory = ci.getDocSerializerFactory(); - Iterator e = inputCD.getDocumentEnumeration(); + Iterator<Object> e = inputCD.getDocumentEnumeration(); Document doc = (Document) e.next(); DocumentSerializer ser = myDocSerializerFactory.createDocumentSerializer(doc); @@ -266,7 +266,7 @@ public class Convert implements Cloneable { DocumentSerializerFactory myDocSerializerFactory = ci.getDocSerializerFactory(); - Iterator e = inputCD.getDocumentEnumeration(); + Iterator<Object> e = inputCD.getDocumentEnumeration(); Document doc = (Document) e.next(); DocumentSerializer ser = myDocSerializerFactory.createDocumentSerializer(doc); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java index 035453459d3d..afa85efdd672 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java @@ -34,7 +34,7 @@ public class ConvertData { /** * Vector of <code>Document</code> objects. */ - private ArrayList v = new ArrayList(); + private ArrayList<Object> v = new ArrayList<Object>(); /** * Name of the <code>ConvertData</code> object. @@ -89,8 +89,8 @@ public class ConvertData { * @return The <code>Enumeration</code> to access the * <code>Vector</code> of <code>Document</code> objects. */ - public Iterator getDocumentEnumeration() { - Iterator enumerate = v.iterator(); + public Iterator<Object> getDocumentEnumeration() { + Iterator<Object> enumerate = v.iterator(); return (enumerate); } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java index 2b0fe101443b..936bd021ab9e 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/dom/DOMDocument.java @@ -240,7 +240,7 @@ public class DOMDocument ByteArrayOutputStream baos = new ByteArrayOutputStream(); - java.lang.reflect.Constructor con; + java.lang.reflect.Constructor<?> con; java.lang.reflect.Method meth; String domImpl = doc.getClass().getName(); @@ -257,7 +257,7 @@ public class DOMDocument // First of all try for JAXP 1.0 if (domImpl.equals("com.sun.xml.tree.XmlDocument")) { System.out.println("Using JAXP"); - Class jaxpDoc = Class.forName("com.sun.xml.tree.XmlDocument"); + Class<?> jaxpDoc = Class.forName("com.sun.xml.tree.XmlDocument"); // The method is in the XMLDocument class itself, not a helper meth = jaxpDoc.getMethod("write", @@ -268,7 +268,7 @@ public class DOMDocument else if (domImpl.equals("org.apache.crimson.tree.XmlDocument")) { System.out.println("Using Crimson"); - Class crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); + Class<?> crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); // The method is in the XMLDocument class itself, not a helper meth = crimsonDoc.getMethod("write", new Class[] { Class.forName("java.io.OutputStream") } ); @@ -279,7 +279,7 @@ public class DOMDocument || domImpl.equals("org.apache.xerces.dom.DeferredDocumentImpl")) { System.out.println("Using Xerces"); // Try for Xerces - Class xercesSer = + Class<?> xercesSer = Class.forName("org.apache.xml.serialize.XMLSerializer"); // Get the OutputStream constructor @@ -304,7 +304,7 @@ public class DOMDocument else if (domImpl.equals("gnu.xml.dom.DomDocument")) { System.out.println("Using GNU"); - Class gnuSer = Class.forName("gnu.xml.dom.ls.DomLSSerializer"); + Class<?> gnuSer = Class.forName("gnu.xml.dom.ls.DomLSSerializer"); // Get the serialize method meth = gnuSer.getMethod("serialize", @@ -387,7 +387,7 @@ public class DOMDocument } - Element root = (Element) doc.createElement(rootName); + Element root = doc.createElement(rootName); doc.appendChild(root); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java index 2eda2fa6e31b..c5abd5ee8bd4 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbDecoder.java @@ -201,7 +201,7 @@ public final class PdbDecoder { // last record dis.reset(); - len = (int) dis.available() - recOffset[lastIndex]; + len = dis.available() - recOffset[lastIndex]; dis.skip(recOffset[lastIndex]); bytes = new byte[len]; dis.readFully(bytes); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java index f025ceadeb4b..b30d38f0de83 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbEncoder.java @@ -160,7 +160,7 @@ public final class PdbEncoder { // unique ID (uid) in 4 bytes (int) chunk. // unique ID's have to be unique, thus // increment each time. - int attr = (((int) recAttr[i]) << 24 ); + int attr = (recAttr[i] << 24 ); attr |= uid; dos.writeInt(attr); uid++; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java index cd0c2e71af8f..e40fef1ee368 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbHeader.java @@ -111,10 +111,10 @@ final class PdbHeader { in.readFully(pdbName); attribute = in.readShort(); version = in.readUnsignedShort(); - creationDate = ((long) in.readInt()) & 0xffffffffL; - modificationDate = ((long) in.readInt()) & 0xffffffffL; - lastBackupDate = ((long) in.readInt()) & 0xffffffffL; - modificationNumber = ((long) in.readInt()) & 0xffffffffL; + creationDate = in.readInt() & 0xffffffffL; + modificationDate = in.readInt() & 0xffffffffL; + lastBackupDate = in.readInt() & 0xffffffffL; + modificationNumber = in.readInt() & 0xffffffffL; appInfoID = in.readInt(); sortInfoID = in.readInt(); creatorID = in.readInt(); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java index 55e33f891bb7..bd83ff5ca2e4 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PdbUtil.java @@ -56,19 +56,19 @@ public final class PdbUtil { // grab the first char and put it in the high bits // note that we only want 8 lower bits of it. - temp = (int) s.charAt(0); + temp = s.charAt(0); id = temp << 24; // grab the second char and add it in. - temp = ((int) s.charAt(1)) & 0x00ff; + temp = s.charAt(1) & 0x00ff; id += temp << 16; // grab the second char and add it in. - temp = ((int) s.charAt(2)) & 0x00ff; + temp = s.charAt(2) & 0x00ff; id += temp << 8; // grab the last char and add it in - id += ((int) s.charAt(3)) & 0x00ff; + id += s.charAt(3) & 0x00ff; return id; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java index b1da02333a61..5e9014604172 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java @@ -96,7 +96,7 @@ public abstract class OfficeDocument private OfficeZip zip = null; /** Collection to keep track of the embedded objects in the document. */ - private Map embeddedObjects = null; + private Map<String, EmbeddedObject> embeddedObjects = null; /** * Default constructor. @@ -290,10 +290,10 @@ public abstract class OfficeDocument * * @return An <code>Iterator</code> of <code>EmbeddedObject</code> objects. */ - public Iterator getEmbeddedObjects() { + public Iterator<EmbeddedObject> getEmbeddedObjects() { if (embeddedObjects == null && manifestDoc != null) { - embeddedObjects = new HashMap(); + embeddedObjects = new HashMap<String, EmbeddedObject>(); // Need to read the manifest file and construct a list of objects NodeList nl = manifestDoc.getElementsByTagName(TAG_MANIFEST_FILE); @@ -363,7 +363,7 @@ public abstract class OfficeDocument } if (embeddedObjects.containsKey(name)) { - return (EmbeddedObject)embeddedObjects.get(name); + return embeddedObjects.get(name); } else { return null; @@ -382,7 +382,7 @@ public abstract class OfficeDocument } if (embeddedObjects == null) { - embeddedObjects = new HashMap(); + embeddedObjects = new HashMap<String, EmbeddedObject>(); } embeddedObjects.put(embObj.getName(), embObj); @@ -529,12 +529,12 @@ public abstract class OfficeDocument NodeList nodeList; Node tmpNode; - Node rootNode = (Node)rootElement; + Node rootNode = rootElement; if (newDoc !=null){ /*content*/ contentDoc = createDOM(TAG_OFFICE_DOCUMENT_CONTENT); rootElement=contentDoc.getDocumentElement(); - rootNode = (Node)rootElement; + rootNode = rootElement; // FIX (HJ): Include office:font-decls in content DOM nodeList= newDoc.getElementsByTagName(TAG_OFFICE_FONT_DECLS); @@ -558,7 +558,7 @@ public abstract class OfficeDocument /*Styles*/ styleDoc = createDOM(TAG_OFFICE_DOCUMENT_STYLES); rootElement=styleDoc.getDocumentElement(); - rootNode = (Node)rootElement; + rootNode = rootElement; // FIX (HJ): Include office:font-decls in styles DOM nodeList= newDoc.getElementsByTagName(TAG_OFFICE_FONT_DECLS); @@ -590,7 +590,7 @@ public abstract class OfficeDocument /*Settings*/ settingsDoc = createDOM(TAG_OFFICE_DOCUMENT_SETTINGS); rootElement=settingsDoc.getDocumentElement(); - rootNode = (Node)rootElement; + rootNode = rootElement; nodeList= newDoc.getElementsByTagName(TAG_OFFICE_SETTINGS); if (nodeList.getLength()>0){ tmpNode = settingsDoc.importNode(nodeList.item(0),true); @@ -599,7 +599,7 @@ public abstract class OfficeDocument /*Meta*/ metaDoc = createDOM(TAG_OFFICE_DOCUMENT_META); rootElement=metaDoc.getDocumentElement(); - rootNode = (Node)rootElement; + rootNode = rootElement; nodeList= newDoc.getElementsByTagName(TAG_OFFICE_META); if (nodeList.getLength()>0){ tmpNode = metaDoc.importNode(nodeList.item(0),true); @@ -671,9 +671,9 @@ public abstract class OfficeDocument Element manifestRoot = manifestDoc.getDocumentElement(); // The EmbeddedObjects come first. - Iterator embObjs = getEmbeddedObjects(); + Iterator<EmbeddedObject> embObjs = getEmbeddedObjects(); while (embObjs.hasNext()) { - EmbeddedObject obj = (EmbeddedObject)embObjs.next(); + EmbeddedObject obj = embObjs.next(); obj.writeManifestData(manifestDoc); obj.write(zip); @@ -780,7 +780,7 @@ public abstract class OfficeDocument NodeList nodeList; Node tmpNode; - Node rootNode = (Node)rootElement; + Node rootNode = rootElement; if (metaDoc !=null){ nodeList= metaDoc.getElementsByTagName(TAG_OFFICE_META); if (nodeList.getLength()>0){ @@ -844,7 +844,7 @@ public abstract class OfficeDocument ByteArrayOutputStream baos = new ByteArrayOutputStream(); - java.lang.reflect.Constructor con; + java.lang.reflect.Constructor<?> con; java.lang.reflect.Method meth; String domImpl = doc.getClass().getName(); @@ -862,7 +862,7 @@ public abstract class OfficeDocument Debug.log(Debug.INFO, "Using JAXP"); - Class jaxpDoc = Class.forName("com.sun.xml.tree.XmlDocument"); + Class<?> jaxpDoc = Class.forName("com.sun.xml.tree.XmlDocument"); // The method is in the XMLDocument class itself, not a helper meth = jaxpDoc.getMethod("write", @@ -874,7 +874,7 @@ public abstract class OfficeDocument { Debug.log(Debug.INFO, "Using Crimson"); - Class crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); + Class<?> crimsonDoc = Class.forName("org.apache.crimson.tree.XmlDocument"); // The method is in the XMLDocument class itself, not a helper meth = crimsonDoc.getMethod("write", new Class[] { Class.forName("java.io.OutputStream") } ); @@ -887,7 +887,7 @@ public abstract class OfficeDocument Debug.log(Debug.INFO, "Using Xerces"); // Try for Xerces - Class xercesSer = + Class<?> xercesSer = Class.forName("org.apache.xml.serialize.XMLSerializer"); // Get the OutputStream constructor @@ -912,7 +912,7 @@ public abstract class OfficeDocument else if (domImpl.equals("gnu.xml.dom.DomDocument")) { Debug.log(Debug.INFO, "Using GNU"); - Class gnuSer = Class.forName("gnu.xml.dom.ls.DomLSSerializer"); + Class<?> gnuSer = Class.forName("gnu.xml.dom.ls.DomLSSerializer"); // Get the serialize method meth = gnuSer.getMethod("serialize", @@ -1036,7 +1036,7 @@ public abstract class OfficeDocument } - Element root = (Element) doc.createElement(rootName); + Element root = doc.createElement(rootName); doc.appendChild(root); root.setAttribute("xmlns:office", "http://openoffice.org/2000/office"); @@ -1075,7 +1075,7 @@ public abstract class OfficeDocument } - Element root = (Element) doc.createElement(rootName); + Element root = doc.createElement(rootName); doc.appendChild(root); root.setAttribute("xmlns:office", "http://openoffice.org/2000/office"); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java index 4b81d5556c24..cbd9f7ca8ad7 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeZip.java @@ -52,7 +52,7 @@ class OfficeZip { private final static int BUFFERSIZE = 1024; - private List entryList = null; + private List<Entry> entryList = null; private int contentIndex = -1; private int styleIndex = -1; @@ -63,7 +63,7 @@ class OfficeZip { /** Default constructor. */ OfficeZip() { - entryList = new LinkedList(); + entryList = new LinkedList<Entry>(); } @@ -205,7 +205,7 @@ class OfficeZip { // Could improve performance by caching the name and index when // iterating through the ZipFile in read(). for (int i = 0; i < entryList.size(); i++) { - Entry e = (Entry)entryList.get(i); + Entry e = entryList.get(i); if (e.zipEntry.getName().equals(name)) { return getEntryBytes(i); @@ -228,7 +228,7 @@ class OfficeZip { */ void setNamedBytes(String name, byte[] bytes) { for (int i = 0; i < entryList.size(); i++) { - Entry e = (Entry)entryList.get(i); + Entry e = entryList.get(i); if (e.zipEntry.getName().equals(name)) { setEntryBytes(i, bytes, name); @@ -259,7 +259,7 @@ class OfficeZip { byte[] bytes = null; if (index > -1) { - Entry entry = (Entry) entryList.get(index); + Entry entry = entryList.get(index); bytes = entry.bytes; } return bytes; @@ -349,7 +349,7 @@ class OfficeZip { // replace existing entry in entryList - Entry entry = (Entry) entryList.get(index); + Entry entry = entryList.get(index); name = entry.zipEntry.getName(); int method = entry.zipEntry.getMethod(); @@ -385,11 +385,11 @@ class OfficeZip { ZipOutputStream zos = new ZipOutputStream(os); - ListIterator iterator = entryList.listIterator(); + ListIterator<Entry> iterator = entryList.listIterator(); while (iterator.hasNext()) { - Entry entry = (Entry) iterator.next(); + Entry entry = iterator.next(); ZipEntry ze = entry.zipEntry; String name = ze.getName(); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java index aefba0864729..8d7761f63ffa 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/ParaStyle.java @@ -180,7 +180,7 @@ public class ParaStyle extends Style implements Cloneable { }; /** Array of attribute structures for this paragraph <code>Style</code>. */ - protected Class algor[] = { + protected Class<?> algor[] = { horizSize.class, horizSize.class, horizSize.class, diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java index 2832a44ec37b..818a4f250db9 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/StyleCatalog.java @@ -42,7 +42,7 @@ import org.w3c.dom.NodeList; */ public class StyleCatalog { - private ArrayList styles; // The actual styles + private ArrayList<Style> styles; // The actual styles /** * Constructor @@ -51,7 +51,7 @@ public class StyleCatalog { * for efficiency purposes. */ public StyleCatalog(int initialEntries) { - styles = new ArrayList(initialEntries); + styles = new ArrayList<Style>(initialEntries); } @@ -90,8 +90,8 @@ public class StyleCatalog { * whether there is a match in the * families array. */ - public void add(Node node, String families[], Class classes[], - Class defaultClass, boolean alwaysCreateDefault) { + public void add(Node node, String families[], Class<?> classes[], + Class<?> defaultClass, boolean alwaysCreateDefault) { if (node == null) return; @@ -117,7 +117,7 @@ public class StyleCatalog { for (int j = 0; j < families.length; j++) { if (families[j].equals(familyName)) { - Class styleClass = classes[j]; + Class<?> styleClass = classes[j]; callConstructor(classes[j], child); found = true; } @@ -138,16 +138,16 @@ public class StyleCatalog { * @param cls The class whose constructor will be called. * @param node The constructed class will be added to this node. */ - private void callConstructor(Class cls, Node node) { - Class params[] = new Class[2]; + private void callConstructor(Class<?> cls, Node node) { + Class<?> params[] = new Class[2]; params[0] = Node.class; params[1] = this.getClass(); try { - Constructor c = cls.getConstructor(params); + Constructor<?> c = cls.getConstructor(params); Object p[] = new Object[2]; p[0] = node; p[1] = this; - styles.add(c.newInstance(p)); + styles.add((Style) c.newInstance(p)); } catch (Exception e) { Debug.log(Debug.ERROR, "Exception when calling constructor", e); } @@ -180,10 +180,10 @@ public class StyleCatalog { * null otherwise */ public Style lookup(String name, String family, String parent, - Class styleClass) { + Class<?> styleClass) { int nStyles = styles.size(); for (int i = 0; i < nStyles; i++) { - Style s = (Style)styles.get(i); + Style s = styles.get(i); if ((name != null) && (s.getName() != null) && (!s.getName().equals(name))) continue; @@ -218,7 +218,7 @@ public class StyleCatalog { int matchCount = 0; int nStyles = styles.size(); for (int j = 0; j < nStyles; j++) { - Style p = ((Style)styles.get(j)).getResolved(); + Style p = styles.get(j).getResolved(); if (p.isSubset(s)) matchCount++; } @@ -226,7 +226,7 @@ public class StyleCatalog { Style[] matchArray = new Style[matchCount]; matchCount = 0; for (int j = 0; j < nStyles; j++) { - Style p = ((Style)styles.get(j)).getResolved(); + Style p = styles.get(j).getResolved(); if (p.isSubset(s)) matchArray[matchCount++] = p; } return matchArray; @@ -269,7 +269,7 @@ public class StyleCatalog { int len = styles.size(); for (int j = 0; j < len; j++) { - Style s = (Style)styles.get(j); + Style s = styles.get(j); Element styleNode = parentDoc.createElement("style:style"); @@ -304,7 +304,7 @@ public class StyleCatalog { TextStyle.dumpHdr(); int nStyles = styles.size(); for (int i = 0; i < nStyles; i++) { - Style s = (Style)styles.get(i); + Style s = styles.get(i); if (s.getClass().equals(TextStyle.class)) ((TextStyle)s).dumpCSV(); } @@ -312,7 +312,7 @@ public class StyleCatalog { ParaStyle.dumpHdr(); int nStyles = styles.size(); for (int i = 0; i < nStyles; i++) { - Style s = (Style)styles.get(i); + Style s = styles.get(i); if (s.getClass().equals(ParaStyle.class)) ((ParaStyle)s).dumpCSV(); } @@ -335,8 +335,8 @@ public class StyleCatalog { * * @return The class that is appropriate for this node. */ - private Class getClass(Node node, String[] families, Class[] classes, - Class defaultClass) { + private Class<?> getClass(Node node, String[] families, Class<?>[] classes, + Class<?> defaultClass) { NamedNodeMap attributes = node.getAttributes(); if (attributes != null) { int len = attributes.getLength(); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java index b8f9341d33c7..fa5bdd51cff4 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java @@ -42,7 +42,7 @@ public class BookSettings implements OfficeConstants { private boolean hasColumnRowHeaders = true; private String activeSheet = new String(); - private ArrayList worksheetSettings = new ArrayList(); + private ArrayList<SheetSettings> worksheetSettings = new ArrayList<SheetSettings>(); /** * Constructor for a <code>BookSettings</code>. Reads document settings @@ -59,7 +59,7 @@ public class BookSettings implements OfficeConstants { * * @param worksheetSettings If it's a row the height, a column the width */ - public BookSettings(ArrayList worksheetSettings) { + public BookSettings(ArrayList<SheetSettings> worksheetSettings) { this.worksheetSettings = worksheetSettings; } @@ -86,7 +86,7 @@ public class BookSettings implements OfficeConstants { * * @return <code>Vector</code> of <code>SheetSettings</code> */ - public ArrayList getSheetSettings() { + public ArrayList<SheetSettings> getSheetSettings() { return worksheetSettings; } @@ -138,10 +138,10 @@ public class BookSettings implements OfficeConstants { public void writeNode(org.w3c.dom.Document settings, Node root) { this.settings = settings; - Element configItemMapNamed = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_NAMED); + Element configItemMapNamed = settings.createElement(TAG_CONFIG_ITEM_MAP_NAMED); configItemMapNamed.setAttribute(ATTRIBUTE_CONFIG_NAME, "Tables"); - for(Iterator e = worksheetSettings.iterator();e.hasNext();) { - SheetSettings s = (SheetSettings) e.next(); + for(Iterator<SheetSettings> e = worksheetSettings.iterator();e.hasNext();) { + SheetSettings s = e.next(); s.writeNode(settings, configItemMapNamed); } addConfigItem(root, "ActiveTable", "string", activeSheet); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java index 6c349eabf45a..c29daf726957 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/NameDefinition.java @@ -143,7 +143,7 @@ public class NameDefinition implements OfficeConstants { if(isRangeType()) { Debug.log(Debug.TRACE, "Found Range Name : " + getName()); - Element namedRangeElement = (Element) doc.createElement(TAG_TABLE_NAMED_RANGE); + Element namedRangeElement = doc.createElement(TAG_TABLE_NAMED_RANGE); namedRangeElement.setAttribute(ATTRIBUTE_TABLE_NAME, getName()); namedRangeElement.setAttribute(ATTRIBUTE_TABLE_BASE_CELL_ADDRESS, getBaseCellAddress()); namedRangeElement.setAttribute(ATTRIBUTE_TABLE_CELL_RANGE_ADDRESS, getDefinition()); @@ -151,7 +151,7 @@ public class NameDefinition implements OfficeConstants { } else if (isExpressionType()) { Debug.log(Debug.TRACE, "Found Expression Name : " + getName()); - Element namedExpressionElement = (Element) doc.createElement(TAG_TABLE_NAMED_EXPRESSION); + Element namedExpressionElement = doc.createElement(TAG_TABLE_NAMED_EXPRESSION); namedExpressionElement.setAttribute(ATTRIBUTE_TABLE_NAME, getName()); namedExpressionElement.setAttribute(ATTRIBUTE_TABLE_BASE_CELL_ADDRESS,getBaseCellAddress()); namedExpressionElement.setAttribute(ATTRIBUTE_TABLE_EXPRESSION, getDefinition()); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java index 546c6b64da90..47779eb514df 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SheetSettings.java @@ -251,7 +251,7 @@ public class SheetSettings implements OfficeConstants { public void writeNode(org.w3c.dom.Document settings, Node root) { this.settings = settings; - Element configItemMapEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY); + Element configItemMapEntry = settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY); configItemMapEntry.setAttribute(ATTRIBUTE_CONFIG_NAME, getSheetName()); addConfigItem(configItemMapEntry, "CursorPositionX", "int", Integer.toString(cursorX)); addConfigItem(configItemMapEntry, "CursorPositionY", "int", Integer.toString(cursorY)); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java index fdb35ba1cc74..c54ccea7b89b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetDecoder.java @@ -49,7 +49,7 @@ public abstract class SpreadsheetDecoder { * * @return The Enumeration */ - public abstract Iterator getNameDefinitions(); + public abstract Iterator<NameDefinition> getNameDefinitions(); /** * Returns an <code>BookSettings</code> @@ -63,7 +63,7 @@ public abstract class SpreadsheetDecoder { * * @return The Enumeration */ - public abstract Iterator getColumnRowInfos(); + public abstract Iterator<ColumnRowInfo> getColumnRowInfos(); /** * Returns the number of populated rows in the current WorkSheet. diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java index 63c3cd423589..bb2c0af88309 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SpreadsheetEncoder.java @@ -40,7 +40,7 @@ public abstract class SpreadsheetEncoder { * * @throws IOException If any I/O error occurs. */ - public SpreadsheetEncoder(String name, String password) throws IOException { }; + public SpreadsheetEncoder(String name, String password) throws IOException { } /** @@ -99,7 +99,7 @@ public abstract class SpreadsheetEncoder { * @param columnRows An <code>IntArrayList</code> of column * widths. */ - public abstract void setColumnRows(ArrayList columnRows) throws IOException; + public abstract void setColumnRows(ArrayList<ColumnRowInfo> columnRows) throws IOException; /** * Set the name definition of this spreadsheet diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java index f1119bc761e4..c9941b2a8f9b 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentDeserializer.java @@ -202,7 +202,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, for(int i=0;i<fontTable.length;) { // Create an element node for the table - Element tableElement = (Element) doc.createElement(TAG_STYLE_FONT_DECL); + Element tableElement = doc.createElement(TAG_STYLE_FONT_DECL); tableElement.setAttribute(ATTRIBUTE_STYLE_NAME, fontTable[i++]); tableElement.setAttribute(ATTRIBUTE_FO_FONT_FAMILY, fontTable[i++]); @@ -251,14 +251,14 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } // Add the Defined Name table if there is one - Iterator nameDefinitionTable = decoder.getNameDefinitions(); + Iterator<NameDefinition> nameDefinitionTable = decoder.getNameDefinitions(); if(nameDefinitionTable.hasNext()) { processNameDefinition(node, nameDefinitionTable); } // add settings NodeList settingsList = settings.getElementsByTagName(TAG_OFFICE_SETTINGS); - Node settingsNode = settingsList.item(0);; + Node settingsNode = settingsList.item(0); processSettings(settingsNode); } @@ -276,12 +276,12 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, */ protected void processSettings(Node root) { - Element configItemSetEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_SET); + Element configItemSetEntry = settings.createElement(TAG_CONFIG_ITEM_SET); configItemSetEntry.setAttribute(ATTRIBUTE_CONFIG_NAME, "view-settings"); - Element configItemMapIndexed = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_INDEXED); + Element configItemMapIndexed = settings.createElement(TAG_CONFIG_ITEM_MAP_INDEXED); configItemMapIndexed.setAttribute(ATTRIBUTE_CONFIG_NAME, "Views"); - Element configItemMapEntry = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY); - BookSettings bs = (BookSettings) decoder.getSettings(); + Element configItemMapEntry = settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY); + BookSettings bs = decoder.getSettings(); bs.writeNode(settings, configItemMapEntry); configItemMapIndexed.appendChild(configItemMapEntry); @@ -300,15 +300,15 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * * @throws IOException If any I/O error occurs. */ - protected void processNameDefinition(Node root, Iterator eNameDefinitions) throws IOException { + protected void processNameDefinition(Node root, Iterator<NameDefinition> eNameDefinitions) throws IOException { Debug.log(Debug.TRACE, "<NAMED-EXPRESSIONS>"); - Element namedExpressionsElement = (Element) doc.createElement(TAG_NAMED_EXPRESSIONS); + Element namedExpressionsElement = doc.createElement(TAG_NAMED_EXPRESSIONS); while(eNameDefinitions.hasNext()) { - NameDefinition tableEntry = (NameDefinition) eNameDefinitions.next(); + NameDefinition tableEntry = eNameDefinitions.next(); tableEntry.writeNode(doc, namedExpressionsElement); } @@ -334,7 +334,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, Debug.log(Debug.TRACE, "<TABLE>"); // Create an element node for the table - Element tableElement = (Element) doc.createElement(TAG_TABLE); + Element tableElement = doc.createElement(TAG_TABLE); // Get the sheet name String sheetName = decoder.getSheetName(); @@ -376,14 +376,14 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, */ protected void processColumns(Node root) throws IOException { - for(Iterator e = decoder.getColumnRowInfos();e.hasNext();) { + for(Iterator<ColumnRowInfo> e = decoder.getColumnRowInfos();e.hasNext();) { - ColumnRowInfo ci = (ColumnRowInfo) e.next(); + ColumnRowInfo ci = e.next(); if(ci.isColumn()) { ColumnStyle cStyle = new ColumnStyle("Default",SxcConstants.COLUMN_STYLE_FAMILY, SxcConstants.DEFAULT_STYLE, ci.getSize(), null); - Style result[] = (Style[]) styleCat.getMatching(cStyle); + Style result[] = styleCat.getMatching(cStyle); String styleName; if(result.length==0) { @@ -398,7 +398,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } // Create an element node for the new row - Element colElement = (Element) doc.createElement(TAG_TABLE_COLUMN); + Element colElement = doc.createElement(TAG_TABLE_COLUMN); colElement.setAttribute(ATTRIBUTE_TABLE_STYLE_NAME, styleName); if(ci.getRepeated()!=1) { String repeatStr = String.valueOf(ci.getRepeated()); @@ -479,17 +479,17 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, col = 1; // Create an element node for the new row - rowElement = (Element) doc.createElement(TAG_TABLE_ROW); + rowElement = doc.createElement(TAG_TABLE_ROW); - for(Iterator e = decoder.getColumnRowInfos();e.hasNext();) { - ColumnRowInfo cri = (ColumnRowInfo) e.next(); + for(Iterator<ColumnRowInfo> e = decoder.getColumnRowInfos();e.hasNext();) { + ColumnRowInfo cri = e.next(); if(cri.isRow() && cri.getRepeated()==newRow-1) { // We have the correct Row BIFFRecord for this row RowStyle rStyle = new RowStyle("Default",SxcConstants.ROW_STYLE_FAMILY, SxcConstants.DEFAULT_STYLE, cri.getSize(), null); - Style result[] = (Style[]) styleCat.getMatching(rStyle); + Style result[] = styleCat.getMatching(rStyle); String styleName; if(result.length==0) { @@ -545,7 +545,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, Format fmt = decoder.getCellFormat(); // Create an element node for the cell - cellElement = (Element) doc.createElement(TAG_TABLE_CELL); + cellElement = doc.createElement(TAG_TABLE_CELL); Node bodyNode = doc.getElementsByTagName(TAG_OFFICE_BODY).item(0); @@ -562,7 +562,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, CellStyle( "Default",SxcConstants.TABLE_CELL_STYLE_FAMILY, SxcConstants.DEFAULT_STYLE, fmt, null); String styleName; - Style result[] = (Style[]) styleCat.getMatching(tStyle); + Style result[] = styleCat.getMatching(tStyle); if(result.length==0) { tStyle.setName("ce" + textStyles++); @@ -584,7 +584,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, rowElement.appendChild(cellElement); // Append the cellContents as a text node - Element textElement = (Element) doc.createElement(TAG_PARAGRAPH); + Element textElement = doc.createElement(TAG_PARAGRAPH); cellElement.appendChild(textElement); textElement.appendChild(doc.createTextNode(cellContents)); @@ -638,7 +638,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, protected void addEmptyRows(int numEmptyRows, Node root, int numEmptyCells) { // Create an element node for the row - Element rowElement = (Element) doc.createElement(TAG_TABLE_ROW); + Element rowElement = doc.createElement(TAG_TABLE_ROW); // TODO - style currently hardcoded - get real value // Set row style-name attribute @@ -681,7 +681,7 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, protected void addEmptyCells(int numColsSkipped, Node row) { // Create an empty cellElement - Element cellElement = (Element) doc.createElement(TAG_TABLE_CELL); + Element cellElement = doc.createElement(TAG_TABLE_CELL); // TODO - style currently hardcoded - get real value // Set cell style-name attribute diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java index f0a651cbbb55..82ab17fafaca 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/SxcDocumentSerializer.java @@ -83,7 +83,7 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, * An array of column widths of the current worksheet. Width is * measured in number of characters. */ - private ArrayList ColumnRowList; + private ArrayList<ColumnRowInfo> ColumnRowList; /** Width, in characters, of the current cell display data. */ private int displayWidth = 0; @@ -183,7 +183,7 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, String families[] = new String[] { SxcConstants.COLUMN_STYLE_FAMILY, SxcConstants.ROW_STYLE_FAMILY, SxcConstants.TABLE_CELL_STYLE_FAMILY }; - Class classes[] = new Class[] { ColumnStyle.class, + Class<?> classes[] = new Class[] { ColumnStyle.class, RowStyle.class, CellStyle.class}; /* @@ -302,7 +302,7 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, Debug.log(Debug.TRACE, "<TABLE>"); - ColumnRowList = new ArrayList(); + ColumnRowList = new ArrayList<ColumnRowInfo>(); // Get table attributes // TODO - extract style from attribute @@ -625,8 +625,8 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, if (fmt.isDefault() && styleName.length()==0) { int index = 1; - for(Iterator e = ColumnRowList.iterator();e.hasNext();) { - ColumnRowInfo cri = (ColumnRowInfo) e.next(); + for(Iterator<ColumnRowInfo> e = ColumnRowList.iterator();e.hasNext();) { + ColumnRowInfo cri = e.next(); if(cri.isColumn()) { if(colID>=index && colID<(index+cri.getRepeated())) { fmt = new Format(cri.getFormat()); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java index 0f383062f7fc..caf135382277 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java @@ -98,7 +98,7 @@ public final class DocumentDeserializerImpl */ public Document deserialize() throws ConvertException, IOException { log("\nFound the XSLT deserializer"); - Iterator enumerate = cd.getDocumentEnumeration(); + Iterator<Object> enumerate = cd.getDocumentEnumeration(); org.w3c.dom.Document domDoc=null; DOMDocument docOut=null; GenericOfficeDocument doc = null; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java index 36f0df7485ce..8de934082dee 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java @@ -106,7 +106,7 @@ public final class DocumentSerializerImpl org.w3c.dom.Document styleDoc = sxwDoc.getStyleDOM(); ByteArrayOutputStream baos= new ByteArrayOutputStream(); ConvertData cd = new ConvertData(); - Node offnode = (Node)domDoc.getDocumentElement(); + Node offnode = domDoc.getDocumentElement(); if (!(offnode.getNodeName()).equals("office:document")){ try{ DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); @@ -141,7 +141,7 @@ public final class DocumentSerializerImpl NodeList nodeList; Node tmpNode; - Node rootNode = (Node)rootElement; + Node rootNode = rootElement; if (metaDoc !=null){ nodeList= metaDoc.getElementsByTagName(TAG_OFFICE_META); if (nodeList.getLength()>0){ diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java index e7a5ed991d3c..59d5ef38d165 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java @@ -135,15 +135,15 @@ public final class PluginFactoryImpl extends PluginFactory public String getDeviceFileExtension(){ - Class c = this.getClass(); + Class<? extends PluginFactoryImpl> c = this.getClass(); InputStream is = c.getResourceAsStream("XsltPlugin.properties"); Properties props = new Properties(); String ext= ".txt"; String mimeType = null; ConverterInfo ci = this.getConverterInfo(); - Iterator enumerate = ci.getDeviceMime(); + Iterator<String> enumerate = ci.getDeviceMime(); while (enumerate.hasNext()) { - mimeType= (String) enumerate.next(); + mimeType= enumerate.next(); } try { props.load(is); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharArrayLCSAlgorithm.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharArrayLCSAlgorithm.java index 2ab19045f613..0d2a3aa67b64 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharArrayLCSAlgorithm.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharArrayLCSAlgorithm.java @@ -54,7 +54,7 @@ public class CharArrayLCSAlgorithm { // in those 2 sequences diffTable = createDiffTable(orgSeq, modSeq); - ArrayList diffResult = new ArrayList(); + ArrayList<Difference> diffResult = new ArrayList<Difference>(); generateResult(diffTable, orgSeqlen, modSeqlen, diffResult); @@ -154,7 +154,7 @@ public class CharArrayLCSAlgorithm { * and positions filled in. */ private void generateResult(int[][] diffTable, - int i, int j, ArrayList diffVector) { + int i, int j, ArrayList<Difference> diffVector) { // handle the first element if (i == 0 || j == 0) { diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharacterParser.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharacterParser.java index 7e3775526dc1..da22778ad1ab 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharacterParser.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/CharacterParser.java @@ -46,7 +46,7 @@ public class CharacterParser { private TextNodeIterator textNodes; private int currentPosition = 0; - private List nodeList_ = null; + private List<TextNodeEntry> nodeList_ = null; private char[] charArray; @@ -57,7 +57,7 @@ public class CharacterParser { */ public CharacterParser(Node node) { textNodes = new TextNodeIterator(node); - nodeList_ = new ArrayList(); + nodeList_ = new ArrayList<TextNodeEntry>(); parseNodes(); } @@ -68,7 +68,7 @@ public class CharacterParser { * * @return The <code>Node</code> pointer with the given character position. */ - public List getNodeList() { + public List<TextNodeEntry> getNodeList() { // will go through the nodeList to find the corresponding node return nodeList_; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorLCSAlgorithm.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorLCSAlgorithm.java index 3f35dcbfde30..58e511c5f022 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorLCSAlgorithm.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorLCSAlgorithm.java @@ -50,7 +50,7 @@ public class IteratorLCSAlgorithm implements DiffAlgorithm { printDiffTable(diffTable); } - ArrayList diffResult = new ArrayList(); + ArrayList<Difference> diffResult = new ArrayList<Difference>(); generateResult(diffTable, orgSeqlen, modSeqlen, diffResult); @@ -161,7 +161,7 @@ public class IteratorLCSAlgorithm implements DiffAlgorithm { * and positions fill in. */ private void generateResult(int[][] diffTable, - int i, int j, ArrayList diffVector) { + int i, int j, ArrayList<Difference> diffVector) { // handle the first element if (i == 0 && j == 0) { diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorRowCompare.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorRowCompare.java index 86140d1d7b17..ec93778a78de 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorRowCompare.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/IteratorRowCompare.java @@ -76,7 +76,7 @@ public class IteratorRowCompare implements DiffAlgorithm { int orgSeqlen = orgSeq.elementCount(); int modSeqlen = modSeq.elementCount(); - ArrayList diffVector = new ArrayList(); + ArrayList<Difference> diffVector = new ArrayList<Difference>(); // i and j are counters to keep track the current position in the // iterator diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/NodeIterator.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/NodeIterator.java index 971d94864d89..31cc2efca0b0 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/NodeIterator.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/diff/NodeIterator.java @@ -46,7 +46,7 @@ import org.w3c.dom.NodeList; */ public abstract class NodeIterator implements Iterator { - private List nodeList = null; + private List<Node> nodeList = null; private int currentPosition = 0; private Node root; private ConverterCapabilities cc_ = null; @@ -60,7 +60,7 @@ public abstract class NodeIterator implements Iterator { */ public NodeIterator(ConverterCapabilities cc, Node node) { cc_ = cc; - nodeList = new ArrayList(); + nodeList = new ArrayList<Node>(); root = node; markTree(node); } @@ -136,7 +136,7 @@ public abstract class NodeIterator implements Iterator { public void refresh() { - nodeList = new ArrayList(); + nodeList = new ArrayList<Node>(); markTree(root); currentPosition = 0; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/CharacterBaseParagraphMerge.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/CharacterBaseParagraphMerge.java index c4b1e9a53ccb..37917a1d47b3 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/CharacterBaseParagraphMerge.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/CharacterBaseParagraphMerge.java @@ -78,8 +78,8 @@ public final class CharacterBaseParagraphMerge CharacterParser modParser, Difference[] diffs) { - List orgNodeList = orgParser.getNodeList(); - List modNodeList = modParser.getNodeList(); + List<TextNodeEntry> orgNodeList = orgParser.getNodeList(); + List<TextNodeEntry> modNodeList = modParser.getNodeList(); int diffCount = 0; int modNodeListCnt = 0; int numNode = orgNodeList.size(); @@ -88,7 +88,7 @@ public final class CharacterBaseParagraphMerge int extraChar = 0; int orgDiffCount = diffCount; - TextNodeEntry orgTextNode = (TextNodeEntry)(orgNodeList.get(i)); + TextNodeEntry orgTextNode = (orgNodeList.get(i)); Debug.log(Debug.INFO, "checking node " + (i + 1) + " of " + numNode); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java index ece388c5c2ba..9ff7addbd5b4 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java @@ -35,7 +35,7 @@ public class ConverterInfoList { private static String defaultPropsFile = "ConverterInfoList.properties"; - private ArrayList jars; + private ArrayList<String> jars; private Properties props = null; @@ -59,7 +59,7 @@ public class ConverterInfoList { */ public ConverterInfoList(String propsFile) throws IOException { - Class c = this.getClass(); + Class<? extends ConverterInfoList> c = this.getClass(); InputStream is = c.getResourceAsStream(propsFile); BufferedInputStream bis = new BufferedInputStream(is); props = new Properties(); @@ -68,7 +68,7 @@ public class ConverterInfoList { int i = 1; String jarFileName = new String(); - jars = new ArrayList(); + jars = new ArrayList<String>(); while ((jarFileName = props.getProperty("jarname" + i)) != null) { jars.add(jarFileName); @@ -88,7 +88,7 @@ public class ConverterInfoList { * <code>String</code> describes a plug-in to be * loaded into the registry. */ - public Iterator getJarFileEnum() { + public Iterator<String> getJarFileEnum() { return jars.iterator(); } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java index 0bd127318e25..8fb8d89977fe 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java @@ -30,6 +30,7 @@ import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConverterFactory; import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentMerger; +import org.openoffice.xmerge.util.registry.ConverterInfo; import org.openoffice.xmerge.util.registry.ConverterInfoMgr; import org.openoffice.xmerge.util.registry.ConverterInfoReader; @@ -51,7 +52,7 @@ public final class Driver { private String mergeFile = null; /** Command-line parmeter. */ - private ArrayList deviceFiles = new ArrayList(); + private ArrayList<String> deviceFiles = new ArrayList<String>(); /** Command-line parmeter shortcuts. */ private String mimeTypes[] = { @@ -78,12 +79,12 @@ public final class Driver { " property file"); } - Iterator jarInfoEnumeration; + Iterator<ConverterInfo> jarInfoEnumeration; ConverterInfoReader cir; - Iterator jarFileEnum = cil.getJarFileEnum(); + Iterator<String> jarFileEnum = cil.getJarFileEnum(); while (jarFileEnum.hasNext()) { - String jarName = (String) jarFileEnum.next(); + String jarName = jarFileEnum.next(); try { cir = new ConverterInfoReader(jarName, false); jarInfoEnumeration = cir.getConverterInfoEnumeration(); @@ -134,9 +135,9 @@ public final class Driver { } try { - Iterator dfEnum = deviceFiles.iterator(); + Iterator<String> dfEnum = deviceFiles.iterator(); while (dfEnum.hasNext()) { - processFile = (String)dfEnum.next(); + processFile = dfEnum.next(); File f = new File(processFile); // Make sure the input file actually exists before using it @@ -165,7 +166,7 @@ public final class Driver { if (dataOut != null ) { if (mergeFile == null) { - Iterator docEnum = dataOut.getDocumentEnumeration(); + Iterator<Object> docEnum = dataOut.getDocumentEnumeration(); while (docEnum.hasNext()) { Document docOut = (Document)docEnum.next(); String fileName = docOut.getFileName(); @@ -185,7 +186,7 @@ public final class Driver { FileInputStream mergeIS = new FileInputStream(mergeFile); Document mergeDoc = myConvert.getOfficeDocument(mergeFile, mergeIS); DocumentMerger merger = myConvert.getDocumentMerger(mergeDoc); - Iterator mergeDocEnum = dataOut.getDocumentEnumeration(); + Iterator<Object> mergeDocEnum = dataOut.getDocumentEnumeration(); Document convertedFile = (Document)mergeDocEnum.next(); merger.merge(convertedFile); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java index dcd25b26b931..b43f0033513c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java @@ -62,7 +62,7 @@ public final class Debug { try { - Class c = new Debug().getClass(); + Class<? extends Debug> c = new Debug().getClass(); InputStream is = c.getResourceAsStream("Debug.properties"); Properties props = new Properties(); props.load(is); @@ -316,7 +316,7 @@ public final class Debug { for (int i = 0; i < bytes.length; i++) { - int ch = ((int) bytes[i] & 0xff); + int ch = (bytes[i] & 0xff); String str = Integer.toHexString(ch); if (str.length() < 2) buff.append('0'); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/EndianConverter.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/EndianConverter.java index 93a23fb0800f..5c6ccc5a2f4e 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/EndianConverter.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/EndianConverter.java @@ -162,7 +162,7 @@ public class EndianConverter { ((long)(value[3]&0xFF) << 24) + ((long)(value[2]&0xFF) << 16) + ((long)(value[1]&0xFF) << 8) + - (long)(value[0]&0xFF)); + (value[0]&0xFF)); return Double.longBitsToDouble(lvalue); } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/IntArrayList.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/IntArrayList.java index eff94bf8f901..aa903f2cf348 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/IntArrayList.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/IntArrayList.java @@ -28,14 +28,14 @@ import java.lang.Integer; public class IntArrayList { /** The list to hold our integers. */ - private ArrayList list; + private ArrayList<Integer> list; /** * Constructor. * Creates the list with 0 length. */ public IntArrayList() { - list = new ArrayList(); + list = new ArrayList<Integer>(); } @@ -45,7 +45,7 @@ public class IntArrayList { * @param initialCapacity Initial capacity of the list. */ public IntArrayList(int initialCapacity) { - list = new ArrayList(initialCapacity); + list = new ArrayList<Integer>(initialCapacity); } @@ -122,7 +122,7 @@ public class IntArrayList { * @return The value of the data stored in element index. */ public int get(int index) { - return ((Integer)list.get(index)).intValue(); + return list.get(index).intValue(); } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java index 2bd53b2ea975..a0f2d8b6bf75 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java @@ -46,7 +46,7 @@ public class OfficeUtil implements OfficeConstants { * representing the text. */ public static Node[] parseText(String text, Document parentDoc) { - ArrayList nodeVec = new ArrayList(); + ArrayList<Node> nodeVec = new ArrayList<Node>(); /* * Break up the text from the text run into Open @@ -120,7 +120,7 @@ public class OfficeUtil implements OfficeConstants { // Now create and populate an array to return the nodes in. Node nodes[] = new Node[nodeVec.size()]; for (int i = 0; i < nodeVec.size(); i++) - nodes[i] = (Node)nodeVec.get(i); + nodes[i] = nodeVec.get(i); return nodes; } }
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/TwipsConverter.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/TwipsConverter.java index 3d21c185d7e7..e43e38240b75 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/TwipsConverter.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/TwipsConverter.java @@ -37,7 +37,7 @@ public class TwipsConverter { public static float twips2cm(int value) { float inches = (float) value/1440; - float cm = (float) inches*(float)2.54; + float cm = inches*(float)2.54; return cm; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java index 259cee0d3401..37b504132f95 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java @@ -54,7 +54,7 @@ public class ConverterInfo { private String piJarName; private String piOfficeMime; - private ArrayList piDeviceMime; + private ArrayList<String> piDeviceMime; private String piDisplayName; private String piDescription; private String piVersion; @@ -88,7 +88,7 @@ public class ConverterInfo { * be loaded. */ public ConverterInfo(String jarName, String officeMime, - ArrayList deviceMime, String displayName, String description, + ArrayList<String> deviceMime, String displayName, String description, String version, String vendor, String impl,String xsltSerial, String xsltDeserial) throws RegistryException { @@ -117,16 +117,16 @@ public class ConverterInfo { URL jarURL = new URL(jarName); URLClassLoader loader = new URLClassLoader(new URL[] { jarURL }, piClassLoader); - Class clas = loader.loadClass(piClassImpl); - Class[] argumentTypes = { org.openoffice.xmerge.util.registry.ConverterInfo.class }; - Constructor construct = clas.getConstructor(argumentTypes); + Class<?> clas = loader.loadClass(piClassImpl); + Class<?>[] argumentTypes = { org.openoffice.xmerge.util.registry.ConverterInfo.class }; + Constructor<?> construct = clas.getConstructor(argumentTypes); Object[] arguments = { this }; piPluginFactory = ( PluginFactory ) construct.newInstance(arguments); // See which interfaces the plug-in PluginFactory supports. // - Class[] cl = piPluginFactory.getClass().getInterfaces(); + Class<?>[] cl = piPluginFactory.getClass().getInterfaces(); for (int i=0; i < cl.length; i++) { if (cl[i].getName().equals("org.openoffice.xmerge.DocumentSerializerFactory")) { @@ -166,7 +166,7 @@ public class ConverterInfo { public ConverterInfo(String jarName, String officeMime, - ArrayList deviceMime, String displayName, String description, + ArrayList<String> deviceMime, String displayName, String description, String version, String vendor, String impl) throws RegistryException { @@ -192,16 +192,16 @@ public class ConverterInfo { URL jarURL = new URL(jarName); URLClassLoader loader = new URLClassLoader(new URL[] { jarURL }, piClassLoader); - Class clas = loader.loadClass(piClassImpl); - Class[] argumentTypes = { org.openoffice.xmerge.util.registry.ConverterInfo.class }; - Constructor construct = clas.getConstructor(argumentTypes); + Class<?> clas = loader.loadClass(piClassImpl); + Class<?>[] argumentTypes = { org.openoffice.xmerge.util.registry.ConverterInfo.class }; + Constructor<?> construct = clas.getConstructor(argumentTypes); Object[] arguments = { this }; piPluginFactory = ( PluginFactory ) construct.newInstance(arguments); // See which interfaces the plug-in PluginFactory supports. // - Class[] cl = piPluginFactory.getClass().getInterfaces(); + Class<?>[] cl = piPluginFactory.getClass().getInterfaces(); for (int i=0; i < cl.length; i++) { if (cl[i].getName().equals("org.openoffice.xmerge.DocumentSerializerFactory")) { @@ -290,7 +290,7 @@ public class ConverterInfo { * @return An <code>Enumeration</code> of <code>String</code> * objects indicating the device mime-type. */ - public Iterator getDeviceMime() { + public Iterator<String> getDeviceMime() { return(piDeviceMime.iterator()); } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java index f6d7689e537f..9f5ff30ec196 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java @@ -32,13 +32,13 @@ import java.io.*; */ public final class ConverterInfoMgr { - private static ArrayList converterInfoList; + private static ArrayList<ConverterInfo> converterInfoList; /** * Constructor */ static { - converterInfoList = new ArrayList(); + converterInfoList = new ArrayList<ConverterInfo>(); } /** @@ -82,9 +82,9 @@ public final class ConverterInfoMgr { // Verify there is no converter with the same Display Name in // the registry. // - Iterator ciEnum = converterInfoList.iterator(); + Iterator<ConverterInfo> ciEnum = converterInfoList.iterator(); while (ciEnum.hasNext()) { - converterInfo = (ConverterInfo)ciEnum.next(); + converterInfo = ciEnum.next(); if (ci.getDisplayName().equals(converterInfo.getDisplayName())) { RegistryException re = new RegistryException( "Converter with specified display name already exists."); @@ -112,10 +112,10 @@ public final class ConverterInfoMgr { * @throws RegistryException If a <code>ConverterInfo</code> in the * <code>Vector</code> is not valid. */ - public static void addPlugIn(Iterator jarEnum) throws RegistryException { + public static void addPlugIn(Iterator<ConverterInfo> jarEnum) throws RegistryException { while (jarEnum.hasNext()) { - ConverterInfo converterInfo = (ConverterInfo)jarEnum.next(); + ConverterInfo converterInfo = jarEnum.next(); addPlugIn(converterInfo); } } @@ -128,7 +128,7 @@ public final class ConverterInfoMgr { * <code>ConverterInfo</code> objects, an empty * <code>Vector</code> if none exist. */ - public static Iterator getConverterInfoEnumeration() { + public static Iterator<ConverterInfo> getConverterInfoEnumeration() { return (converterInfoList.iterator()); } @@ -157,10 +157,10 @@ public final class ConverterInfoMgr { } }*/ - Iterator ciIter = converterInfoList.iterator(); + Iterator<ConverterInfo> ciIter = converterInfoList.iterator(); while (ciIter.hasNext()) { - converterInfo = (ConverterInfo)ciIter.next(); + converterInfo = ciIter.next(); if (jar.equals(converterInfo.getJarName())) { ciIter.remove(); rc = true; @@ -183,10 +183,10 @@ public final class ConverterInfoMgr { ConverterInfo converterInfo; boolean rc = false; - Iterator ciEnum = converterInfoList.iterator(); + Iterator<ConverterInfo> ciEnum = converterInfoList.iterator(); while (ciEnum.hasNext()) { - converterInfo = (ConverterInfo)ciEnum.next(); + converterInfo = ciEnum.next(); if (name.equals(converterInfo.getDisplayName())) { converterInfoList.remove(converterInfo); rc = true; @@ -218,17 +218,17 @@ public final class ConverterInfoMgr { // Loop over elements comparing with deviceFromMime // - Iterator ciEnum = converterInfoList.iterator(); + Iterator<ConverterInfo> ciEnum = converterInfoList.iterator(); while (ciEnum.hasNext()) { - converterInfo = (ConverterInfo)ciEnum.next(); - String toDeviceInfo = (String)converterInfo.getOfficeMime(); - Iterator fromEnum = converterInfo.getDeviceMime(); + converterInfo = ciEnum.next(); + String toDeviceInfo = converterInfo.getOfficeMime(); + Iterator<String> fromEnum = converterInfo.getDeviceMime(); // Loop over the deviceMime types. // while (fromEnum.hasNext()) { - String fromDeviceInfo = (String)fromEnum.next(); + String fromDeviceInfo = fromEnum.next(); if (deviceMime.trim().equals(fromDeviceInfo) && officeMime.trim().equals(toDeviceInfo)) { return (converterInfo); @@ -261,36 +261,36 @@ public final class ConverterInfoMgr { // Loop over elements comparing with deviceFromMime // - Iterator cifEnum = converterInfoList.iterator(); + Iterator<ConverterInfo> cifEnum = converterInfoList.iterator(); while (cifEnum.hasNext()) { - converterInfo[0] = (ConverterInfo)cifEnum.next(); + converterInfo[0] = cifEnum.next(); String fromOfficeInfo = converterInfo[0].getOfficeMime(); - Iterator fromEnum = converterInfo[0].getDeviceMime(); + Iterator<String> fromEnum = converterInfo[0].getDeviceMime(); // Loop over the deviceMime types looking for a deviceFromMime // match. // while (fromEnum.hasNext()) { - String fromDeviceInfo = (String)fromEnum.next(); + String fromDeviceInfo = fromEnum.next(); if (deviceFromMime.trim().equals(fromDeviceInfo)) { // Found a a match for deviceFrom. Now loop over the // elements comparing with deviceToMime // - Iterator citEnum = converterInfoList.iterator(); + Iterator<ConverterInfo> citEnum = converterInfoList.iterator(); while (citEnum.hasNext()) { - converterInfo[1] = (ConverterInfo)citEnum.next(); + converterInfo[1] = citEnum.next(); String toOfficeInfo = converterInfo[1].getOfficeMime(); - Iterator toEnum = converterInfo[1].getDeviceMime(); + Iterator<String> toEnum = converterInfo[1].getDeviceMime(); // Loop over deviceMime types looking for a // deviceToMime match. // while (toEnum.hasNext()) { - String toDeviceInfo = (String)toEnum.next(); + String toDeviceInfo = toEnum.next(); if (deviceToMime.trim().equals(toDeviceInfo) && fromOfficeInfo.equals(toOfficeInfo)) { @@ -365,7 +365,7 @@ public final class ConverterInfoMgr { } if (cir != null) { - Iterator jarInfoEnum = cir.getConverterInfoEnumeration(); + Iterator<ConverterInfo> jarInfoEnum = cir.getConverterInfoEnumeration(); try { ConverterInfoMgr.addPlugIn(jarInfoEnum); } catch (Exception e) { @@ -471,25 +471,25 @@ public final class ConverterInfoMgr { // } else if (c == 'V') { - Iterator ciEnum = ConverterInfoMgr.getConverterInfoEnumeration(); + Iterator<ConverterInfo> ciEnum = ConverterInfoMgr.getConverterInfoEnumeration(); int ciCnt = 0; while (ciEnum.hasNext()) { System.out.println(""); System.out.println(" Displaying converter number " + ciCnt); - ConverterInfo converterInfo = (ConverterInfo)ciEnum.next(); + ConverterInfo converterInfo = ciEnum.next(); System.out.println(" DisplayName : " + converterInfo.getDisplayName()); System.out.println(" JarFile : " + converterInfo.getJarName()); System.out.println(" Description : " + converterInfo.getDescription()); System.out.println(" Version : " + converterInfo.getVersion()); System.out.println(" OfficeMime : " + converterInfo.getOfficeMime()); - Iterator fromEnum = converterInfo.getDeviceMime(); + Iterator<String> fromEnum = converterInfo.getDeviceMime(); int feCnt = 1; while (fromEnum.hasNext()) { System.out.println(" DeviceMime : (#" + feCnt + ") : " + - (String)fromEnum.next()); + fromEnum.next()); feCnt++; } if (feCnt == 1) { diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java index bcf0819bb141..38b4bb9bb86e 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java @@ -50,7 +50,7 @@ public class ConverterInfoReader { private final static String TAG_XSLT_SERIAL = "converter-xslt-serialize"; private String jarfilename; private Document document; - private ArrayList converterInfoList; + private ArrayList<ConverterInfo> converterInfoList; /** @@ -87,7 +87,7 @@ public class ConverterInfoReader { JarFile jarfile; URL url; - converterInfoList = new ArrayList(); + converterInfoList = new ArrayList<ConverterInfo>(); jarfilename = jar; // Get Jar via URL @@ -161,7 +161,7 @@ public class ConverterInfoReader { Node detailNode; String elementTagName; String officeMime = null; - ArrayList deviceMime = new ArrayList(); + ArrayList<String> deviceMime = new ArrayList<String>(); String name = null; String desc = null; String version = null; @@ -260,7 +260,7 @@ public class ConverterInfoReader { * @return An <code>Enumeration</code> of <code>ConverterInfo</code> * objects. */ - public Iterator getConverterInfoEnumeration() { + public Iterator<ConverterInfo> getConverterInfoEnumeration() { return (converterInfoList.iterator()); } } |