From 91362508275511e0ca686617d78a38eb0a58a5e8 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Thu, 5 Nov 2009 15:46:04 +0000 Subject: [PATCH] cleanup only: Java generics + enhanced loops --- .../model/CConfigurationSpecSettings.java | 46 ++++++++----------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java index 80accca071c..b2d58724b85 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java @@ -18,6 +18,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +import java.util.Map.Entry; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.CExternalSetting; @@ -97,9 +98,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ setCOwner(settings.getAttribute(OWNER_ID)); - ICStorageElement children[] = settings.getChildren(); - for(int i = 0; i < children.length; i++){ - ICStorageElement child = children[i]; + for (ICStorageElement child : settings.getChildren()) { String name = child.getName(); if(StorableCdtVariables.MACROS_ELEMENT_NAME.equals(name)){ @@ -563,7 +562,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ ICConfigExtensionReference refs[] = doGet(extensionPointID); if (refs == null) return new ICConfigExtensionReference[0]; - return (ICConfigExtensionReference[])refs.clone(); + return refs.clone(); } private void checkReconsile(String extensionPointID, boolean toExt){ @@ -672,10 +671,10 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ ICConfigExtensionReference[] refs = doGet(extensionPoint); ICConfigExtensionReference extRef = null; - if (refs != null && refs.length != 0){ - for(int i = 0; i < refs.length; i++){ - if(refs[i].getID().equals(extension)){ - extRef = refs[i]; + if (refs != null) { + for (ICConfigExtensionReference ref : refs) { + if(ref.getID().equals(extension)){ + extRef = ref; break; } } @@ -761,10 +760,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ } private void loadExtensionInfo(ICStorageElement node, boolean oldData) { - ICStorageElement childNode; - ICStorageElement list[] = node.getChildren(); - for (int i = 0; i < list.length; i++) { - childNode = list[i]; + for (ICStorageElement childNode : node.getChildren()) { // if (childNode.getNodeType() == Node.ELEMENT_NODE) { if (childNode.getName().equals(PROJECT_EXTENSION)) { try { @@ -787,12 +783,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ String point = element.getAttribute(PROJECT_EXTENSION_ATTR_POINT); String id = element.getAttribute(PROJECT_EXTENSION_ATTR_ID); CConfigExtensionReference ext = createRef(point, id); - ICStorageElement extAttrib[] = element.getChildren(); - for (int j = 0; j < extAttrib.length; j++) { - if (extAttrib[j].getName().equals(PROJECT_EXTENSION_ATTRIBUTE)) { + for (ICStorageElement extAttr : element.getChildren()) { + if (extAttr.getName().equals(PROJECT_EXTENSION_ATTRIBUTE)) { // NamedNodeMap attrib = extAttrib.item(j).getAttributes(); - getInfo(ext).setAttribute(extAttrib[j].getAttribute(PROJECT_EXTENSION_ATTRIBUTE_KEY), - extAttrib[j].getAttribute(PROJECT_EXTENSION_ATTRIBUTE_VALUE)); + getInfo(ext).setAttribute(extAttr.getAttribute(PROJECT_EXTENSION_ATTRIBUTE_KEY), + extAttr.getAttribute(PROJECT_EXTENSION_ATTRIBUTE_VALUE)); } } } @@ -817,10 +812,8 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ } private void decodeProjectData(ICStorageElement data) throws CoreException { - ICStorageElement[] nodes = data.getChildren(); - for (int i = 0; i < nodes.length; ++i) { - if(PROJECT_DATA_ITEM.equals(nodes[i].getName())){ - ICStorageElement element = nodes[i]; + for (ICStorageElement element : data.getChildren()) { + if(PROJECT_DATA_ITEM.equals(element.getName())){ String dataId = element.getAttribute(PROJECT_DATA_ID); if (dataId != null){ element.removeAttribute(PROJECT_DATA_ID); @@ -843,7 +836,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ fExtMap = (HashMap)other.fExtMap.clone(); for (Map.Entry entry : fExtMap.entrySet()) { CConfigExtensionReference refs[] = entry.getValue(); - refs = (CConfigExtensionReference[])refs.clone(); + refs = refs.clone(); for(int i = 0; i < refs.length; i++){ refs[i] = new CConfigExtensionReference(this, refs[i]); } @@ -921,8 +914,8 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ private Map createRefMap(ICConfigExtensionReference refs[]){ Map refsMap = new HashMap(refs.length); - for(int i = 0; i < refs.length; i++){ - refsMap.put(refs[i].getID(), refs[i]); + for (ICConfigExtensionReference ref : refs) { + refsMap.put(ref.getID(), ref); } return refsMap; } @@ -936,9 +929,8 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ if(fExtMap.size() != other.fExtMap.size()) return false; - for(Iterator iter = fExtMap.entrySet().iterator(); iter.hasNext();){ - Map.Entry entry = (Map.Entry)iter.next(); - ICConfigExtensionReference[] thisRefs = (ICConfigExtensionReference[])entry.getValue(); + for (Entry entry : fExtMap.entrySet()) { + ICConfigExtensionReference[] thisRefs = entry.getValue(); ICConfigExtensionReference[] otherRefs = other.fExtMap.get(entry.getKey()); if(otherRefs == null) return thisRefs.length == 0;