Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-09-29 09:27:28 -0400
committerThomas Watson2016-09-29 10:33:27 -0400
commit61d4d356b63091bb27ea0c7be0a6daaf06b74c28 (patch)
tree6fd39d3bb846a8fbfa5d4ea58e0a077f432e0591 /bundles/org.eclipse.osgi.compatibility.plugins/src
parentd200e63587ccac6d7c2d0f506b8f30a2ebe47fe5 (diff)
downloadrt.equinox.framework-61d4d356b63091bb27ea0c7be0a6daaf06b74c28.tar.gz
rt.equinox.framework-61d4d356b63091bb27ea0c7be0a6daaf06b74c28.tar.xz
rt.equinox.framework-61d4d356b63091bb27ea0c7be0a6daaf06b74c28.zip
Bug 502425 - Refactor code for Java 7
Change-Id: I64d3a28a743a0292db27fd421294421dc51eb2e1 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.compatibility.plugins/src')
-rw-r--r--bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginConverterImpl.java26
-rw-r--r--bundles/org.eclipse.osgi.compatibility.plugins/src/org/eclipse/osgi/compatibility/plugins/PluginParser.java18
2 files changed, 22 insertions, 22 deletions
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<String, String>(10);
+ generatedManifest = new Hashtable<>(10);
manifestType = MANIFEST_TYPE_UNKNOWN;
target = null;
devProperties = null;
@@ -165,7 +165,7 @@ public class PluginConverterImpl implements PluginConverter {
private Set<String> filterExport(Set<String> exportToFilter, Collection<String> filter) {
if (filter == null || filter.contains("*")) //$NON-NLS-1$
return exportToFilter;
- Set<String> filteredExport = new HashSet<String>(exportToFilter.size());
+ Set<String> 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<String> findOSJars(File pluginRoot, String path, boolean filter) {
path = path.substring(4);
- List<String> found = new ArrayList<String>(0);
+ List<String> 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<String> findWSJars(File pluginRoot, String path, boolean filter) {
path = path.substring(4);
- List<String> found = new ArrayList<String>(0);
+ List<String> 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 <K, V> Map<K, V> convertDictionaryToMap(Dictionary<K, V> dictionary) {
if (dictionary == null)
return Collections.emptyMap();
- Map<K, V> result = new HashMap<K, V>(dictionary.size());
+ Map<K, V> result = new HashMap<>(dictionary.size());
Enumeration<K> 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<String, String>(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<String> allExportClauses = new ArrayList<String>(libs.size());
+ List<String> allExportClauses = new ArrayList<>(libs.size());
Set<Map.Entry<String, List<String>>> libEntries = libs.entrySet();
for (Iterator<Map.Entry<String, List<String>>> iter = libEntries.iterator(); iter.hasNext();) {
Map.Entry<String, List<String>> element = iter.next();
@@ -491,7 +491,7 @@ public class PluginConverterImpl implements PluginConverter {
}
}
- Set<String> result = new TreeSet<String>();
+ Set<String> result = new TreeSet<>();
Set<Map.Entry<String, List<String>>> libEntries = libs.entrySet();
for (Iterator<Map.Entry<String, List<String>>> iter = libEntries.iterator(); iter.hasNext();) {
Map.Entry<String, List<String>> element = iter.next();
@@ -515,7 +515,7 @@ public class PluginConverterImpl implements PluginConverter {
exports = filterExport(getExportsFromDir(libraryLocation), filter);
} else {
List<String> expandedLibs = getLibrariesExpandingVariables(element.getKey(), false);
- exports = new HashSet<String>();
+ exports = new HashSet<>();
for (Iterator<String> 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<String> getExportsFromDir(File location, String packageName) {
String prefix = (packageName.length() > 0) ? (packageName + '.') : ""; //$NON-NLS-1$
String[] files = location.list();
- Set<String> exportedPaths = new HashSet<String>();
+ Set<String> 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<String> getExportsFromJAR(File jarFile) {
- Set<String> names = new HashSet<String>();
+ Set<String> names = new HashSet<>();
ZipFile file = null;
try {
file = new ZipFile(jarFile);
@@ -597,7 +597,7 @@ public class PluginConverterImpl implements PluginConverter {
private List<String> getLibrariesExpandingVariables(String libraryPath, boolean filter) {
String var = hasPrefix(libraryPath);
if (var == null) {
- List<String> returnValue = new ArrayList<String>(1);
+ List<String> 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<String>(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<String, List<String>> getLibraries() {
if (libraries == null)
- return new HashMap<String, List<String>>(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<Prerequisite>(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<Prerequisite>(0);
+ return requires = new ArrayList<>(0);
return requires;
}
@@ -187,10 +187,10 @@ public class PluginParser extends DefaultHandler implements IModel {
}
// Current State Information
- Stack<Integer> stateStack = new Stack<Integer>();
+ Stack<Integer> stateStack = new Stack<>();
// Current object stack (used to hold the current object we are populating in this plugin info
- Stack<Object> objectStack = new Stack<Object>();
+ Stack<Object> objectStack = new Stack<>();
Locator locator = null;
// Valid States
@@ -273,8 +273,8 @@ public class PluginParser extends DefaultHandler implements IModel {
@SuppressWarnings("unchecked")
List<String> exports = (List<String>) objectStack.pop();
if (manifestInfo.libraries == null) {
- manifestInfo.libraries = new HashMap<String, List<String>>(3);
- manifestInfo.libraryPaths = new ArrayList<String>(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<SAXParserFactory, SAXParserFactory>(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<Prerequisite>();
+ 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$

Back to the top