From 61d4d356b63091bb27ea0c7be0a6daaf06b74c28 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 29 Sep 2016 08:27:28 -0500 Subject: Bug 502425 - Refactor code for Java 7 Change-Id: I64d3a28a743a0292db27fd421294421dc51eb2e1 Signed-off-by: Thomas Watson --- .../compatibility/plugins/PluginConverterImpl.java | 26 +++++++++++----------- .../osgi/compatibility/plugins/PluginParser.java | 18 +++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'bundles/org.eclipse.osgi.compatibility.plugins/src') diff --git a/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java b/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java index 26744fbd9..7bba1320d 100644 --- a/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java +++ b/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java @@ -127,7 +127,7 @@ public class PluginConverterImpl implements PluginConverter { pluginInfo = null; pluginManifestLocation = null; pluginZip = null; - generatedManifest = new Hashtable(10); + generatedManifest = new Hashtable<>(10); manifestType = MANIFEST_TYPE_UNKNOWN; target = null; devProperties = null; @@ -165,7 +165,7 @@ public class PluginConverterImpl implements PluginConverter { private Set filterExport(Set exportToFilter, Collection filter) { if (filter == null || filter.contains("*")) //$NON-NLS-1$ return exportToFilter; - Set filteredExport = new HashSet(exportToFilter.size()); + Set filteredExport = new HashSet<>(exportToFilter.size()); for (String anExport : exportToFilter) { for (String aFilter : filter) { int dotStar = aFilter.indexOf(".*"); //$NON-NLS-1$ @@ -182,7 +182,7 @@ public class PluginConverterImpl implements PluginConverter { private List findOSJars(File pluginRoot, String path, boolean filter) { path = path.substring(4); - List found = new ArrayList(0); + List found = new ArrayList<>(0); for (int i = 0; i < OS_LIST.length; i++) { //look for os/osname/path String searchedPath = "os/" + OS_LIST[i] + "/" + path; //$NON-NLS-1$ //$NON-NLS-2$ @@ -246,7 +246,7 @@ public class PluginConverterImpl implements PluginConverter { private List findWSJars(File pluginRoot, String path, boolean filter) { path = path.substring(4); - List found = new ArrayList(0); + List found = new ArrayList<>(0); for (int i = 0; i < WS_LIST.length; i++) { String searchedPath = "ws/" + WS_LIST[i] + path; //$NON-NLS-1$ if (new File(pluginRoot, searchedPath).exists()) { @@ -275,7 +275,7 @@ public class PluginConverterImpl implements PluginConverter { private Map convertDictionaryToMap(Dictionary dictionary) { if (dictionary == null) return Collections.emptyMap(); - Map result = new HashMap(dictionary.size()); + Map result = new HashMap<>(dictionary.size()); Enumeration keys = dictionary.keys(); while (keys.hasMoreElements()) { K key = keys.nextElement(); @@ -295,7 +295,7 @@ public class PluginConverterImpl implements PluginConverter { throw new PluginConversionException(message); } // replaces any eventual existing file - manifestToWrite = new Hashtable(convertDictionaryToMap(manifestToWrite)); + manifestToWrite = new Hashtable<>(convertDictionaryToMap(manifestToWrite)); // MANIFEST.MF files must be written using UTF-8 out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(generationLocation), UTF_8)); writeEntry(MANIFEST_VERSION, manifestToWrite.remove(MANIFEST_VERSION)); @@ -473,7 +473,7 @@ public class PluginConverterImpl implements PluginConverter { if (devProperties != null || configuration.inDevelopmentMode()) { String[] devClassPath = configuration.getDevClassPath(pluginInfo.getUniqueId(), devProperties); // collect export clauses - List allExportClauses = new ArrayList(libs.size()); + List allExportClauses = new ArrayList<>(libs.size()); Set>> libEntries = libs.entrySet(); for (Iterator>> iter = libEntries.iterator(); iter.hasNext();) { Map.Entry> element = iter.next(); @@ -491,7 +491,7 @@ public class PluginConverterImpl implements PluginConverter { } } - Set result = new TreeSet(); + Set result = new TreeSet<>(); Set>> libEntries = libs.entrySet(); for (Iterator>> iter = libEntries.iterator(); iter.hasNext();) { Map.Entry> element = iter.next(); @@ -515,7 +515,7 @@ public class PluginConverterImpl implements PluginConverter { exports = filterExport(getExportsFromDir(libraryLocation), filter); } else { List expandedLibs = getLibrariesExpandingVariables(element.getKey(), false); - exports = new HashSet(); + exports = new HashSet<>(); for (Iterator iterator = expandedLibs.iterator(); iterator.hasNext();) { String libName = iterator.next(); File libFile = new File(pluginManifestLocation, libName); @@ -537,7 +537,7 @@ public class PluginConverterImpl implements PluginConverter { private Set getExportsFromDir(File location, String packageName) { String prefix = (packageName.length() > 0) ? (packageName + '.') : ""; //$NON-NLS-1$ String[] files = location.list(); - Set exportedPaths = new HashSet(); + Set exportedPaths = new HashSet<>(); boolean containsFile = false; if (files != null) for (int i = 0; i < files.length; i++) { @@ -560,7 +560,7 @@ public class PluginConverterImpl implements PluginConverter { } private Set getExportsFromJAR(File jarFile) { - Set names = new HashSet(); + Set names = new HashSet<>(); ZipFile file = null; try { file = new ZipFile(jarFile); @@ -597,7 +597,7 @@ public class PluginConverterImpl implements PluginConverter { private List getLibrariesExpandingVariables(String libraryPath, boolean filter) { String var = hasPrefix(libraryPath); if (var == null) { - List returnValue = new ArrayList(1); + List returnValue = new ArrayList<>(1); returnValue.add(libraryPath); return returnValue; } @@ -607,7 +607,7 @@ public class PluginConverterImpl implements PluginConverter { if (var.equals("os")) { //$NON-NLS-1$ return findOSJars(pluginManifestLocation, libraryPath, filter); } - return new ArrayList(0); + return new ArrayList<>(0); } //return a String representing the string found between the $s diff --git a/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java b/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java index e6cb4d3a5..933114d3b 100644 --- a/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java +++ b/bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java @@ -70,7 +70,7 @@ public class PluginParser extends DefaultHandler implements IModel { public Map> getLibraries() { if (libraries == null) - return new HashMap>(0); + return new HashMap<>(0); return libraries; } @@ -78,7 +78,7 @@ public class PluginParser extends DefaultHandler implements IModel { if (!TARGET21.equals(target) && schemaVersion == null && !requiresExpanded) { requiresExpanded = true; if (requires == null) { - requires = new ArrayList(1); + requires = new ArrayList<>(1); requires.add(new Prerequisite(PluginConverterImpl.PI_RUNTIME, TARGET21_STRING, false, false, IModel.PLUGIN_REQUIRES_MATCH_GREATER_OR_EQUAL)); requires.add(new Prerequisite(PluginConverterImpl.PI_RUNTIME_COMPATIBILITY, null, false, false, null)); } else { @@ -108,7 +108,7 @@ public class PluginParser extends DefaultHandler implements IModel { } } if (requires == null) - return requires = new ArrayList(0); + return requires = new ArrayList<>(0); return requires; } @@ -187,10 +187,10 @@ public class PluginParser extends DefaultHandler implements IModel { } // Current State Information - Stack stateStack = new Stack(); + Stack stateStack = new Stack<>(); // Current object stack (used to hold the current object we are populating in this plugin info - Stack objectStack = new Stack(); + Stack objectStack = new Stack<>(); Locator locator = null; // Valid States @@ -273,8 +273,8 @@ public class PluginParser extends DefaultHandler implements IModel { @SuppressWarnings("unchecked") List exports = (List) objectStack.pop(); if (manifestInfo.libraries == null) { - manifestInfo.libraries = new HashMap>(3); - manifestInfo.libraryPaths = new ArrayList(3); + manifestInfo.libraries = new HashMap<>(3); + manifestInfo.libraryPaths = new ArrayList<>(3); } manifestInfo.libraries.put(curLibrary, exports); manifestInfo.libraryPaths.add(curLibrary.replace('\\', '/')); @@ -477,7 +477,7 @@ public class PluginParser extends DefaultHandler implements IModel { public static SAXParserFactory acquireXMLParsing(BundleContext context) { if (xmlTracker == null) { - xmlTracker = new ServiceTracker(context, "javax.xml.parsers.SAXParserFactory", null); //$NON-NLS-1$ + xmlTracker = new ServiceTracker<>(context, "javax.xml.parsers.SAXParserFactory", null); //$NON-NLS-1$ xmlTracker.open(); } SAXParserFactory result = xmlTracker.getService(); @@ -595,7 +595,7 @@ public class PluginParser extends DefaultHandler implements IModel { public void parsePluginRequiresImport(Attributes attributes) { if (manifestInfo.requires == null) { - manifestInfo.requires = new ArrayList(); + manifestInfo.requires = new ArrayList<>(); // to avoid cycles // if (!manifestInfo.pluginId.equals(PluginConverterImpl.PI_RUNTIME)) //$NON-NLS-1$ // manifestInfo.requires.add(new Prerequisite(PluginConverterImpl.PI_RUNTIME, null, false, false, null)); //$NON-NLS-1$ -- cgit v1.2.3