diff options
43 files changed, 572 insertions, 582 deletions
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 a9ebc6ab0045..10a28c7f2e4f 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 @@ -18,24 +18,23 @@ package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; -import org.w3c.dom.Element; -import org.w3c.dom.Text; - import java.io.IOException; -import java.util.Enumeration; +import java.util.Iterator; -import org.openoffice.xmerge.Document; import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConvertException; +import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.converter.palm.Record; import org.openoffice.xmerge.converter.palm.PalmDocument; +import org.openoffice.xmerge.converter.palm.Record; +import org.openoffice.xmerge.converter.xml.OfficeConstants; +import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; import org.openoffice.xmerge.util.Debug; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; /** * <p>AportisDoc implementation of <code>DocumentDeserializer</code> @@ -88,9 +87,9 @@ public final class DocumentDeserializerImpl Document doc = null; int i=0; ConvertData cdOut; - Enumeration e = cd.getDocumentEnumeration(); - while (e.hasMoreElements()) { - PalmDocument palmDoc = (PalmDocument) e.nextElement(); + Iterator e = cd.getDocumentEnumeration(); + while (e.hasNext()) { + PalmDocument palmDoc = (PalmDocument) e.next(); PalmDB pdb = palmDoc.getPdb(); log("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); diff --git a/xmerge/source/bridge/java/XMergeBridge.java b/xmerge/source/bridge/java/XMergeBridge.java index f643f6007ddb..6c52a79ee003 100644 --- a/xmerge/source/bridge/java/XMergeBridge.java +++ b/xmerge/source/bridge/java/XMergeBridge.java @@ -23,45 +23,44 @@ /*Java Uno Helper Classes*/ -import com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter; -import com.sun.star.lib.uno.adapter.XOutputStreamToOutputStreamAdapter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.util.Iterator; + +import javax.xml.parsers.ParserConfigurationException; + +import org.openoffice.xmerge.Convert; +import org.openoffice.xmerge.ConvertData; +import org.openoffice.xmerge.ConverterFactory; +import org.openoffice.xmerge.Document; +import org.openoffice.xmerge.converter.xml.OfficeDocument; +import org.openoffice.xmerge.util.registry.ConverterInfo; +import org.openoffice.xmerge.util.registry.ConverterInfoMgr; +import org.openoffice.xmerge.util.registry.ConverterInfoReader; -/*StarOffice/Uno Classes*/ +import com.sun.star.comp.loader.FactoryHelper; +import com.sun.star.frame.XConfigManager; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XServiceInfo; -import com.sun.star.lang.XTypeProvider; -import com.sun.star.uno.Type; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.comp.loader.FactoryHelper; import com.sun.star.lang.XServiceName; import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lang.XTypeProvider; +import com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter; +import com.sun.star.lib.uno.adapter.XOutputStreamToOutputStreamAdapter; import com.sun.star.registry.XRegistryKey; -import com.sun.star.frame.XConfigManager; -import com.sun.star.xml.sax.InputSource; -import com.sun.star.xml.sax.XParser; -import com.sun.star.io.XInputStream; -import com.sun.star.io.XOutputStream; -import com.sun.star.xml.sax.XDocumentHandler; import com.sun.star.uno.AnyConverter; - -/* Generated from Idls */ -import com.sun.star.xml.XImportFilter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; import com.sun.star.xml.XExportFilter; - -/* XMerge Classes */ -import org.openoffice.xmerge.util.registry.ConverterInfoReader; -import org.openoffice.xmerge.util.registry.ConverterInfo; -import org.openoffice.xmerge.util.registry.ConverterInfoMgr; -import org.openoffice.xmerge.Convert; -import org.openoffice.xmerge.ConverterFactory; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.converter.xml.OfficeDocument; -/*Java Classes*/ -import java.util.Enumeration; -import java.io.*; -import javax.xml.parsers.*; -import java.net.URI; +import com.sun.star.xml.XImportFilter; +import com.sun.star.xml.sax.InputSource; +import com.sun.star.xml.sax.XDocumentHandler; +import com.sun.star.xml.sax.XParser; /** This outer class provides an inner class to implement the service @@ -436,7 +435,7 @@ public class XMergeBridge { String name= getFileName(FileName); ConverterInfo converterInfo = null; - Enumeration ciEnum= null; + Iterator ciEnum= null; XInputStreamToInputStreamAdapter xis =new XInputStreamToInputStreamAdapter(xml); @@ -476,10 +475,10 @@ public class XMergeBridge { cv.addInputStream(name,(InputStream)xis,false); ConvertData dataOut = cv.convert(); - Enumeration docEnum = dataOut.getDocumentEnumeration(); + Iterator docEnum = dataOut.getDocumentEnumeration(); - if (docEnum.hasMoreElements()){ - Document docOut = (Document)docEnum.nextElement(); + if (docEnum.hasNext()){ + Document docOut = (Document)docEnum.next(); String fileName = docOut.getFileName(); docOut.write(newxos); @@ -488,7 +487,7 @@ public class XMergeBridge { int i=1; - while (docEnum.hasMoreElements() && sURL.startsWith("file:")) { + while (docEnum.hasNext() && sURL.startsWith("file:")) { URI uri=new URI(sURL); String newFileName= getPath(uri); @@ -502,7 +501,7 @@ public class XMergeBridge { } FileOutputStream fos = new FileOutputStream(newFile); - docOut = (Document)docEnum.nextElement(); + docOut = (Document)docEnum.next(); fileName = docOut.getFileName(); docOut.write(fos); fos.flush(); @@ -539,9 +538,9 @@ public class XMergeBridge { cv.addInputStream(name,(InputStream)xis,false); ConvertData dataIn = cv.convert(); - Enumeration docEnum = dataIn.getDocumentEnumeration(); - while (docEnum.hasMoreElements()) { - OfficeDocument docIn = (OfficeDocument)docEnum.nextElement(); + Iterator docEnum = dataIn.getDocumentEnumeration(); + while (docEnum.hasNext()) { + OfficeDocument docIn = (OfficeDocument)docEnum.next(); docIn.write(newxos,false); } 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 49f75b09ad31..3a76673e9b99 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 @@ -19,19 +19,29 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; import java.util.Enumeration; +import java.util.Iterator; import java.util.NoSuchElementException; import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.converter.xml.sxc.BookSettings; -import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; +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.ColumnRowInfo; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.*; +import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; +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; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.ExtendedFormat; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.FloatNumber; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.FontDescription; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Formula; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Row; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Worksheet; +import org.openoffice.xmerge.util.Debug; /** * This class is used by {@link @@ -48,7 +58,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { private int maxRows = 0; private int maxCols = 0; private int wsIndex; - private Enumeration cellValue; + private Iterator cellValue; private Format fmt = null; /** @@ -80,8 +90,8 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { */ public void addDeviceContent(ConvertData cd) throws IOException { - Enumeration e = cd.getDocumentEnumeration(); - wb = (Workbook) e.nextElement(); + Iterator e = cd.getDocumentEnumeration(); + wb = (Workbook) e.next(); } @@ -93,7 +103,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { */ public int getNumberOfSheets() { - Vector v = wb.getWorksheetNames(); + ArrayList v = wb.getWorksheetNames(); Debug.log(Debug.TRACE,"Total Number of Sheets : " + v.size()); return (v.size()); } @@ -104,17 +114,17 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * * @return The number of sheets in the WorkBook. */ - public Enumeration getNameDefinitions() { + public Iterator getNameDefinitions() { - Enumeration e = wb.getDefinedNames(); - Vector nameDefinitionVector = new Vector(); - while(e.hasMoreElements()) { - DefinedName dn = (DefinedName)e.nextElement(); + Iterator e = wb.getDefinedNames(); + ArrayList nameDefinitionVector = new ArrayList(); + while(e.hasNext()) { + DefinedName dn = (DefinedName)e.next(); NameDefinition nameDefinitionEntry = dn.getNameDefinition(); nameDefinitionVector.add(nameDefinitionEntry); } Debug.log(Debug.TRACE,"Getting " + nameDefinitionVector.size() + " DefinedName records"); - return (nameDefinitionVector.elements()); + return (nameDefinitionVector.iterator()); } /** @@ -133,13 +143,13 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { * * @return The number of sheets in the WorkBook. */ - public Enumeration getColumnRowInfos() { + public Iterator getColumnRowInfos() { - Vector colRowVector = new Vector(); + ArrayList colRowVector = new ArrayList(); // Collect Columns from worksheet and add them to the vector - for(Enumeration e = ws.getColInfos();e.hasMoreElements();) { - ColInfo ci = (ColInfo)e.nextElement(); + for(Iterator e = ws.getColInfos();e.hasNext();) { + ColInfo ci = (ColInfo)e.next(); int repeated = ci.getLast() - ci.getFirst() + 1; ColumnRowInfo colInfo = new ColumnRowInfo( ci.getColWidth(), repeated, @@ -148,8 +158,8 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { } // Collect Rows from worksheet and add them to the vector - for(Enumeration e = ws.getRows();e.hasMoreElements();) { - Row rw = (Row)e.nextElement(); + for(Iterator e = ws.getRows();e.hasNext();) { + Row rw = (Row)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(); @@ -159,7 +169,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { colRowVector.add(rowInfo); } Debug.log(Debug.TRACE,"Getting " + colRowVector.size() + " ColRowInfo records"); - return (colRowVector.elements()); + return (colRowVector.iterator()); } /** @@ -214,7 +224,7 @@ final class PocketExcelDecoder extends SpreadsheetDecoder { boolean success = false; try { - cell = (CellValue) cellValue.nextElement(); + cell = (CellValue) cellValue.next(); Debug.log(Debug.TRACE,"Current Cell : " + cell.getString()); readCellFormat(); success = true; 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 af59467c18fb..88ddfdb60749 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 @@ -19,7 +19,7 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; import org.openoffice.xmerge.util.Debug; @@ -77,7 +77,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { */ public int getNumberOfSheets() { - Vector v = wb.getWorksheetNames(); + ArrayList v = wb.getWorksheetNames(); return (v.size()); } @@ -202,7 +202,7 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { * @param columnWidths An <code>IntArrayList</code> of column * widths. */ - public void setColumnRows(Vector columnRows) throws IOException { + public void setColumnRows(ArrayList columnRows) throws IOException { wb.addColInfo(columnRows); } @@ -268,9 +268,8 @@ final class PocketExcelEncoder extends SpreadsheetEncoder { * @param sheet The required sheet. */ public String getSheetName(int sheet) { - - Vector v = wb.getWorksheetNames(); - String wsName = (String) (v.elementAt(sheet)); + ArrayList 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 ca857c330be4..7c59af8005d5 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 @@ -19,15 +19,14 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel; import java.io.IOException; -import java.util.Enumeration; -import java.util.Vector; +import java.util.ArrayList; +import java.util.Iterator; -import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelDecoder; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; +import org.openoffice.xmerge.util.Debug; /** @@ -84,8 +83,8 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { protected String getWorkbookName(ConvertData cd) throws IOException { - Enumeration e = cd.getDocumentEnumeration(); - Workbook wb = (Workbook) e.nextElement(); + Iterator e = cd.getDocumentEnumeration(); + Workbook wb = (Workbook) e.next(); String workbookName = wb.getName(); return workbookName; @@ -103,14 +102,14 @@ public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { protected String[] getWorksheetNames(ConvertData cd) throws IOException { - Enumeration e = cd.getDocumentEnumeration(); - Workbook wb = (Workbook) e.nextElement(); - Vector v = wb.getWorksheetNames(); - e = v.elements(); + Iterator e = cd.getDocumentEnumeration(); + Workbook wb = (Workbook) e.next(); + ArrayList v = wb.getWorksheetNames(); + e = v.iterator(); String worksheetNames[] = new String[v.size()]; int i = 0; - while(e.hasMoreElements()) { - worksheetNames[i] = (String) e.nextElement(); + while(e.hasNext()) { + worksheetNames[i] = (String) e.next(); Debug.log(Debug.TRACE,"Worksheet Name : " + worksheetNames[i]); i++; } 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 2d1a5d750e0c..d3ebde40a97e 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 @@ -18,20 +18,21 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; -import java.io.OutputStream; -import java.io.InputStream; import java.io.IOException; -import java.util.Vector; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; import java.util.Enumeration; +import java.util.Iterator; import org.openoffice.xmerge.converter.xml.OfficeConstants; +import org.openoffice.xmerge.converter.xml.sxc.BookSettings; +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.BookSettings; import org.openoffice.xmerge.converter.xml.sxc.SheetSettings; -import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; -import org.openoffice.xmerge.converter.xml.sxc.ColumnRowInfo; +import org.openoffice.xmerge.util.Debug; /** * This class is used by <code> PxlDocument</code> to maintain pexcel @@ -42,11 +43,11 @@ import org.openoffice.xmerge.converter.xml.sxc.ColumnRowInfo; public class Workbook implements org.openoffice.xmerge.Document, OfficeConstants { - private Vector fonts = new Vector(); - private Vector extendedFormats = new Vector(); - private Vector worksheets = new Vector(); - private Vector boundsheets = new Vector(); - private Vector definedNames = new Vector(); + 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 static final CodePage cp; private static final Window1 win1; private static final BeginningOfFile bof;; @@ -98,27 +99,27 @@ OfficeConstants { public void write(OutputStream os) throws IOException { bof.write(os); cp.write(os); - for(Enumeration e = definedNames.elements();e.hasMoreElements();) { - DefinedName dn = (DefinedName) e.nextElement(); + for(Iterator e = definedNames.iterator();e.hasNext();) { + DefinedName dn = (DefinedName) e.next(); dn.write(os); } win1.write(os); - for(Enumeration e = fonts.elements();e.hasMoreElements();) { - FontDescription fd = (FontDescription) e.nextElement(); + for(Iterator e = fonts.iterator();e.hasNext();) { + FontDescription fd = (FontDescription) e.next(); fd.write(os); } - for(Enumeration e = extendedFormats.elements();e.hasMoreElements();) { - ExtendedFormat xf = (ExtendedFormat) e.nextElement(); + for(Iterator e = extendedFormats.iterator();e.hasNext();) { + ExtendedFormat xf = (ExtendedFormat) e.next(); xf.write(os); } - for(Enumeration e = boundsheets.elements();e.hasMoreElements();) { - BoundSheet bs = (BoundSheet) e.nextElement(); + for(Iterator e = boundsheets.iterator();e.hasNext();) { + BoundSheet bs = (BoundSheet) e.next(); bs.write(os); } eof.write(os); - for(Enumeration e = worksheets.elements();e.hasMoreElements();) { - Worksheet ws = (Worksheet) e.nextElement(); + for(Iterator e = worksheets.iterator();e.hasNext();) { + Worksheet ws = (Worksheet) e.next(); ws.write(os); } } @@ -213,8 +214,8 @@ OfficeConstants { boolean alreadyExists = false; int i = 0; - for(Enumeration e = fonts.elements();e.hasMoreElements();) { - FontDescription fd = (FontDescription) e.nextElement(); + for(Iterator e = fonts.iterator();e.hasNext();) { + FontDescription fd = (FontDescription) e.next(); if(fd.compareTo(f)) { alreadyExists = true; break; @@ -243,8 +244,8 @@ OfficeConstants { boolean alreadyExists = false; int i = 0; - for(Enumeration e = extendedFormats.elements();e.hasMoreElements();) { - ExtendedFormat currentXF = (ExtendedFormat) e.nextElement(); + for(Iterator e = extendedFormats.iterator();e.hasNext();) { + ExtendedFormat currentXF = (ExtendedFormat) e.next(); if(xf.compareTo(currentXF)) { alreadyExists = true; break; @@ -266,7 +267,7 @@ OfficeConstants { */ public Worksheet getWorksheet(int index) { - return ((Worksheet) worksheets.elementAt(index)); + return ((Worksheet) worksheets.get(index)); } /** @@ -278,7 +279,7 @@ OfficeConstants { */ public FontDescription getFontDescription(int ixfnt) { - return (FontDescription) fonts.elementAt(ixfnt); + return (FontDescription) fonts.get(ixfnt); } /** @@ -290,7 +291,7 @@ OfficeConstants { */ public ExtendedFormat getExtendedFormat(int ixfe) { - return (ExtendedFormat) extendedFormats.elementAt(ixfe); + return (ExtendedFormat) extendedFormats.get(ixfe); } /** @@ -298,9 +299,9 @@ OfficeConstants { * * @return Enumeration for the DefinedNames */ - public Enumeration getDefinedNames() { + public Iterator getDefinedNames() { - return definedNames.elements(); + return definedNames.iterator(); } /** @@ -310,10 +311,10 @@ OfficeConstants { */ public BookSettings getSettings() { - Vector settingsVector = new Vector(); + ArrayList settingsVector = new ArrayList(); int index = 0; - for(Enumeration e = worksheets.elements();e.hasMoreElements();) { - Worksheet ws = (Worksheet) e.nextElement(); + for(Iterator e = worksheets.iterator();e.hasNext();) { + Worksheet ws = (Worksheet) e.next(); SheetSettings s = ws.getSettings(); s.setSheetName(getSheetName(index++)); settingsVector.add(s); @@ -329,9 +330,9 @@ OfficeConstants { * * @return a <code>Vector</code> containing all the worksheet Names */ - public Vector getWorksheetNames() { + public ArrayList getWorksheetNames() { - Vector wsNames = new Vector(); + ArrayList wsNames = new ArrayList(); for(int i = 0;i < boundsheets.size();i++) { wsNames.add(getSheetName(i)); @@ -346,7 +347,7 @@ OfficeConstants { * @return a <code>String</code> containing the name of the worksheet */ public String getSheetName(int index) { - BoundSheet bs = (BoundSheet) boundsheets.elementAt(index); + BoundSheet bs = (BoundSheet) boundsheets.get(index); return bs.getSheetName(); } @@ -376,7 +377,7 @@ OfficeConstants { public void addCell(int row,int col, Format fmt, String cellContents) throws IOException { - Worksheet currentWS = (Worksheet) worksheets.elementAt(worksheets.size()-1); + Worksheet currentWS = (Worksheet) worksheets.get(worksheets.size()-1); int ixfe = addExtendedFormat(fmt); String category = fmt.getCategory(); @@ -428,16 +429,16 @@ OfficeConstants { * * @param columnRows <code>Vector</code> of <code>ColumnRowInfo</code> */ - public void addColInfo(Vector columnRows) throws IOException { + public void addColInfo(ArrayList columnRows) throws IOException { - Worksheet currentWS = (Worksheet) worksheets.elementAt(worksheets.size()-1); + Worksheet currentWS = (Worksheet) worksheets.get(worksheets.size()-1); int nCols = 0; int nRows = 0; Debug.log(Debug.TRACE,"Workbook: addColInfo()"); - for(Enumeration e = columnRows.elements();e.hasMoreElements();) { - ColumnRowInfo cri =(ColumnRowInfo) e.nextElement(); + for(Iterator e = columnRows.iterator();e.hasNext();) { + ColumnRowInfo cri =(ColumnRowInfo) e.next(); int ixfe = 0; int size = cri.getSize(); int repeated = cri.getRepeated(); @@ -484,17 +485,17 @@ OfficeConstants { public void addSettings(BookSettings book) throws IOException { int index = 0; - Vector sheetSettings = book.getSheetSettings(); + ArrayList sheetSettings = book.getSheetSettings(); String activeSheetName = book.getActiveSheet(); - for(Enumeration e = worksheets.elements();e.hasMoreElements();) { - Worksheet ws = (Worksheet) e.nextElement(); + for(Iterator e = worksheets.iterator();e.hasNext();) { + Worksheet ws = (Worksheet) e.next(); String name = getSheetName(index++); if(activeSheetName.equals(name)) { win1.setActiveSheet(index-1); } - for(Enumeration eSettings = sheetSettings.elements();eSettings.hasMoreElements();) { - SheetSettings s = (SheetSettings) eSettings.nextElement(); + for(Iterator eSettings = sheetSettings.iterator();eSettings.hasNext();) { + SheetSettings s = (SheetSettings) 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 fe6656e324dd..ee050f6a7b94 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 @@ -18,16 +18,17 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; -import java.io.OutputStream; -import java.io.InputStream; +import java.awt.Point; import java.io.IOException; -import java.util.Vector; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; import java.util.Enumeration; -import java.awt.Point; +import java.util.Iterator; -import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.converter.xml.sxc.SheetSettings; import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; +import org.openoffice.xmerge.util.Debug; /** * This class is used by <code>PxlDocument</code> to maintain pexcel @@ -39,9 +40,9 @@ public class Worksheet { private String name; private Workbook wb; - private Vector rows = new Vector(); - private Vector colInfo = new Vector(); - private Vector cells = new Vector(); + private ArrayList rows = new ArrayList(); + private ArrayList colInfo = new ArrayList(); + private ArrayList cells = new ArrayList(); private DefColWidth dcw = new DefColWidth(); private DefRowHeight drh = new DefRowHeight(); private Window2 win2 = new Window2(); @@ -75,17 +76,17 @@ public class Worksheet { bof = new BeginningOfFile(false); bof.write(os); dcw.write(os); - for(Enumeration e = colInfo.elements();e.hasMoreElements();) { - ColInfo ci = (ColInfo) e.nextElement(); + for(Iterator e = colInfo.iterator();e.hasNext();) { + ColInfo ci = (ColInfo) e.next(); ci.write(os); } drh.write(os); - for(Enumeration e = rows.elements();e.hasMoreElements();) { - Row rw = (Row) e.nextElement(); + for(Iterator e = rows.iterator();e.hasNext();) { + Row rw = (Row) e.next(); rw.write(os); } - for(Enumeration e = cells.elements();e.hasMoreElements();) { - BIFFRecord cv = (BIFFRecord) e.nextElement(); + for(Iterator e = cells.iterator();e.hasNext();) { + BIFFRecord cv = (BIFFRecord) e.next(); cv.write(os); } win2.write(os); @@ -214,8 +215,8 @@ public class Worksheet { * * @return an enumerator to the worksheet cells */ - public Enumeration getCellEnumerator() throws IOException { - return (cells.elements()); + public Iterator getCellEnumerator() throws IOException { + return (cells.iterator()); } /** @@ -270,9 +271,9 @@ public class Worksheet { * * @return an <code>Enumeration</code> to the ColInfo's */ - public Enumeration getColInfos() { + public Iterator getColInfos() { - return (colInfo.elements()); + return (colInfo.iterator()); } /** @@ -300,9 +301,9 @@ public class Worksheet { * * @return an <code>Enumeration</code> to the Rows */ - public Enumeration getRows() { + public Iterator getRows() { - return (rows.elements()); + 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 1e42f519c697..a08bebd57270 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 @@ -18,7 +18,10 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; -import java.util.*; +import java.util.ArrayList; +import java.util.ListIterator; +import java.util.Stack; + import org.openoffice.xmerge.util.Debug; /** @@ -88,8 +91,8 @@ public class FormulaCompiler { * @param tokens The tokens in RPN form * @return The vector of tokens re-ordered in Infix notation */ - public Vector RPN2Infix(Vector tokens) { - Vector infixExpr = new Vector(15); + public ArrayList RPN2Infix(ArrayList tokens) { + ArrayList infixExpr = new ArrayList(15); ListIterator iter = tokens.listIterator(); Stack evalStack = new Stack(); Stack args = new Stack(); @@ -97,7 +100,7 @@ public class FormulaCompiler { while (iter.hasNext()) { Token pt = (Token)iter.next(); if (pt.isOperand()) { - Vector expr = new Vector(5); + ArrayList expr = new ArrayList(5); expr.add(pt); evalStack.push(expr); } else if (pt.isOperator() || pt.isFunction()) { @@ -108,7 +111,7 @@ public class FormulaCompiler { evalStack.push(makeExpression(pt, args)); } } - return (Vector)evalStack.elementAt(0); + return (ArrayList)evalStack.elementAt(0); } /** @@ -120,8 +123,8 @@ public class FormulaCompiler { * * @return A vector of tokens for the expression in Reverse Polish Notation order */ - public Vector infix2RPN(Vector tokens) { - Vector rpnExpr = new Vector(15); + public ArrayList infix2RPN(ArrayList tokens) { + ArrayList rpnExpr = new ArrayList(15); Stack evalStack = new Stack(); ListIterator iter = tokens.listIterator(); while (iter.hasNext()) { @@ -134,7 +137,7 @@ public class FormulaCompiler { if (pt.isFunction()) { iter.next(); } - Vector param = extractParameter(iter); + ArrayList 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 @@ -186,8 +189,8 @@ public class FormulaCompiler { * @param iter an iterator into the list * @return A complete sub-expression */ - protected Vector extractParameter(ListIterator iter) { - Vector param = new Vector(5); + protected ArrayList extractParameter(ListIterator iter) { + ArrayList param = new ArrayList(5); int subExprCount = 0; while (iter.hasNext()) { @@ -220,21 +223,21 @@ public class FormulaCompiler { * @param args The arguments for this operator * @return A correctly ordered expression */ - protected Vector makeExpression(Token pt, Stack args) { - Vector tmp = new Vector(5); + protected ArrayList<Object> makeExpression(Token pt, Stack<ArrayList> args) { + ArrayList<Object> tmp = new ArrayList<Object>(5); TokenFactory tf = new TokenFactory(); if (pt.isOperator()) { if (pt.getNumArgs()==2) { //Binary operator - tmp.addAll((Vector)args.pop()); + tmp.addAll((ArrayList)args.pop()); tmp.add(pt); - tmp.addAll((Vector)args.pop()); + tmp.addAll((ArrayList)args.pop()); } else if (pt.getNumArgs() == 1) { if(isPercent(pt)) { - tmp.addAll((Vector)args.elementAt(0)); + tmp.addAll((ArrayList)args.elementAt(0)); tmp.add(pt); } else { tmp.add(pt); - tmp.addAll((Vector)args.elementAt(0)); + tmp.addAll((ArrayList)args.elementAt(0)); } if (isOpenBrace(pt)) { tmp.add(tf.getOperatorToken(")",1)); @@ -244,12 +247,12 @@ public class FormulaCompiler { tmp.add(pt); tmp.add(tf.getOperatorToken("(",1)); if (!args.isEmpty()) { - Vector v = (Vector)args.pop(); + ArrayList v = (ArrayList)args.pop(); tmp.addAll(v); } while (!args.isEmpty()) { tmp.add(tf.getOperatorToken(",",1)); - Vector v = (Vector)args.pop(); + ArrayList v = (ArrayList)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 58b0bdecd3ed..defda65e9881 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 @@ -20,8 +20,9 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; import java.util.Enumeration; +import java.util.Iterator; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; @@ -69,14 +70,14 @@ public class FormulaHelper { */ public byte[] convertCalcToPXL(String formula) throws UnsupportedFunctionException, FormulaParsingException { - Vector parseTokens = parser.parse(formula); - Vector rpnTokens = compiler.infix2RPN(parseTokens); + ArrayList parseTokens = parser.parse(formula); + ArrayList rpnTokens = compiler.infix2RPN(parseTokens); ByteArrayOutputStream bytes = null; try { bytes = new ByteArrayOutputStream(); - for (Enumeration e = rpnTokens.elements(); e.hasMoreElements();) { - Token t = (Token)e.nextElement(); + for (Iterator e = rpnTokens.iterator(); e.hasNext();) { + Token t = (Token)e.next(); bytes.write(encoder.getByte(t)); } } catch (IOException e) { @@ -92,12 +93,12 @@ public class FormulaHelper { */ public String convertPXLToCalc(byte[] formula) { - Vector parseTokens = decoder.getTokenVector(formula); - Vector infixTokens = compiler.RPN2Infix(parseTokens); + ArrayList parseTokens = decoder.getTokenVector(formula); + ArrayList infixTokens = compiler.RPN2Infix(parseTokens); StringBuffer buff = new StringBuffer(); - for (Enumeration e = infixTokens.elements();e.hasMoreElements();) { - Token t = (Token)e.nextElement(); + for (Iterator e = infixTokens.iterator();e.hasNext();) { + Token t = (Token)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 5e403df81627..76e01c407dda 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 @@ -19,7 +19,7 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; -import java.util.Vector; +import java.util.ArrayList; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; import org.openoffice.xmerge.util.Debug; @@ -41,7 +41,7 @@ public class FormulaParser { private String formulaStr; private int index = 1; private TokenFactory tokenFactory; - private Vector tokenVector; + private ArrayList tokenVector; private Workbook wb; /** @@ -51,7 +51,7 @@ public class FormulaParser { Debug.log(Debug.TRACE,"Creating a Formula Parser"); tokenFactory = new TokenFactory(); - tokenVector = new Vector(); + tokenVector = new ArrayList(); } /** @@ -69,7 +69,7 @@ public class FormulaParser { * starting with the '=' character * @return A <code>Vector</code> containing the parsed <code>Token</code>s */ - public Vector parse(String formula) throws FormulaParsingException { + public ArrayList parse(String formula) throws FormulaParsingException { index = 1; look = ' '; @@ -368,7 +368,7 @@ public class FormulaParser { int numArgs = arguments(); match(')'); tokenVector.add(tokenFactory.getOperatorToken(")", 1)); - tokenVector.insertElementAt(tokenFactory.getFunctionToken(cell, numArgs), index); + tokenVector.add(index, tokenFactory.getFunctionToken(cell, numArgs)); } else { if(cell.indexOf('.')!=-1) { 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 7e5db6c93bdc..019197748809 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 @@ -18,14 +18,15 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; -import java.io.*; -import java.util.Vector; -import java.util.Enumeration; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.DefinedName; import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; +import org.openoffice.xmerge.util.Debug; +import org.openoffice.xmerge.util.EndianConverter; /** * The TokenDecoder decodes a byte[] to an equivalent <code>String</code>. The only @@ -79,9 +80,9 @@ public class TokenDecoder { * @param formula A Pocket Excel Formula byte[] * @return A <code>Vector</code> of deoded <code>Token</code> */ - public Vector getTokenVector(byte[] formula) { + public ArrayList getTokenVector(byte[] formula) { - Vector v = new Vector(); + ArrayList v = new ArrayList(); ByteArrayInputStream bis = new ByteArrayInputStream(formula); int b = 0 ; @@ -96,46 +97,46 @@ public class TokenDecoder { case TokenConstants.TAREA3D: Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: "); v.add(read3DCellAreaRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: " + last(v)); break; case TokenConstants.TREF3D: Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: "); v.add(read3DCellRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: " + last(v)); break; case TokenConstants.TREF : v.add(readCellRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded Cell Reference: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded Cell Reference: " + last(v)); break; case TokenConstants.TAREA : v.add(readCellAreaRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded Cell Area Reference: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded Cell Area Reference: " + last(v)); break; case TokenConstants.TNUM : v.add(readNumToken(bis)); - Debug.log(Debug.TRACE, "Decoded number : " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded number : " + last(v)); break; case TokenConstants.TFUNCVAR : v.add(readFunctionVarToken(bis)); - Debug.log(Debug.TRACE, "Decoded variable argument function: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded variable argument function: " + last(v)); break; case TokenConstants.TFUNC : v.add(readFunctionToken(bis)); - Debug.log(Debug.TRACE, "Decoded function: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded function: " + last(v)); break; case TokenConstants.TSTRING : v.add(readStringToken(bis)); - Debug.log(Debug.TRACE, "Decoded string: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded string: " + last(v)); break; case TokenConstants.TNAME : v.add(readNameToken(bis)); - Debug.log(Debug.TRACE, "Decoded defined name: " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded defined name: " + last(v)); break; case TokenConstants.TUPLUS: case TokenConstants.TUMINUS: case TokenConstants.TPERCENT: v.add(readOperatorToken(b, 1)); - Debug.log(Debug.TRACE, "Decoded Unary operator : " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded Unary operator : " + last(v)); break; case TokenConstants.TADD : case TokenConstants.TSUB : @@ -148,7 +149,7 @@ public class TokenDecoder { case TokenConstants.TGREATER : case TokenConstants.TNEQUALS : v.add(readOperatorToken(b, 2)); - Debug.log(Debug.TRACE, "Decoded Binary operator : " + v.lastElement()); + Debug.log(Debug.TRACE, "Decoded Binary operator : " + last(v)); break; default : @@ -158,6 +159,11 @@ public class TokenDecoder { return v; } + private static Object last(ArrayList list) + { + return list.get(list.size() - 1); + } + /** * Converts a zero based integer to a char (eg. a=0, b=1). * It assumes the integer is less than 26. @@ -213,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 - Enumeration e = wb.getDefinedNames(); + Iterator e = wb.getDefinedNames(); int i = 1; while(i<nameIndex) { - e.nextElement(); + e.next(); i++; } Debug.log(Debug.TRACE,"Name index is " + nameIndex); - DefinedName dn = (DefinedName)e.nextElement(); + DefinedName dn = (DefinedName)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 dc4925323e4d..a705d23c322c 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 @@ -18,14 +18,14 @@ package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; -import java.io.*; -import java.util.Vector; -import java.util.Enumeration; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.DefinedName; +import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.DefinedName; /** * The TokenEncoder encodes a Token to an equivalent pexcel byte[]. The only @@ -75,7 +75,7 @@ public class TokenEncoder { */ public byte[] getByte(Token t) throws IOException { - Vector tmpByteArray = null; // we use this cause we don't know till after + ArrayList 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(Enumeration e = tmpByteArray.elements();e.hasMoreElements();) { - Byte tmpByte = (Byte) e.nextElement(); + for(Iterator e = tmpByteArray.iterator();e.hasNext();) { + Byte tmpByte = (Byte) 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 Vector operatorEncoder(Token t) { + private ArrayList operatorEncoder(Token t) { - Vector tmpByteArray = new Vector(); + ArrayList tmpByteArray = new ArrayList(); 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 Vector stringEncoder(Token t) throws IOException{ + private ArrayList stringEncoder(Token t) throws IOException{ - Vector tmpByteArray = new Vector(); + ArrayList tmpByteArray = new ArrayList(); tmpByteArray.add(new Byte((byte)t.getTokenID())); tmpByteArray.add(new Byte((byte)(t.getValue().length()))); tmpByteArray.add(new Byte((byte)0x01)); @@ -164,9 +164,9 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private Vector numEncoder(Token t) { + private ArrayList numEncoder(Token t) { - Vector tmpByteArray = new Vector(); + ArrayList tmpByteArray = new ArrayList(); double cellLong = (double) Double.parseDouble(t.getValue()); tmpByteArray.add(new Byte((byte)t.getTokenID())); @@ -313,23 +313,23 @@ public class TokenEncoder { * @param t <code>Token</code> to be encoded * @return A <code>Vector</code> of pexcel <code>Byte</code> */ - private Vector nameDefinitionEncoder(Token t) { + private ArrayList nameDefinitionEncoder(Token t) { - Vector tmpByteArray = new Vector(); + ArrayList tmpByteArray = new ArrayList(); String nameString = t.getValue(); Debug.log(Debug.TRACE,"NameDefinitionEncoder : " + nameString); tmpByteArray.add(new Byte((byte)t.getTokenID())); - Enumeration e = wb.getDefinedNames(); + Iterator e = wb.getDefinedNames(); DefinedName dn; String name; int definedNameIndex = 0; do { - dn = (DefinedName)e.nextElement(); + dn = (DefinedName)e.next(); name = dn.getName(); Debug.log(Debug.TRACE,"Name pulled from DefinedName : " + name); definedNameIndex++; - } while(!nameString.equalsIgnoreCase(name) && e.hasMoreElements()); + } while(!nameString.equalsIgnoreCase(name) && e.hasNext()); tmpByteArray.add(new Byte((byte)definedNameIndex)); tmpByteArray.add(new Byte((byte)0x00)); @@ -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 Vector cellRefEncoder(Token t) { + private ArrayList cellRefEncoder(Token t) { - Vector tmpByteArray = new Vector(); + ArrayList tmpByteArray = new ArrayList(); tmpByteArray.add(new Byte((byte)t.getTokenID())); byte cellRefBytes[] = encodeCellCoordinates(t.getValue()); @@ -376,12 +376,12 @@ public class TokenEncoder { sheetName = s.substring(0,s.length()); } Debug.log(Debug.TRACE,"Searching for Worksheet : " + sheetName); - Vector names = wb.getWorksheetNames(); - Enumeration e = names.elements(); + ArrayList names = wb.getWorksheetNames(); + Iterator e = names.iterator(); do { - savedName = (String) e.nextElement(); + savedName = (String) e.next(); sheetIndex++; - } while(!savedName.equalsIgnoreCase(sheetName) && e.hasMoreElements()); + } while(!savedName.equalsIgnoreCase(sheetName) && e.hasNext()); Debug.log(Debug.TRACE,"Setting sheetindex to " + sheetIndex); return (short)(sheetIndex-1); @@ -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 Vector threeDCellRefEncoder(Token t) { + private ArrayList threeDCellRefEncoder(Token t) { - Vector tmpByteArray = new Vector(); + ArrayList tmpByteArray = new ArrayList(); 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 Vector threeDAreaRefEncoder(Token t) { + private ArrayList threeDAreaRefEncoder(Token t) { - Vector tmpByteArray = new Vector(); + ArrayList tmpByteArray = new ArrayList(); 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 Vector areaRefEncoder(Token t) { + private ArrayList areaRefEncoder(Token t) { - Vector tmpByteArray = new Vector(); + ArrayList tmpByteArray = new ArrayList(); 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 Vector functionEncoder(Token t) { - Vector tmpByteArray = new Vector(); + private ArrayList functionEncoder(Token t) { + ArrayList tmpByteArray = new ArrayList(); 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 eec12f0ca49e..a306b53930b0 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 @@ -18,13 +18,12 @@ package org.openoffice.xmerge.converter.xml.sxw.pocketword; -import org.openoffice.xmerge.util.EndianConverter; - import java.io.ByteArrayOutputStream; -import java.io.OutputStream; import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; -import java.util.Vector; +import org.openoffice.xmerge.util.EndianConverter; /** @@ -47,10 +46,10 @@ class DocumentDescriptor { private short length = 0; private short numLines = 0; - private Vector paragraphDesc = null; + private ArrayList paragraphDesc = null; DocumentDescriptor() { - paragraphDesc = new Vector(0, 1); + paragraphDesc = new ArrayList(0); } @@ -107,7 +106,7 @@ class DocumentDescriptor { 0x00, 0x00, 0x00, 0x00 } ); for (int i = 0; i < paragraphDesc.size(); i++) { - ParagraphDescriptor pd = (ParagraphDescriptor)paragraphDesc.elementAt(i); + ParagraphDescriptor pd = (ParagraphDescriptor)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 341d2e5ccc9d..b067ea0ed4f2 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 @@ -18,28 +18,24 @@ package org.openoffice.xmerge.converter.xml.sxw.pocketword; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Iterator; + import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConvertException; import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentDeserializer; - import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; - import org.openoffice.xmerge.converter.xml.ParaStyle; -import org.openoffice.xmerge.converter.xml.TextStyle; import org.openoffice.xmerge.converter.xml.StyleCatalog; - +import org.openoffice.xmerge.converter.xml.TextStyle; +import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; import org.openoffice.xmerge.util.OfficeUtil; - -import java.io.IOException; - -import java.util.Enumeration; -import java.util.Vector; - -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** @@ -76,11 +72,11 @@ public final class DocumentDeserializerImpl * for conversion. */ public DocumentDeserializerImpl(ConvertData cd) { - Enumeration e = cd.getDocumentEnumeration(); + Iterator e = cd.getDocumentEnumeration(); // A Pocket Word file is composed of one binary file - while (e.hasMoreElements()) { - pswDoc = (PocketWordDocument)e.nextElement(); + while (e.hasNext()) { + pswDoc = (PocketWordDocument)e.next(); } docName = pswDoc.getName(); @@ -102,7 +98,7 @@ public final class DocumentDeserializerImpl * @throws IOException If any I/O error occurs. */ public Document deserialize() throws IOException, ConvertException { - Enumeration pe = pswDoc.getParagraphEnumeration(); + Iterator pe = pswDoc.getParagraphEnumeration(); sxwDoc = new SxwDocument (docName); sxwDoc.initContentDOM(); @@ -133,7 +129,7 @@ public final class DocumentDeserializerImpl * * @throws IOException If any I/O errors occur. */ - private void buildDocument(Enumeration data) throws IOException { + private void buildDocument(Iterator data) throws IOException { org.w3c.dom.Document doc = sxwDoc.getContentDOM(); @@ -161,8 +157,8 @@ public final class DocumentDeserializerImpl // Down to business ... - while (data.hasMoreElements()) { - Paragraph p = (Paragraph)data.nextElement(); + while (data.hasNext()) { + Paragraph p = (Paragraph)data.next(); Element paraNode = doc.createElement(TAG_PARAGRAPH); // Set paragraph style information here @@ -183,11 +179,11 @@ public final class DocumentDeserializerImpl * For each of the paragraphs, process each segment. * There will always be at least one. */ - Enumeration paraData = p.getSegmentsEnumerator(); - Vector textSpans = new Vector(0, 1); + Iterator paraData = p.getSegmentsEnumerator(); + ArrayList textSpans = new ArrayList(0); do { - ParagraphTextSegment pts = (ParagraphTextSegment)paraData.nextElement(); + ParagraphTextSegment pts = (ParagraphTextSegment)paraData.next(); Element span = doc.createElement(OfficeConstants.TAG_SPAN); TextStyle ts = pts.getStyle(); @@ -213,7 +209,7 @@ public final class DocumentDeserializerImpl textSpans.add(span); - } while (paraData.hasMoreElements()); + } while (paraData.hasNext()); /* @@ -221,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.elementAt(0); + Element firstSpan = (Element)textSpans.get(0); String styleName = firstSpan.getAttribute(ATTRIBUTE_TEXT_STYLE_NAME); if (styleName.equals(PocketWordConstants.DEFAULT_STYLE)) { NodeList nl = firstSpan.getChildNodes(); @@ -244,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.elementAt(i)); + paraNode.appendChild((Node)textSpans.get(i)); } 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 cd7c1586896d..dc56c635c275 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 @@ -18,18 +18,16 @@ package org.openoffice.xmerge.converter.xml.sxw.pocketword; +import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; -import java.util.Vector; -import java.util.Enumeration; - -import java.awt.Color; - -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.util.ColourConverter; import org.openoffice.xmerge.converter.xml.ParaStyle; import org.openoffice.xmerge.converter.xml.TextStyle; +import org.openoffice.xmerge.util.ColourConverter; +import org.openoffice.xmerge.util.EndianConverter; /** @@ -73,9 +71,9 @@ class Paragraph implements PocketWordConstants { * representation. */ - private Vector textSegments = null; + private ArrayList textSegments = null; - private Vector lineDescriptors = null; + private ArrayList lineDescriptors = null; private ParaStyle pStyle = null; @@ -87,7 +85,7 @@ class Paragraph implements PocketWordConstants { * initialisation of the Vector storing the paragraph's text. */ private Paragraph () { - textSegments = new Vector(0, 1); + textSegments = new ArrayList(); } @@ -101,7 +99,7 @@ class Paragraph implements PocketWordConstants { public Paragraph (ParaStyle style) { this(); - lineDescriptors = new Vector(0, 1); + lineDescriptors = new ArrayList(); pStyle = style; } @@ -473,7 +471,7 @@ class Paragraph implements PocketWordConstants { try { for (int i = 0; i < textSegments.size(); i++) { - ParagraphTextSegment pts = (ParagraphTextSegment)textSegments.elementAt(i); + ParagraphTextSegment pts = (ParagraphTextSegment)textSegments.get(i); segs.write(pts.getData()); } } @@ -605,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.elementAt(i); + LineDescriptor ld = (LineDescriptor)lineDescriptors.get(i); bos.write(ld.getDescriptorInfo()); } @@ -653,11 +651,11 @@ class Paragraph implements PocketWordConstants { StringBuffer sb = new StringBuffer(""); // Line Descriptor info should be eliminated each time - lineDescriptors = new Vector(1, 1); + lineDescriptors = new ArrayList(); lines = 0; for (int i = 0; i < textSegments.size(); i++) { - ParagraphTextSegment pts = (ParagraphTextSegment)textSegments.elementAt(i); + ParagraphTextSegment pts = (ParagraphTextSegment)textSegments.get(i); sb.append(pts.getText()); } @@ -765,8 +763,8 @@ class Paragraph implements PocketWordConstants { * * @return An <code>Enumeration</code> of the text segments. */ - public Enumeration getSegmentsEnumerator () { - return textSegments.elements(); + public Iterator 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 0f20f0043502..c59c6715ad68 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 @@ -18,18 +18,17 @@ package org.openoffice.xmerge.converter.xml.sxw.pocketword; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.converter.xml.ParaStyle; -import org.openoffice.xmerge.converter.xml.TextStyle; - -import java.io.InputStream; -import java.io.IOException; -import java.io.OutputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Iterator; -import java.util.Enumeration; -import java.util.Vector; +import org.openoffice.xmerge.Document; +import org.openoffice.xmerge.converter.xml.ParaStyle; +import org.openoffice.xmerge.converter.xml.TextStyle; /** @@ -46,9 +45,9 @@ public class PocketWordDocument implements Document, PocketWordConstants { private String docName; private byte[] preamble; - private Vector fonts; + private ArrayList fonts; private DocumentDescriptor descriptor; - private Vector paragraphs; + private ArrayList paragraphs; private ParaStyle pStyle; private Paragraph currentPara; @@ -86,9 +85,9 @@ public class PocketWordDocument implements Document, PocketWordConstants { docName = trimDocumentName(name); preamble = new byte[52]; - fonts = new Vector(0, 1); + fonts = new ArrayList(); descriptor = new DocumentDescriptor(); - paragraphs = new Vector(0, 1); + paragraphs = new ArrayList(); } @@ -206,8 +205,8 @@ public class PocketWordDocument implements Document, PocketWordConstants { * * @return <code>Enumeration</code> over the paragraphs in the document. */ - public Enumeration getParagraphEnumeration() { - return paragraphs.elements(); + public Iterator getParagraphEnumeration() { + return paragraphs.iterator(); } @@ -253,19 +252,19 @@ public class PocketWordDocument implements Document, PocketWordConstants { loadFonts(); for (int i = 0; i < fonts.size(); i++ ) { - ByteArrayOutputStream fontData = (ByteArrayOutputStream)fonts.elementAt(i); + ByteArrayOutputStream fontData = (ByteArrayOutputStream)fonts.get(i); dos.write(fontData.toByteArray()); } for (int i = 0; i < paragraphs.size(); i++) { - Paragraph para = (Paragraph)paragraphs.elementAt(i); + Paragraph para = (Paragraph)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.elementAt(i); + Paragraph para = (Paragraph)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 f05cefc08bc9..83071b21254f 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 @@ -18,28 +18,30 @@ package org.openoffice.xmerge.converter.xml.sxw.wordsmith; -import org.w3c.dom.*; - +import java.io.ByteArrayInputStream; import java.io.IOException; -import java.util.Enumeration; +import java.util.ArrayList; +import java.util.Iterator; -import org.openoffice.xmerge.Document; import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConvertException; +import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.converter.xml.OfficeConstants; import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.converter.palm.PdbDecoder; import org.openoffice.xmerge.converter.palm.PalmDocument; +import org.openoffice.xmerge.converter.palm.Record; +import org.openoffice.xmerge.converter.xml.OfficeConstants; +import org.openoffice.xmerge.converter.xml.ParaStyle; +import org.openoffice.xmerge.converter.xml.Style; +import org.openoffice.xmerge.converter.xml.StyleCatalog; +import org.openoffice.xmerge.converter.xml.TextStyle; import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; - -import java.util.Vector; -import java.io.ByteArrayInputStream; - -import org.openoffice.xmerge.converter.xml.*; import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.XmlUtil; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; /** * <p>WordSmith implementation of @@ -102,10 +104,10 @@ implements DOCConstants, OfficeConstants, DocumentDeserializer { Document doc = null; PalmDocument palmDoc = null; - Enumeration e = cd.getDocumentEnumeration(); + Iterator e = cd.getDocumentEnumeration(); - while(e.hasMoreElements()) { - palmDoc = (PalmDocument) e.nextElement(); + while(e.hasNext()) { + palmDoc = (PalmDocument) e.next(); PalmDB pdb = palmDoc.getPdb(); Record[] recs = pdb.getRecords(); decoder = new WSDecoder(); @@ -201,7 +203,7 @@ implements DOCConstants, OfficeConstants, DocumentDeserializer { * @return Array of <code>Node</code> objects. */ private Node[] parseText(String text, org.w3c.dom.Document parentDoc) { - Vector nodeVec = new Vector(); + ArrayList nodeVec = new ArrayList(); // Break up the text from the WordSmith text run into Open // Office text runs. There may be more runs in OO because @@ -229,7 +231,7 @@ implements DOCConstants, OfficeConstants, DocumentDeserializer { if (closerIndex > 0) { String beginningText = text.substring(0, closerIndex); Text textNode = parentDoc.createTextNode(beginningText); - nodeVec.addElement(textNode); + nodeVec.add(textNode); log("<TEXT>"); log(beginningText); log("</TEXT>"); @@ -272,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.elementAt(i); + nodes[i] = (Node)nodeVec.get(i); return nodes; } 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 9a1e19a4867e..4ed64f04e4ac 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.Vector v = new java.util.Vector(20, 20); + java.util.ArrayList v = new java.util.ArrayList(20); WseFontTable fontTable = null; WseColorTable colorTable = null; 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 879f360212ad..2d9c13a3c198 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 @@ -20,13 +20,10 @@ package org.openoffice.xmerge.converter.xml.sxw.wordsmith; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.*; -import java.io.UnsupportedEncodingException; -import java.util.List; +import java.io.IOException; import java.util.ArrayList; -import java.util.Vector; -import org.openoffice.xmerge.converter.palm.*; +import org.openoffice.xmerge.converter.palm.Record; /** * This class is used by {@link @@ -61,7 +58,7 @@ final class WSEncoder { WseHeader header = null; WseFontTable ft = null; WseColorTable ct = null; - private Vector elements; // paragraphs & text runs + private ArrayList elements; // paragraphs & text runs /* Totals for the WordSmith document. */ int nrParagraphs = 0; @@ -78,7 +75,7 @@ final class WSEncoder { version = 1; textLen = 0; maxRecSize = 4096; - elements = new Vector(); + elements = new ArrayList(); } @@ -95,7 +92,7 @@ final class WSEncoder { else if (elem.getClass() == WseColorTable.class) ct = (WseColorTable)elem; else - elements.addElement(elem); + elements.add(elem); } @@ -109,13 +106,13 @@ final class WSEncoder { */ Record[] getRecords() throws IOException { - Vector allRecs = new Vector(); + ArrayList allRecs = new ArrayList(); int nElements = elements.size(); // Count up the number of paragraphs, atoms, and characters. int currElement = 0; while (currElement < nElements) { - Wse e = (Wse)elements.elementAt(currElement++); + Wse e = (Wse)elements.get(currElement++); if (e.getClass() == WsePara.class) nrParagraphs++; if (e.getClass() == WseTextRun.class) { @@ -147,7 +144,7 @@ final class WSEncoder { currElement = 0; while (currElement < nElements) { - Wse e = (Wse)elements.elementAt(currElement++); + Wse e = (Wse)elements.get(currElement++); int length = e.getByteCount(); if ((length + currRecLen) <= 4096) { System.arraycopy(e.getBytes(), 0, currRec, currRecLen, length); @@ -159,7 +156,7 @@ final class WSEncoder { System.arraycopy(e.getBytes(), 0, currRec, currRecLen, firstPartLen); Record r = new Record(currRec); - allRecs.addElement(r); + allRecs.add(r); // Put the remainder at the beginning of the next record currRecLen = 0; @@ -174,7 +171,7 @@ final class WSEncoder { byte[] partial = new byte[currRecLen]; System.arraycopy(currRec, 0, partial, 0, currRecLen); Record rr = new Record(partial); - allRecs.addElement(rr); + allRecs.add(rr); } @@ -189,13 +186,13 @@ final class WSEncoder { dos.writeShort(allRecs.size()); dos.writeShort(maxRecSize); dos.writeInt(0); - allRecs.insertElementAt(new Record(bos.toByteArray()), 0); + allRecs.add(0, new Record(bos.toByteArray())); // Convert Vector of Records to an array and return it. int nRecs = allRecs.size(); Record recs[] = new Record[nRecs]; for (int i = 0; i < nRecs; i++) - recs[i] = (Record)allRecs.elementAt(i); + recs[i] = (Record)allRecs.get(i); return recs; } 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 8378c2094ba1..88afab707cd4 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.Vector fontNames = new java.util.Vector(10); + java.util.ArrayList fontNames = new java.util.ArrayList(10); /** @@ -94,7 +94,7 @@ class WseFontTable extends Wse { */ public String getFontName(int index) { try { - return (String)fontNames.elementAt(index); + return (String)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.elementAt(i); + String name = (String) 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.elementAt(i); + String name = (String)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.elementAt(i); + String name = (String)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/textRecord.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java index 0750da455cca..f71e5faddd7c 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.Vector elements; + java.util.ArrayList elements; /** * Default constructor */ textRecord() { - elements = new java.util.Vector(10); + elements = new java.util.ArrayList(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.elementAt(i); + Wse e = (Wse)elements.get(i); totalBytes += e.getByteCount(); } return totalBytes; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java index 0f2e98546c0d..1629f768b9dc 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/Convert.java @@ -18,9 +18,9 @@ package org.openoffice.xmerge; -import java.io.InputStream; import java.io.IOException; -import java.util.Enumeration; +import java.io.InputStream; +import java.util.Iterator; import org.openoffice.xmerge.util.registry.ConverterInfo; @@ -212,9 +212,9 @@ public class Convert implements Cloneable { DocumentSerializerFactory myDocSerializerFactory = ci.getDocSerializerFactory(); - Enumeration e = inputCD.getDocumentEnumeration(); + Iterator e = inputCD.getDocumentEnumeration(); - Document doc = (Document) e.nextElement(); + Document doc = (Document) e.next(); DocumentSerializer ser = myDocSerializerFactory.createDocumentSerializer(doc); dataOut = ser.serialize(); @@ -266,9 +266,9 @@ public class Convert implements Cloneable { DocumentSerializerFactory myDocSerializerFactory = ci.getDocSerializerFactory(); - Enumeration e = inputCD.getDocumentEnumeration(); + Iterator e = inputCD.getDocumentEnumeration(); - Document doc = (Document) e.nextElement(); + Document doc = (Document) e.next(); DocumentSerializer ser = myDocSerializerFactory.createDocumentSerializer(doc); dataOut = ser instanceof DocumentSerializer2 ? ((DocumentSerializer2) ser).serialize(sFromURL,sToURL) : diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java index 305de052cf1a..035453459d3d 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/ConvertData.java @@ -18,8 +18,8 @@ package org.openoffice.xmerge; -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; +import java.util.Iterator; /** * <p><code>ConvertData</code> is used as a container for passing @@ -34,7 +34,7 @@ public class ConvertData { /** * Vector of <code>Document</code> objects. */ - private Vector v = new Vector(); + private ArrayList v = new ArrayList(); /** * Name of the <code>ConvertData</code> object. @@ -49,7 +49,7 @@ public class ConvertData { */ public void reset() { name = null; - v.removeAllElements(); + v.clear(); } /** @@ -89,8 +89,8 @@ public class ConvertData { * @return The <code>Enumeration</code> to access the * <code>Vector</code> of <code>Document</code> objects. */ - public Enumeration getDocumentEnumeration() { - Enumeration enumerate = v.elements(); + public Iterator getDocumentEnumeration() { + Iterator enumerate = v.iterator(); return (enumerate); } 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 dda143bfd667..2832a44ec37b 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 @@ -18,13 +18,14 @@ package org.openoffice.xmerge.converter.xml; -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Element; -import org.openoffice.xmerge.util.*; -import java.util.Vector; import java.lang.reflect.Constructor; +import java.util.ArrayList; + +import org.openoffice.xmerge.util.Debug; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** @@ -41,7 +42,7 @@ import java.lang.reflect.Constructor; */ public class StyleCatalog { - private Vector styles; // The actual styles + private ArrayList styles; // The actual styles /** * Constructor @@ -50,7 +51,7 @@ public class StyleCatalog { * for efficiency purposes. */ public StyleCatalog(int initialEntries) { - styles = new Vector(initialEntries); + styles = new ArrayList(initialEntries); } @@ -159,7 +160,7 @@ public class StyleCatalog { * @param s The <code>Style</code> to add. */ public void add(Style s) { - styles.addElement(s); + styles.add(s); } @@ -182,7 +183,7 @@ public class StyleCatalog { Class styleClass) { int nStyles = styles.size(); for (int i = 0; i < nStyles; i++) { - Style s = (Style)styles.elementAt(i); + Style s = (Style)styles.get(i); if ((name != null) && (s.getName() != null) && (!s.getName().equals(name))) continue; @@ -217,7 +218,7 @@ public class StyleCatalog { int matchCount = 0; int nStyles = styles.size(); for (int j = 0; j < nStyles; j++) { - Style p = ((Style)styles.elementAt(j)).getResolved(); + Style p = ((Style)styles.get(j)).getResolved(); if (p.isSubset(s)) matchCount++; } @@ -225,7 +226,7 @@ public class StyleCatalog { Style[] matchArray = new Style[matchCount]; matchCount = 0; for (int j = 0; j < nStyles; j++) { - Style p = ((Style)styles.elementAt(j)).getResolved(); + Style p = ((Style)styles.get(j)).getResolved(); if (p.isSubset(s)) matchArray[matchCount++] = p; } return matchArray; 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 8398af67a37d..b8f9341d33c7 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 @@ -18,16 +18,16 @@ package org.openoffice.xmerge.converter.xml.sxc; -import java.util.Vector; -import java.util.Enumeration; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; -import org.w3c.dom.Element; +import java.util.ArrayList; +import java.util.Iterator; import org.openoffice.xmerge.converter.xml.OfficeConstants; import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.XmlUtil; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * This is a class representing the different attributes for a worksheet @@ -42,7 +42,7 @@ public class BookSettings implements OfficeConstants { private boolean hasColumnRowHeaders = true; private String activeSheet = new String(); - private Vector worksheetSettings = new Vector(); + private ArrayList worksheetSettings = new ArrayList(); /** * 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(Vector worksheetSettings) { + public BookSettings(ArrayList worksheetSettings) { this.worksheetSettings = worksheetSettings; } @@ -86,7 +86,7 @@ public class BookSettings implements OfficeConstants { * * @return <code>Vector</code> of <code>SheetSettings</code> */ - public Vector getSheetSettings() { + public ArrayList getSheetSettings() { return worksheetSettings; } @@ -140,8 +140,8 @@ public class BookSettings implements OfficeConstants { this.settings = settings; Element configItemMapNamed = (Element) settings.createElement(TAG_CONFIG_ITEM_MAP_NAMED); configItemMapNamed.setAttribute(ATTRIBUTE_CONFIG_NAME, "Tables"); - for(Enumeration e = worksheetSettings.elements();e.hasMoreElements();) { - SheetSettings s = (SheetSettings) e.nextElement(); + for(Iterator e = worksheetSettings.iterator();e.hasNext();) { + SheetSettings s = (SheetSettings) e.next(); s.writeNode(settings, configItemMapNamed); } addConfigItem(root, "ActiveTable", "string", activeSheet); 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 e0d037a2ca9f..fdb35ba1cc74 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 @@ -19,9 +19,8 @@ package org.openoffice.xmerge.converter.xml.sxc; import java.io.IOException; -import java.util.Enumeration; +import java.util.Iterator; -import org.openoffice.xmerge.converter.xml.sxc.Format; import org.openoffice.xmerge.ConvertData; /** @@ -50,7 +49,7 @@ public abstract class SpreadsheetDecoder { * * @return The Enumeration */ - public abstract Enumeration getNameDefinitions(); + public abstract Iterator getNameDefinitions(); /** * Returns an <code>BookSettings</code> @@ -64,7 +63,7 @@ public abstract class SpreadsheetDecoder { * * @return The Enumeration */ - public abstract Enumeration getColumnRowInfos(); + public abstract Iterator 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 8b3d72e8789f..63c3cd423589 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 @@ -19,7 +19,7 @@ package org.openoffice.xmerge.converter.xml.sxc; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; /** * <p>This class is a abstract class for encoding an SXC into an @@ -99,7 +99,7 @@ public abstract class SpreadsheetEncoder { * @param columnRows An <code>IntArrayList</code> of column * widths. */ - public abstract void setColumnRows(Vector columnRows) throws IOException; + public abstract void setColumnRows(ArrayList 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 34a76ef32aa8..f1119bc761e4 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 @@ -18,25 +18,21 @@ package org.openoffice.xmerge.converter.xml.sxc; -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; -import org.w3c.dom.Element; - import java.io.IOException; import java.util.Enumeration; +import java.util.Iterator; -import org.openoffice.xmerge.Document; import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConvertException; +import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentDeserializer; import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxc.SxcDocument; -import org.openoffice.xmerge.converter.xml.sxc.BookSettings; -import org.openoffice.xmerge.converter.xml.sxc.NameDefinition; -import org.openoffice.xmerge.converter.xml.sxc.CellStyle; import org.openoffice.xmerge.converter.xml.Style; import org.openoffice.xmerge.converter.xml.StyleCatalog; import org.openoffice.xmerge.util.Debug; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * <p>General spreadsheet implementation of <code>DocumentDeserializer</code> @@ -255,8 +251,8 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, } // Add the Defined Name table if there is one - Enumeration nameDefinitionTable = decoder.getNameDefinitions(); - if(nameDefinitionTable.hasMoreElements()) { + Iterator nameDefinitionTable = decoder.getNameDefinitions(); + if(nameDefinitionTable.hasNext()) { processNameDefinition(node, nameDefinitionTable); } @@ -304,15 +300,15 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, * * @throws IOException If any I/O error occurs. */ - protected void processNameDefinition(Node root, Enumeration eNameDefinitions) throws IOException { + protected void processNameDefinition(Node root, Iterator eNameDefinitions) throws IOException { Debug.log(Debug.TRACE, "<NAMED-EXPRESSIONS>"); Element namedExpressionsElement = (Element) doc.createElement(TAG_NAMED_EXPRESSIONS); - while(eNameDefinitions.hasMoreElements()) { + while(eNameDefinitions.hasNext()) { - NameDefinition tableEntry = (NameDefinition) eNameDefinitions.nextElement(); + NameDefinition tableEntry = (NameDefinition) eNameDefinitions.next(); tableEntry.writeNode(doc, namedExpressionsElement); } @@ -380,9 +376,9 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, */ protected void processColumns(Node root) throws IOException { - for(Enumeration e = decoder.getColumnRowInfos();e.hasMoreElements();) { + for(Iterator e = decoder.getColumnRowInfos();e.hasNext();) { - ColumnRowInfo ci = (ColumnRowInfo) e.nextElement(); + ColumnRowInfo ci = (ColumnRowInfo) e.next(); if(ci.isColumn()) { ColumnStyle cStyle = new ColumnStyle("Default",SxcConstants.COLUMN_STYLE_FAMILY, SxcConstants.DEFAULT_STYLE, ci.getSize(), null); @@ -486,8 +482,8 @@ public abstract class SxcDocumentDeserializer implements OfficeConstants, rowElement = (Element) doc.createElement(TAG_TABLE_ROW); - for(Enumeration e = decoder.getColumnRowInfos();e.hasMoreElements();) { - ColumnRowInfo cri = (ColumnRowInfo) e.nextElement(); + for(Iterator e = decoder.getColumnRowInfos();e.hasNext();) { + ColumnRowInfo cri = (ColumnRowInfo) 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, 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 985ccdf72123..f0a651cbbb55 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 @@ -19,28 +19,22 @@ package org.openoffice.xmerge.converter.xml.sxc; import java.awt.Color; - -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Element; - import java.io.IOException; -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; +import java.util.Iterator; -import org.openoffice.xmerge.Document; import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConvertException; +import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentSerializer; - import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxc.SxcDocument; -import org.openoffice.xmerge.converter.xml.sxc.CellStyle; import org.openoffice.xmerge.converter.xml.StyleCatalog; - import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.XmlUtil; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * <p>General spreadsheet implementation of <code>DocumentSerializer</code> @@ -89,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 Vector ColumnRowList; + private ArrayList ColumnRowList; /** Width, in characters, of the current cell display data. */ private int displayWidth = 0; @@ -308,7 +302,7 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, Debug.log(Debug.TRACE, "<TABLE>"); - ColumnRowList = new Vector(); + ColumnRowList = new ArrayList(); // Get table attributes // TODO - extract style from attribute @@ -631,8 +625,8 @@ public abstract class SxcDocumentSerializer implements OfficeConstants, if (fmt.isDefault() && styleName.length()==0) { int index = 1; - for(Enumeration e = ColumnRowList.elements();e.hasMoreElements();) { - ColumnRowInfo cri = (ColumnRowInfo) e.nextElement(); + for(Iterator e = ColumnRowList.iterator();e.hasNext();) { + ColumnRowInfo cri = (ColumnRowInfo) 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 c334119740f2..0f383062f7fc 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 @@ -18,41 +18,33 @@ package org.openoffice.xmerge.converter.xml.xslt; -import java.io.InputStream; -import java.io.IOException; -import java.util.Enumeration; -import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.URIResolver; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; - - -import org.openoffice.xmerge.Document; import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConvertException; +import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentDeserializer; import org.openoffice.xmerge.converter.dom.DOMDocument; -import org.openoffice.xmerge.converter.xml.xslt.GenericOfficeDocument; import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.registry.ConverterInfo; -// Imported TraX classes -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -import javax.xml.transform.URIResolver; -import javax.xml.transform.Source; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -// Imported java classes -import java.io.FileNotFoundException; - /** * <p>Xslt implementation of @@ -106,14 +98,14 @@ public final class DocumentDeserializerImpl */ public Document deserialize() throws ConvertException, IOException { log("\nFound the XSLT deserializer"); - Enumeration enumerate = cd.getDocumentEnumeration(); + Iterator enumerate = cd.getDocumentEnumeration(); org.w3c.dom.Document domDoc=null; DOMDocument docOut=null; GenericOfficeDocument doc = null; ByteArrayOutputStream baos =null; GenericOfficeDocument sxwDoc = new GenericOfficeDocument("output"); - while (enumerate.hasMoreElements()) { - docOut = (DOMDocument) enumerate.nextElement(); + while (enumerate.hasNext()) { + docOut = (DOMDocument) enumerate.next(); } domDoc = docOut.getContentDOM(); try{ 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 a4fd578bcf66..e7a5ed991d3c 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 @@ -18,24 +18,23 @@ package org.openoffice.xmerge.converter.xml.xslt; -import org.openoffice.xmerge.Document; +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; +import java.util.Properties; + import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.DocumentSerializer; -import org.openoffice.xmerge.DocumentSerializerFactory; +import org.openoffice.xmerge.ConverterCapabilities; +import org.openoffice.xmerge.Document; import org.openoffice.xmerge.DocumentDeserializer; import org.openoffice.xmerge.DocumentDeserializerFactory; +import org.openoffice.xmerge.DocumentMerger; +import org.openoffice.xmerge.DocumentMergerFactory; +import org.openoffice.xmerge.DocumentSerializer; +import org.openoffice.xmerge.DocumentSerializerFactory; import org.openoffice.xmerge.PluginFactory; import org.openoffice.xmerge.converter.dom.DOMDocument; -import org.openoffice.xmerge.converter.xml.xslt.GenericOfficeDocument; import org.openoffice.xmerge.util.registry.ConverterInfo; -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.DocumentMergerFactory; -import org.openoffice.xmerge.ConverterCapabilities; - -import java.io.InputStream; -import java.util.Enumeration; -import java.io.IOException; -import java.util.Properties; /** * <p>Xslt implementation of the <code>PluginFactory</code>. @@ -142,9 +141,9 @@ public final class PluginFactoryImpl extends PluginFactory String ext= ".txt"; String mimeType = null; ConverterInfo ci = this.getConverterInfo(); - Enumeration enumerate = ci.getDeviceMime(); - while (enumerate.hasMoreElements()) { - mimeType= (String) enumerate.nextElement(); + Iterator enumerate = ci.getDeviceMime(); + while (enumerate.hasNext()) { + mimeType= (String) 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 7d83f165da35..2ab19045f613 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 @@ -18,7 +18,7 @@ package org.openoffice.xmerge.merger.diff; -import java.util.Vector; +import java.util.ArrayList; import org.openoffice.xmerge.merger.Difference; /** @@ -54,7 +54,7 @@ public class CharArrayLCSAlgorithm { // in those 2 sequences diffTable = createDiffTable(orgSeq, modSeq); - Vector diffResult = new Vector(); + ArrayList diffResult = new ArrayList(); generateResult(diffTable, orgSeqlen, modSeqlen, diffResult); @@ -64,7 +64,7 @@ public class CharArrayLCSAlgorithm { // generateResult is called recursively if (diffResult.size() > 0) { diffArray = new Difference[diffResult.size()]; - diffResult.copyInto(diffArray); + diffResult.toArray(diffArray); } diffTable = null; @@ -154,7 +154,7 @@ public class CharArrayLCSAlgorithm { * and positions filled in. */ private void generateResult(int[][] diffTable, - int i, int j, Vector diffVector) { + int i, int j, ArrayList 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 6a6f9fa6a44d..7e3775526dc1 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 @@ -22,7 +22,7 @@ import org.w3c.dom.Node; import org.openoffice.xmerge.converter.xml.OfficeConstants; -import java.util.Vector; +import java.util.ArrayList; import java.util.List; @@ -57,7 +57,7 @@ public class CharacterParser { */ public CharacterParser(Node node) { textNodes = new TextNodeIterator(node); - nodeList_ = new Vector(); + nodeList_ = new ArrayList(); parseNodes(); } 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 c541b89fb4e1..3f35dcbfde30 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 @@ -18,7 +18,7 @@ package org.openoffice.xmerge.merger.diff; -import java.util.Vector; +import java.util.ArrayList; import org.openoffice.xmerge.merger.DiffAlgorithm; import org.openoffice.xmerge.merger.Difference; import org.openoffice.xmerge.merger.Iterator; @@ -50,7 +50,7 @@ public class IteratorLCSAlgorithm implements DiffAlgorithm { printDiffTable(diffTable); } - Vector diffResult = new Vector(); + ArrayList diffResult = new ArrayList(); generateResult(diffTable, orgSeqlen, modSeqlen, diffResult); @@ -60,7 +60,7 @@ public class IteratorLCSAlgorithm implements DiffAlgorithm { // generateResult is called recursively if (diffResult.size() > 0) { diffArray = new Difference[diffResult.size()]; - diffResult.copyInto(diffArray); + diffResult.toArray(diffArray); } diffTable = null; @@ -161,7 +161,7 @@ public class IteratorLCSAlgorithm implements DiffAlgorithm { * and positions fill in. */ private void generateResult(int[][] diffTable, - int i, int j, Vector diffVector) { + int i, int j, ArrayList 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 7bd32bfcd767..86140d1d7b17 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 @@ -21,7 +21,7 @@ package org.openoffice.xmerge.merger.diff; import org.w3c.dom.Node; import org.w3c.dom.Element; -import java.util.Vector; +import java.util.ArrayList; import org.openoffice.xmerge.merger.DiffAlgorithm; import org.openoffice.xmerge.merger.Difference; import org.openoffice.xmerge.merger.Iterator; @@ -76,7 +76,7 @@ public class IteratorRowCompare implements DiffAlgorithm { int orgSeqlen = orgSeq.elementCount(); int modSeqlen = modSeq.elementCount(); - Vector diffVector = new Vector(); + ArrayList diffVector = new ArrayList(); // i and j are counters to keep track the current position in the // iterator @@ -194,7 +194,7 @@ public class IteratorRowCompare implements DiffAlgorithm { // convert the vector to array Difference[] diffArray = new Difference[diffVector.size()]; - diffVector.copyInto(diffArray); + diffVector.toArray(diffArray); return diffArray; } 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 ccbc3172736c..971d94864d89 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 @@ -18,17 +18,16 @@ package org.openoffice.xmerge.merger.diff; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.NamedNodeMap; +import java.util.ArrayList; +import java.util.List; import org.openoffice.xmerge.ConverterCapabilities; import org.openoffice.xmerge.merger.Iterator; import org.openoffice.xmerge.util.Debug; import org.openoffice.xmerge.util.Resources; - -import java.util.Vector; -import java.util.List; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** @@ -61,7 +60,7 @@ public abstract class NodeIterator implements Iterator { */ public NodeIterator(ConverterCapabilities cc, Node node) { cc_ = cc; - nodeList = new Vector(); + nodeList = new ArrayList(); root = node; markTree(node); } @@ -137,7 +136,7 @@ public abstract class NodeIterator implements Iterator { public void refresh() { - nodeList = new Vector(); + nodeList = new ArrayList(); markTree(root); currentPosition = 0; } 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 cc182c2ba2db..ece388c5c2ba 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/ConverterInfoList.java @@ -18,12 +18,12 @@ package org.openoffice.xmerge.test; +import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.BufferedInputStream; +import java.util.ArrayList; +import java.util.Iterator; import java.util.Properties; -import java.util.Vector; -import java.util.Enumeration; /** * Loads a properties file so that registry knows which plug-ins @@ -35,7 +35,7 @@ public class ConverterInfoList { private static String defaultPropsFile = "ConverterInfoList.properties"; - private Vector jars; + private ArrayList jars; private Properties props = null; @@ -68,7 +68,7 @@ public class ConverterInfoList { int i = 1; String jarFileName = new String(); - jars = new Vector(); + jars = new ArrayList(); while ((jarFileName = props.getProperty("jarname" + i)) != null) { jars.add(jarFileName); @@ -88,9 +88,9 @@ public class ConverterInfoList { * <code>String</code> describes a plug-in to be * loaded into the registry. */ - public Enumeration getJarFileEnum() { + public Iterator getJarFileEnum() { - return jars.elements(); + 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 9a4816b03536..0bd127318e25 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/test/Driver.java @@ -18,20 +18,20 @@ package org.openoffice.xmerge.test; -import java.util.Vector; -import java.util.Enumeration; -import java.io.FileOutputStream; -import java.io.FileInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Iterator; import org.openoffice.xmerge.Convert; -import org.openoffice.xmerge.Document; import org.openoffice.xmerge.ConvertData; import org.openoffice.xmerge.ConverterFactory; -import org.openoffice.xmerge.test.ConverterInfoList; +import org.openoffice.xmerge.Document; +import org.openoffice.xmerge.DocumentMerger; import org.openoffice.xmerge.util.registry.ConverterInfoMgr; import org.openoffice.xmerge.util.registry.ConverterInfoReader; -import org.openoffice.xmerge.DocumentMerger; /** * This class is a command-line driver for the converter framework. @@ -51,7 +51,7 @@ public final class Driver { private String mergeFile = null; /** Command-line parmeter. */ - private Vector deviceFiles = new Vector(); + private ArrayList deviceFiles = new ArrayList(); /** Command-line parmeter shortcuts. */ private String mimeTypes[] = { @@ -78,12 +78,12 @@ public final class Driver { " property file"); } - Enumeration jarInfoEnumeration; + Iterator jarInfoEnumeration; ConverterInfoReader cir; - Enumeration jarFileEnum = cil.getJarFileEnum(); - while (jarFileEnum.hasMoreElements()) { - String jarName = (String) jarFileEnum.nextElement(); + Iterator jarFileEnum = cil.getJarFileEnum(); + while (jarFileEnum.hasNext()) { + String jarName = (String) jarFileEnum.next(); try { cir = new ConverterInfoReader(jarName, false); jarInfoEnumeration = cir.getConverterInfoEnumeration(); @@ -134,9 +134,9 @@ public final class Driver { } try { - Enumeration dfEnum = deviceFiles.elements(); - while (dfEnum.hasMoreElements()) { - processFile = (String)dfEnum.nextElement(); + Iterator dfEnum = deviceFiles.iterator(); + while (dfEnum.hasNext()) { + processFile = (String)dfEnum.next(); File f = new File(processFile); // Make sure the input file actually exists before using it @@ -165,9 +165,9 @@ public final class Driver { if (dataOut != null ) { if (mergeFile == null) { - Enumeration docEnum = dataOut.getDocumentEnumeration(); - while (docEnum.hasMoreElements()) { - Document docOut = (Document)docEnum.nextElement(); + Iterator docEnum = dataOut.getDocumentEnumeration(); + while (docEnum.hasNext()) { + Document docOut = (Document)docEnum.next(); String fileName = docOut.getFileName(); try { FileOutputStream fos = new FileOutputStream(fileName); @@ -185,8 +185,8 @@ public final class Driver { FileInputStream mergeIS = new FileInputStream(mergeFile); Document mergeDoc = myConvert.getOfficeDocument(mergeFile, mergeIS); DocumentMerger merger = myConvert.getDocumentMerger(mergeDoc); - Enumeration mergeDocEnum = dataOut.getDocumentEnumeration(); - Document convertedFile = (Document)mergeDocEnum.nextElement(); + Iterator mergeDocEnum = dataOut.getDocumentEnumeration(); + Document convertedFile = (Document)mergeDocEnum.next(); merger.merge(convertedFile); mergeIS.close(); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ActiveSyncDriver.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ActiveSyncDriver.java index 6756d2fbd918..42ce0a9a427c 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ActiveSyncDriver.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/ActiveSyncDriver.java @@ -121,7 +121,7 @@ public class ActiveSyncDriver { } // Get the document and write it out. - Document doc = (Document)dataOut.getDocumentEnumeration().nextElement(); + Document doc = (Document)dataOut.getDocumentEnumeration().next(); if (doc == null) { return false; } 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 a58888b725ad..2bd53b2ea975 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/OfficeUtil.java @@ -25,7 +25,7 @@ import org.w3c.dom.Text; import org.openoffice.xmerge.converter.xml.OfficeConstants; -import java.util.Vector; +import java.util.ArrayList; /** @@ -46,7 +46,7 @@ public class OfficeUtil implements OfficeConstants { * representing the text. */ public static Node[] parseText(String text, Document parentDoc) { - Vector nodeVec = new Vector(); + ArrayList nodeVec = new ArrayList(); /* * Break up the text from the text run into Open @@ -80,7 +80,7 @@ public class OfficeUtil implements OfficeConstants { if (closerIndex > 0) { String beginningText = text.substring(0, closerIndex); Text textNode = parentDoc.createTextNode(beginningText); - nodeVec.addElement(textNode); + nodeVec.add(textNode); } text = text.substring(closerIndex); @@ -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.elementAt(i); + nodes[i] = (Node)nodeVec.get(i); return nodes; } }
\ No newline at end of file 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 92e1f7b6bad4..259cee0d3401 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 @@ -18,15 +18,16 @@ package org.openoffice.xmerge.util.registry; -import java.util.Vector; -import java.util.Enumeration; +import java.lang.reflect.Constructor; import java.net.URL; import java.net.URLClassLoader; -import java.lang.reflect.Constructor; -import org.openoffice.xmerge.PluginFactory; -import org.openoffice.xmerge.DocumentSerializerFactory; +import java.util.ArrayList; +import java.util.Iterator; + import org.openoffice.xmerge.DocumentDeserializerFactory; import org.openoffice.xmerge.DocumentMergerFactory; +import org.openoffice.xmerge.DocumentSerializerFactory; +import org.openoffice.xmerge.PluginFactory; /** * Class for storing the information about a converter plugin. @@ -53,7 +54,7 @@ public class ConverterInfo { private String piJarName; private String piOfficeMime; - private Vector piDeviceMime; + private ArrayList piDeviceMime; private String piDisplayName; private String piDescription; private String piVersion; @@ -87,7 +88,7 @@ public class ConverterInfo { * be loaded. */ public ConverterInfo(String jarName, String officeMime, - Vector deviceMime, String displayName, String description, + ArrayList deviceMime, String displayName, String description, String version, String vendor, String impl,String xsltSerial, String xsltDeserial) throws RegistryException { @@ -165,7 +166,7 @@ public class ConverterInfo { public ConverterInfo(String jarName, String officeMime, - Vector deviceMime, String displayName, String description, + ArrayList deviceMime, String displayName, String description, String version, String vendor, String impl) throws RegistryException { @@ -289,8 +290,8 @@ public class ConverterInfo { * @return An <code>Enumeration</code> of <code>String</code> * objects indicating the device mime-type. */ - public Enumeration getDeviceMime() { - return(piDeviceMime.elements()); + public Iterator 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 e31468ff7c97..f6d7689e537f 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 Vector converterInfoList; + private static ArrayList converterInfoList; /** * Constructor */ static { - converterInfoList = new Vector(); + converterInfoList = new ArrayList(); } /** @@ -73,7 +73,7 @@ public final class ConverterInfoMgr { "Converter must have valid office mime specified."); throw re; } - if (! ci.getDeviceMime().hasMoreElements()) { + if (! ci.getDeviceMime().hasNext()) { RegistryException re = new RegistryException( "Converter must have valid device mime specified."); throw re; @@ -82,9 +82,9 @@ public final class ConverterInfoMgr { // Verify there is no converter with the same Display Name in // the registry. // - Enumeration ciEnum = converterInfoList.elements(); - while (ciEnum.hasMoreElements()) { - converterInfo = (ConverterInfo)ciEnum.nextElement(); + Iterator ciEnum = converterInfoList.iterator(); + while (ciEnum.hasNext()) { + converterInfo = (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(Enumeration jarEnum) throws RegistryException { + public static void addPlugIn(Iterator jarEnum) throws RegistryException { - while (jarEnum.hasMoreElements()) { - ConverterInfo converterInfo = (ConverterInfo)jarEnum.nextElement(); + while (jarEnum.hasNext()) { + ConverterInfo converterInfo = (ConverterInfo)jarEnum.next(); addPlugIn(converterInfo); } } @@ -128,8 +128,8 @@ public final class ConverterInfoMgr { * <code>ConverterInfo</code> objects, an empty * <code>Vector</code> if none exist. */ - public static Enumeration getConverterInfoEnumeration() { - return (converterInfoList.elements()); + public static Iterator getConverterInfoEnumeration() { + return (converterInfoList.iterator()); } /** @@ -183,10 +183,10 @@ public final class ConverterInfoMgr { ConverterInfo converterInfo; boolean rc = false; - Enumeration ciEnum = converterInfoList.elements(); - while (ciEnum.hasMoreElements()) + Iterator ciEnum = converterInfoList.iterator(); + while (ciEnum.hasNext()) { - converterInfo = (ConverterInfo)ciEnum.nextElement(); + converterInfo = (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 // - Enumeration ciEnum = converterInfoList.elements(); - while (ciEnum.hasMoreElements()) { + Iterator ciEnum = converterInfoList.iterator(); + while (ciEnum.hasNext()) { - converterInfo = (ConverterInfo)ciEnum.nextElement(); + converterInfo = (ConverterInfo)ciEnum.next(); String toDeviceInfo = (String)converterInfo.getOfficeMime(); - Enumeration fromEnum = converterInfo.getDeviceMime(); + Iterator fromEnum = converterInfo.getDeviceMime(); // Loop over the deviceMime types. // - while (fromEnum.hasMoreElements()) { - String fromDeviceInfo = (String)fromEnum.nextElement(); + while (fromEnum.hasNext()) { + String fromDeviceInfo = (String)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 // - Enumeration cifEnum = converterInfoList.elements(); - while (cifEnum.hasMoreElements()) { + Iterator cifEnum = converterInfoList.iterator(); + while (cifEnum.hasNext()) { - converterInfo[0] = (ConverterInfo)cifEnum.nextElement(); + converterInfo[0] = (ConverterInfo)cifEnum.next(); String fromOfficeInfo = converterInfo[0].getOfficeMime(); - Enumeration fromEnum = converterInfo[0].getDeviceMime(); + Iterator fromEnum = converterInfo[0].getDeviceMime(); // Loop over the deviceMime types looking for a deviceFromMime // match. // - while (fromEnum.hasMoreElements()) { - String fromDeviceInfo = (String)fromEnum.nextElement(); + while (fromEnum.hasNext()) { + String fromDeviceInfo = (String)fromEnum.next(); if (deviceFromMime.trim().equals(fromDeviceInfo)) { // Found a a match for deviceFrom. Now loop over the // elements comparing with deviceToMime // - Enumeration citEnum = converterInfoList.elements(); - while (citEnum.hasMoreElements()) { + Iterator citEnum = converterInfoList.iterator(); + while (citEnum.hasNext()) { - converterInfo[1] = (ConverterInfo)citEnum.nextElement(); + converterInfo[1] = (ConverterInfo)citEnum.next(); String toOfficeInfo = converterInfo[1].getOfficeMime(); - Enumeration toEnum = converterInfo[1].getDeviceMime(); + Iterator toEnum = converterInfo[1].getDeviceMime(); // Loop over deviceMime types looking for a // deviceToMime match. // - while (toEnum.hasMoreElements()) { - String toDeviceInfo = (String)toEnum.nextElement(); + while (toEnum.hasNext()) { + String toDeviceInfo = (String)toEnum.next(); if (deviceToMime.trim().equals(toDeviceInfo) && fromOfficeInfo.equals(toOfficeInfo)) { @@ -365,7 +365,7 @@ public final class ConverterInfoMgr { } if (cir != null) { - Enumeration jarInfoEnum = cir.getConverterInfoEnumeration(); + Iterator jarInfoEnum = cir.getConverterInfoEnumeration(); try { ConverterInfoMgr.addPlugIn(jarInfoEnum); } catch (Exception e) { @@ -471,25 +471,25 @@ public final class ConverterInfoMgr { // } else if (c == 'V') { - Enumeration ciEnum = ConverterInfoMgr.getConverterInfoEnumeration(); + Iterator ciEnum = ConverterInfoMgr.getConverterInfoEnumeration(); int ciCnt = 0; - while (ciEnum.hasMoreElements()) + while (ciEnum.hasNext()) { System.out.println(""); System.out.println(" Displaying converter number " + ciCnt); - ConverterInfo converterInfo = (ConverterInfo)ciEnum.nextElement(); + ConverterInfo 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()); - Enumeration fromEnum = converterInfo.getDeviceMime(); + Iterator fromEnum = converterInfo.getDeviceMime(); int feCnt = 1; - while (fromEnum.hasMoreElements()) + while (fromEnum.hasNext()) { System.out.println(" DeviceMime : (#" + feCnt + ") : " + - (String)fromEnum.nextElement()); + (String)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 5c1d400e8bb5..bcf0819bb141 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 Vector converterInfoList; + private ArrayList converterInfoList; /** @@ -87,7 +87,7 @@ public class ConverterInfoReader { JarFile jarfile; URL url; - converterInfoList = new Vector(); + converterInfoList = new ArrayList(); jarfilename = jar; // Get Jar via URL @@ -161,7 +161,7 @@ public class ConverterInfoReader { Node detailNode; String elementTagName; String officeMime = null; - Vector deviceMime = new Vector(); + ArrayList deviceMime = new ArrayList(); String name = null; String desc = null; String version = null; @@ -260,8 +260,8 @@ public class ConverterInfoReader { * @return An <code>Enumeration</code> of <code>ConverterInfo</code> * objects. */ - public Enumeration getConverterInfoEnumeration() { - return (converterInfoList.elements()); + public Iterator getConverterInfoEnumeration() { + return (converterInfoList.iterator()); } } |