diff options
author | Noel Grandin <noel@peralex.com> | 2012-09-07 13:41:02 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-09-10 23:43:39 +0200 |
commit | 4c9e62c6e3513a57e86dfb7ea06a74ce2943aaaa (patch) | |
tree | 1008fb1ceb97da428ab451b0d1b83b1bb3b5e089 /scripting | |
parent | Java cleanup, remove unnecessary imports (diff) | |
download | core-4c9e62c6e3513a57e86dfb7ea06a74ce2943aaaa.tar.gz core-4c9e62c6e3513a57e86dfb7ea06a74ce2943aaaa.zip |
Java cleanup, convert ArrayList and Vector to use generics
Change-Id: Ic668b46872ee0bfd259ca335aed9d68fb545c3a4
Diffstat (limited to 'scripting')
10 files changed, 44 insertions, 44 deletions
diff --git a/scripting/java/org/openoffice/idesupport/JavaFinder.java b/scripting/java/org/openoffice/idesupport/JavaFinder.java index d8e3ec02117f..8c0071844fe9 100644 --- a/scripting/java/org/openoffice/idesupport/JavaFinder.java +++ b/scripting/java/org/openoffice/idesupport/JavaFinder.java @@ -41,11 +41,11 @@ public class JavaFinder implements MethodFinder { private static final String FIRST_PARAM = "drafts.com.sun.star.script.framework.runtime.XScriptContext"; - private Vector classpath = null; + private Vector<String> classpath = null; private JavaFinder() {} - private JavaFinder(Vector classpath) { + private JavaFinder(Vector<String> classpath) { this.classpath = classpath; } @@ -59,7 +59,7 @@ public class JavaFinder implements MethodFinder { return finder; } - public static JavaFinder getInstance(Vector classpath) { + public static JavaFinder getInstance(Vector<String> classpath) { return new JavaFinder(classpath); } @@ -126,7 +126,7 @@ public class JavaFinder implements MethodFinder { } if (result.size() != 0) - return (ScriptEntry[])result.toArray(empty); + return result.toArray(empty); return empty; } @@ -136,7 +136,7 @@ public class JavaFinder implements MethodFinder { for (int i = 0; i < len; i++) { try { - String s = (String)classpath.elementAt(i); + String s = classpath.elementAt(i); s = SVersionRCFile.toFileURL(s); if (s != null) @@ -146,7 +146,7 @@ public class JavaFinder implements MethodFinder { } } - return new URLClassLoader((URL[])urls.toArray(new URL[0])); + return new URLClassLoader(urls.toArray(new URL[0])); } private ClassLoader getClassLoader(File basedir) { @@ -175,7 +175,7 @@ public class JavaFinder implements MethodFinder { File f; for (int i = 0; i < urls.length; i++) { try { - f = (File)files.get(i); + f = files.get(i); urlpath = SVersionRCFile.toFileURL(f.getAbsolutePath()); if (urlpath != null) @@ -215,7 +215,7 @@ public class JavaFinder implements MethodFinder { ArrayList<String> result = new ArrayList<String>(); for (int i = 0; i < classFiles.size(); i++) { - File classFile = (File)classFiles.get(i); + File classFile = classFiles.get(i); String className = classFile.getName(); className = className.substring(0, className.lastIndexOf(CLASS_SUFFIX)); boolean finished = false; @@ -223,7 +223,7 @@ public class JavaFinder implements MethodFinder { for (int j = 0; j < javaFiles.size() && finished == false; j++) { - File javaFile = (File)javaFiles.get(j); + File javaFile = javaFiles.get(j); String javaName = javaFile.getName(); javaName = javaName.substring(0, javaName.lastIndexOf(JAVA_SUFFIX)); @@ -240,6 +240,6 @@ public class JavaFinder implements MethodFinder { } } } - return (String[])result.toArray(new String[0]); + return result.toArray(new String[0]); } } diff --git a/scripting/java/org/openoffice/idesupport/LocalOffice.java b/scripting/java/org/openoffice/idesupport/LocalOffice.java index 3fa8dc5e2d8c..ffbbb3fbee36 100644 --- a/scripting/java/org/openoffice/idesupport/LocalOffice.java +++ b/scripting/java/org/openoffice/idesupport/LocalOffice.java @@ -43,7 +43,7 @@ public class LocalOffice public static final LocalOffice create( ClassLoader parent, String officePath, int port) { - Vector path = new Vector(); + Vector<String> path = new Vector<String>(); path.addElement(officePath + "/program/classes/ridl.jar"); path.addElement(officePath + "/program/classes/jurt.jar"); path.addElement(officePath + "/program/classes/unoil.jar"); diff --git a/scripting/java/org/openoffice/idesupport/OfficeDocument.java b/scripting/java/org/openoffice/idesupport/OfficeDocument.java index 02fdba5632f0..72e17c68ff33 100644 --- a/scripting/java/org/openoffice/idesupport/OfficeDocument.java +++ b/scripting/java/org/openoffice/idesupport/OfficeDocument.java @@ -51,9 +51,9 @@ public class OfficeDocument return false; } - public Enumeration getParcels() { + public Enumeration<String> getParcels() { - Vector parcels = new Vector(); + Vector<String> parcels = new Vector<String>(); ZipFile zp = null; try diff --git a/scripting/java/org/openoffice/idesupport/SVersionRCFile.java b/scripting/java/org/openoffice/idesupport/SVersionRCFile.java index 9fd9a81e1896..9e7bbe209ce4 100644 --- a/scripting/java/org/openoffice/idesupport/SVersionRCFile.java +++ b/scripting/java/org/openoffice/idesupport/SVersionRCFile.java @@ -57,11 +57,11 @@ public class SVersionRCFile { /* Make sure this is in LowerCase !!!!! */ private static final String SCRIPTF = "scriptf"; - private static final HashMap files = new HashMap(3); + private static final HashMap<String, SVersionRCFile> files = new HashMap<String, SVersionRCFile>(3); private File sversionrc = null; private OfficeInstallation defaultversion = null; - private Vector versions = null; + private Vector<OfficeInstallation> versions = null; private long lastModified = 0; public SVersionRCFile() { @@ -70,7 +70,7 @@ public class SVersionRCFile { public SVersionRCFile(String name) { sversionrc = new File(name); - versions = new Vector(5); + versions = new Vector<OfficeInstallation>(5); } public static SVersionRCFile createInstance() { @@ -81,7 +81,7 @@ public class SVersionRCFile { SVersionRCFile result = null; synchronized(SVersionRCFile.class) { - result = (SVersionRCFile)files.get(name); + result = files.get(name); if (result == null) { result = new SVersionRCFile(name); @@ -99,7 +99,7 @@ public class SVersionRCFile { return defaultversion; } - public Enumeration getVersions() throws IOException { + public Enumeration<OfficeInstallation> getVersions() throws IOException { long l = sversionrc.lastModified(); @@ -209,7 +209,7 @@ public class SVersionRCFile { else ov = new SVersionRCFile(args[0]); - Enumeration enumer; + Enumeration<OfficeInstallation> enumer; try { enumer = ov.getVersions(); @@ -220,7 +220,7 @@ public class SVersionRCFile { } while (enumer.hasMoreElements()) { - OfficeInstallation oi = (OfficeInstallation)enumer.nextElement(); + OfficeInstallation oi = enumer.nextElement(); System.out.println("Name: " + oi.getName() + ", Path: " + oi.getPath() + ", URL: " + oi.getURL()); } diff --git a/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java b/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java index 4030d683db40..b78f439a4a8d 100644 --- a/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java +++ b/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java @@ -38,13 +38,14 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import com.sun.star.script.framework.container.ParcelDescriptor; +import com.sun.star.script.framework.container.ScriptEntry; import org.openoffice.idesupport.zip.ParcelZipper; public class ConfigurePanel extends JPanel { private File basedir; - private Vector classpath; + private Vector<String> classpath; private ParcelDescriptor descriptor; private MethodPanel methodPanel; @@ -53,7 +54,7 @@ public class ConfigurePanel extends JPanel { public static final String DIALOG_TITLE = "Choose What to Export as Scripts"; - public ConfigurePanel(String basedir, Vector classpath, + public ConfigurePanel(String basedir, Vector<String> classpath, ParcelDescriptor descriptor) { this.basedir = new File(basedir); @@ -62,7 +63,7 @@ public class ConfigurePanel extends JPanel { initUI(); } - public ConfigurePanel(String basedir, Vector classpath) + public ConfigurePanel(String basedir, Vector<String> classpath) throws IOException { this.basedir = new File(basedir); @@ -72,7 +73,7 @@ public class ConfigurePanel extends JPanel { initUI(); } - public void reload(String basedir, Vector classpath, + public void reload(String basedir, Vector<String> classpath, ParcelDescriptor descriptor) { if (basedir != null) @@ -90,7 +91,7 @@ public class ConfigurePanel extends JPanel { scriptPanel.reload(descriptor.getScriptEntries()); } - public void reload(String basedir, Vector classpath) + public void reload(String basedir, Vector<String> classpath) throws IOException { if (basedir != null) @@ -108,7 +109,7 @@ public class ConfigurePanel extends JPanel { } public ParcelDescriptor getConfiguration() throws Exception { - Enumeration scripts = scriptPanel.getScriptEntries(); + Enumeration<ScriptEntry> scripts = scriptPanel.getScriptEntries(); descriptor.setScriptEntries(scripts); return descriptor; } diff --git a/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java b/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java index 3e85f2048316..9bc31edc30e2 100644 --- a/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java +++ b/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java @@ -33,7 +33,7 @@ import org.openoffice.idesupport.JavaFinder; public class MethodPanel extends JPanel { private File basedir; - private Vector classpath; + private Vector<String> classpath; private final static String FIRST_PARAM = "drafts.com.sun.star.script.framework.runtime.XScriptContext"; @@ -42,7 +42,7 @@ public class MethodPanel extends JPanel { private JList list; private ScriptEntry[] values; - public MethodPanel(File basedir, Vector classpath, String language) { + public MethodPanel(File basedir, Vector<String> classpath, String language) { this.basedir = basedir; this.classpath = classpath; @@ -50,7 +50,7 @@ public class MethodPanel extends JPanel { initUI(); } - public void reload(File basedir, Vector classpath, String language) { + public void reload(File basedir, Vector<String> classpath, String language) { this.basedir = basedir; this.classpath = classpath; diff --git a/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java b/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java index b30e1a9949f0..f34dd4806bdf 100644 --- a/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java +++ b/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java @@ -81,7 +81,7 @@ public class ScriptPanel extends JPanel { model.removeAll(); } - public Enumeration getScriptEntries() { + public Enumeration<ScriptEntry> getScriptEntries() { return model.getScriptEntries(); } @@ -121,11 +121,11 @@ public class ScriptPanel extends JPanel { final String[] columnNames = {"Exported Method", "Script Name"}; - private Vector scripts; + private Vector<ScriptEntry> scripts; private int nextRow; public ScriptTableModel(ScriptEntry[] entries) { - scripts = new Vector(entries.length + 11); + scripts = new Vector<ScriptEntry>(entries.length + 11); for (int i = 0; i < entries.length; i++) { scripts.addElement(entries[i]); } @@ -162,7 +162,7 @@ public class ScriptPanel extends JPanel { nextRow = 0; } - public Enumeration getScriptEntries() { + public Enumeration<ScriptEntry> getScriptEntries() { return scripts.elements(); } @@ -170,7 +170,7 @@ public class ScriptPanel extends JPanel { String result = ""; ScriptEntry entry; - entry = (ScriptEntry)scripts.elementAt(row); + entry = scripts.elementAt(row); if (col == 0) result = entry.getLanguageName(); @@ -188,7 +188,7 @@ public class ScriptPanel extends JPanel { } public void setValueAt(Object value, int row, int col) { - ScriptEntry entry = (ScriptEntry)scripts.elementAt(row); + ScriptEntry entry = scripts.elementAt(row); entry.setLogicalName((String)value); fireTableCellUpdated(row, col); } diff --git a/scripting/workben/installer/IdeUpdater.java b/scripting/workben/installer/IdeUpdater.java index 5d94cffcb7ec..721a265d644c 100644 --- a/scripting/workben/installer/IdeUpdater.java +++ b/scripting/workben/installer/IdeUpdater.java @@ -39,7 +39,7 @@ public class IdeUpdater extends Thread { private JLabel statusLabel; - private Vector listeners; + private Vector<InstallListener> listeners; private Thread internalThread; private boolean threadSuspended; private JProgressBar progressBar; @@ -69,7 +69,7 @@ public class IdeUpdater extends Thread { System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath ); this.installPath = installPath; this.statusLabel = statusLabel; - listeners = new Vector(); + listeners = new Vector<InstallListener>(); threadSuspended = false; progressBar=pBar; progressBar.setStringPainted(true); @@ -173,10 +173,10 @@ public class IdeUpdater extends Thread { private void onInstallComplete() { - Enumeration e = listeners.elements(); + Enumeration<InstallListener> e = listeners.elements(); while (e.hasMoreElements()) { - InstallListener listener = (InstallListener)e.nextElement(); + InstallListener listener = e.nextElement(); listener.installationComplete(null); } }// onInstallComplete diff --git a/scripting/workben/installer/InstUtil.java b/scripting/workben/installer/InstUtil.java index c3d673cc377c..05d265d147ff 100644 --- a/scripting/workben/installer/InstUtil.java +++ b/scripting/workben/installer/InstUtil.java @@ -331,7 +331,6 @@ public class InstUtil { public static Properties getOfficeVersions(File sversionFile) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(sversionFile)); - Vector values; String sectionName = null; Properties results = new Properties(); diff --git a/scripting/workben/installer/XmlUpdater.java b/scripting/workben/installer/XmlUpdater.java index 5f1c88c41e7e..5161350975d5 100644 --- a/scripting/workben/installer/XmlUpdater.java +++ b/scripting/workben/installer/XmlUpdater.java @@ -38,7 +38,7 @@ public class XmlUpdater extends Thread { private JLabel statusLabel; - private Vector listeners; + private Vector<InstallListener> listeners; private Thread internalThread; private boolean threadSuspended; private JProgressBar progressBar; @@ -107,7 +107,7 @@ public class XmlUpdater extends Thread { this.statusLabel = statusLabel; this.netInstall = netInstall; this.bindingsInstall = bindingsInstall; - listeners = new Vector(); + listeners = new Vector<InstallListener>(); threadSuspended = false; progressBar=pBar; progressBar.setStringPainted(true); @@ -432,10 +432,10 @@ public class XmlUpdater extends Thread { private void onInstallComplete() { - Enumeration e = listeners.elements(); + Enumeration<InstallListener> e = listeners.elements(); while (e.hasMoreElements()) { - InstallListener listener = (InstallListener)e.nextElement(); + InstallListener listener = e.nextElement(); listener.installationComplete(null); } }// onInstallComplete |