diff options
author | Andrew Ferguson | 2008-01-15 11:40:08 +0000 |
---|---|---|
committer | Andrew Ferguson | 2008-01-15 11:40:08 +0000 |
commit | 100ce28bcda9580c9f1f9f0a18b3244fb1be863a (patch) | |
tree | fb174c6c72eb9f8e274f54a6aaeb81e635d60d90 /core/org.eclipse.cdt.core/templateengine | |
parent | c18ff521d9d51731971360251fa77f5f70524fe2 (diff) | |
download | org.eclipse.cdt-100ce28bcda9580c9f1f9f0a18b3244fb1be863a.tar.gz org.eclipse.cdt-100ce28bcda9580c9f1f9f0a18b3244fb1be863a.tar.xz org.eclipse.cdt-100ce28bcda9580c9f1f9f0a18b3244fb1be863a.zip |
Apply patch for 215823 for Mark Espiritu, and fix generics warnings in template engine
Diffstat (limited to 'core/org.eclipse.cdt.core/templateengine')
14 files changed, 223 insertions, 282 deletions
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java index 40a5f7af983..97ce360ebd1 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,7 +14,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -35,8 +34,7 @@ import org.w3c.dom.Node; /** * Processes the shared default values. Updates and Persists new key - value (default) pair */ - -public class SharedDefaults extends HashMap/*<String, String>*/ { +public class SharedDefaults extends HashMap<String, String> { private static final long serialVersionUID = 0000000000L; public Document document; @@ -46,9 +44,9 @@ public class SharedDefaults extends HashMap/*<String, String>*/ { /** * HashMap's for persistence */ - private HashMap/*<String, String>*/ sharedDefaultsMap; - private HashMap/*<String, String>*/ persistDataMap; - private HashMap/*<String, String>*/ tableDataMap; + private HashMap<String, String> sharedDefaultsMap; + private HashMap<String, String> persistDataMap; + private HashMap<String, String> tableDataMap; /** * Two XML files here supports to provide consistent writing of data into @@ -96,9 +94,9 @@ public class SharedDefaults extends HashMap/*<String, String>*/ { */ public SharedDefaults() { - sharedDefaultsMap = new HashMap/*<String, String>*/(); - persistDataMap = new HashMap/*<String, String>*/(); - tableDataMap = new HashMap/*<String, String>*/(); + sharedDefaultsMap = new HashMap<String, String>(); + persistDataMap = new HashMap<String, String>(); + tableDataMap = new HashMap<String, String>(); // The conditional controls here is provided to have consistent // data storage in the file during System crash or @@ -129,15 +127,15 @@ public class SharedDefaults extends HashMap/*<String, String>*/ { if (length == 0) { parsedXML = createDefaultXMLFormat(parsedXML); } - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURL().openStream()); + document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURI().toURL().openStream()); } catch (Exception exp) { TemplateEngineUtil.log(exp); } - List/*<Element>*/ sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); + List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); int listSize = sharedElementList.size(); for (int i = 0; i < listSize; i++) { - Element xmlElement = (Element) sharedElementList.get(i); + Element xmlElement = sharedElementList.get(i); key = xmlElement.getAttribute(TemplateEngineHelper.ID); value = xmlElement.getAttribute(TemplateEngineHelper.VALUE); if (key != null && !key.trim().equals("")) { //$NON-NLS-1$ @@ -152,7 +150,7 @@ public class SharedDefaults extends HashMap/*<String, String>*/ { * @param sharedMap */ - public void updateShareDefaultsMap(Map/*<String, String>*/ sharedMap) { + public void updateShareDefaultsMap(Map<String, String> sharedMap) { sharedDefaultsMap.putAll(sharedMap); persistSharedValueMap(); } @@ -174,7 +172,7 @@ public class SharedDefaults extends HashMap/*<String, String>*/ { * @return HashMap */ - public Map/*<String, String>*/ getSharedDefaultsMap() { + public Map<String, String> getSharedDefaultsMap() { return sharedDefaultsMap; } @@ -198,20 +196,19 @@ public class SharedDefaults extends HashMap/*<String, String>*/ { * @param updateName * @param updateValue */ - public void updateToBackEndStorage(String updateName, String updateValue) { try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURL().openStream()); + document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURI().toURL().openStream()); } catch (Exception exp) { TemplateEngineUtil.log(exp); } persistDataMap.putAll(sharedDefaultsMap); - List/*<Element>*/ sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); + List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); int elementListSize = sharedElementList.size(); for (int i = 0; i < elementListSize; i++) { - Element xmlElement = (Element) sharedElementList.get(i); + Element xmlElement = sharedElementList.get(i); String name = xmlElement.getAttribute(TemplateEngineHelper.ID); if (updateName.equals(name)) { @@ -228,18 +225,17 @@ public class SharedDefaults extends HashMap/*<String, String>*/ { * @param deleteName */ public void deleteBackEndStorage(String[] deleteName) { - try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURL().openStream()); + document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURI().toURL().openStream()); } catch (Exception exp) { TemplateEngineUtil.log(exp); } - List/*<Element>*/ sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); + List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); int elementListSize = sharedElementList.size(); for (int i = 0; i < elementListSize; i++) { - Element xmlElement = (Element) sharedElementList.get(i); + Element xmlElement = sharedElementList.get(i); String name = xmlElement.getAttribute(TemplateEngineHelper.ID); for (int k = 0; k < deleteName.length; k++) { @@ -312,11 +308,10 @@ public class SharedDefaults extends HashMap/*<String, String>*/ { } Node rootElement = d.appendChild(d.createElement("SharedRoot")); //$NON-NLS-1$ - for(Iterator i = sharedDefaultsMap.keySet().iterator(); i.hasNext(); ) { - String key = (String) i.next(); + for(String key : sharedDefaultsMap.keySet()) { Element element = (Element) rootElement.appendChild(d.createElement("SharedProperty")); //$NON-NLS-1$ element.setAttribute(TemplateEngineHelper.ID, key); - element.setAttribute(TemplateEngineHelper.VALUE, (String) sharedDefaultsMap.get(key)); + element.setAttribute(TemplateEngineHelper.VALUE, sharedDefaultsMap.get(key)); } DOMSource domSource = new DOMSource(d); diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java index e4f6bb45aca..c703b6b7112 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,7 +13,6 @@ package org.eclipse.cdt.core.templateengine; import java.io.IOException; import java.net.URL; import java.text.MessageFormat; -import java.util.Collection; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; @@ -45,18 +44,18 @@ public class TemplateCore { private static final String ID = "id"; //$NON-NLS-1$ private static final String TYPE = "type"; //$NON-NLS-1$ - private static Map/*<TemplateInfo, Template>*/ templateCache = new HashMap/*<TemplateInfo, Template>*/(); + private static Map<TemplateInfo, TemplateCore> templateCache = new HashMap<TemplateInfo, TemplateCore>(); - public static final Comparator/*<Template>*/ TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR = new Comparator/*<Template>*/() { - public int compare(Object/*Template*/ t1, Object/*Template*/ t2) { - return String.CASE_INSENSITIVE_ORDER.compare(((TemplateCore)t1).getTemplateId(), ((TemplateCore)t2).getTemplateId()); + public static final Comparator<TemplateCore> TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR = new Comparator<TemplateCore>() { + public int compare(TemplateCore t1, TemplateCore t2) { + return String.CASE_INSENSITIVE_ORDER.compare(t1.getTemplateId(), t2.getTemplateId()); } }; private TemplateDescriptor templateDescriptor; - private Map/*<String, String>*/ valueStore; + private Map<String, String> valueStore; private TemplateInfo templateInfo; - private Set/*<String>*/ allMacrosInProcesses; + private Set<String> allMacrosInProcesses; private TemplateProcessHandler processHandler; private String description; private String label; @@ -80,7 +79,7 @@ public class TemplateCore { if(descriptorURL==null) throw new TemplateInitializationException("Unable to load project template. Location URL is null for "+templateInfo.getTemplateId()); //$NON-NLS-1$ templateDescriptor = new TemplateDescriptor(descriptorURL, templateInfo.getPluginId()); - valueStore = new ValueStore/*<String, String>*/(this); + valueStore = new ValueStore<String>(this); valueStore.putAll(templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement())); valueStore.putAll(TemplateEngine.getSharedDefaults()); valueStore.put("projectType", templateInfo.getProjectType()); //$NON-NLS-1$ @@ -95,9 +94,9 @@ public class TemplateCore { * Returns All Missing Macros In Processes. * @return Set */ - public Set/*<String>*/ getAllMissingMacrosInProcesses() { - Set/*<String>*/ set = new TreeSet/*<String>*/(allMacrosInProcesses); - for (Iterator iter = set.iterator(); iter.hasNext();) { + public Set<String> getAllMissingMacrosInProcesses() { + Set<String> set = new TreeSet<String>(allMacrosInProcesses); + for (Iterator<String> iter = set.iterator(); iter.hasNext();) { if (valueStore.get(iter.next()) != null) { iter.remove(); } @@ -109,7 +108,7 @@ public class TemplateCore { * return the ValueStore maintained by this Template. * @return ValueStore. */ - public Map/*<String, String>*/ getValueStore() { + public Map<String, String> getValueStore() { return valueStore; } @@ -119,7 +118,7 @@ public class TemplateCore { * * @return Vector of IDs. */ - public List/*<String>*/ getPersistTrueIDs() { + public List<String> getPersistTrueIDs() { return templateDescriptor.getPersistTrueIDs(); } @@ -229,7 +228,7 @@ public class TemplateCore { */ public static TemplateCore getTemplate(TemplateInfo templateInfo) throws TemplateInitializationException { synchronized (templateCache) { - TemplateCore template = (TemplateCore) templateCache.get(templateInfo); + TemplateCore template = templateCache.get(templateInfo); if (template == null) { template = new TemplateCore(templateInfo); templateCache.put(templateInfo, template); @@ -238,7 +237,7 @@ public class TemplateCore { } } - private static class ValueStore/*<K, V>*/ extends HashMap/*<K, V>*/ { + private static class ValueStore<K> extends HashMap<K,String> { private static final long serialVersionUID = -4523467333437879406L; private TemplateCore template; @@ -246,26 +245,24 @@ public class TemplateCore { this.template = template; } - public Object/*V*/ put(Object/*K*/ key, Object/*V*/ value) { - value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), (String)value); - Object/*V*/ v = super.put(key, value); + public String put(K key, String value) { + value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), value); + String v = super.put(key, value); template.setDirty(); return v; } - public void putAll(Map/*<? extends K, ? extends V>*/ map) { - Collection keys = map.keySet(); - for (Iterator iterator = keys.iterator(); iterator.hasNext();) { - Object key = iterator.next(); - Object value = map.get(key); - value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), (String) value); + public void putAll(Map<? extends K, ? extends String> map) { + for(K key : map.keySet()) { + String value = map.get(key); + value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), value); super.put(key, value); } template.setDirty(); } - public Object/*V*/ remove(Object key) { - Object/*V*/ v = super.remove(key); + public String remove(Object key) { + String v = super.remove(key); template.setDirty(); return v; } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java index 9ebb0910dc7..9f31d6de309 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,7 +41,7 @@ public class TemplateDescriptor { private Document document; private Element rootElement; - private List/*<String>*/ persistVector; + private List<String> persistVector; private String pluginId; /** @@ -61,7 +61,7 @@ public class TemplateDescriptor { throw new TemplateInitializationException(msg, se); } this.rootElement = document.getDocumentElement(); - this.persistVector = new ArrayList/*<String>*/(); + this.persistVector = new ArrayList<String>(); this.pluginId = pluginId; } @@ -71,12 +71,12 @@ public class TemplateDescriptor { * * @return default values with keys */ - public Map/*<String, String>*/ getTemplateDefaults(Element rootElement) { - Map/*<String, String>*/ templateDefaults = new HashMap/*<String, String>*/(); + public Map<String, String> getTemplateDefaults(Element rootElement) { + Map<String, String> templateDefaults = new HashMap<String, String>(); Element propertyGroupElement; - List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(rootElement); + List<Element> children = TemplateEngine.getChildrenOfElement(rootElement); for (int i = 0, l = children.size(); i < l; i++) { - propertyGroupElement = (Element) children.get(i); + propertyGroupElement = children.get(i); if (isNestedElement(propertyGroupElement)) { templateDefaults = getTemplateDefaults(propertyGroupElement); } @@ -93,12 +93,12 @@ public class TemplateDescriptor { private boolean isNestedElement(Element element){ boolean result=false; if (element!=null){ - List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(element); + List<Element> children = TemplateEngine.getChildrenOfElement(element); String elementName = element.getNodeName(); Element testElement; String testElementName = null; if (children.size() > 0){ - testElement = (Element) children.get(0); + testElement = children.get(0); testElementName=testElement.getNodeName(); } if(elementName.equals(testElementName)) @@ -116,14 +116,14 @@ public class TemplateDescriptor { * root element of type JDOM Element * @return list of property-group elements */ - public List getPropertyGroupList() { - List resultList = null; - List/*<Element>*/ list = new ArrayList/*<Element>*/(); + public List<Element> getPropertyGroupList() { + List<Element> resultList = null; + List<Element> list = new ArrayList<Element>(); resultList = list; if (rootElement != null) { - List/*<Element>*/ tempList = TemplateEngine.getChildrenOfElement(rootElement); + List<Element> tempList = TemplateEngine.getChildrenOfElement(rootElement); for (int i = 0, l = tempList.size(); i < l; i++) { - Element nextPropertyGroup = (Element) tempList.get(i); + Element nextPropertyGroup = tempList.get(i); String nextPGName = nextPropertyGroup.getNodeName(); if (nextPGName.equalsIgnoreCase(PROPERTY_GROUP)) { list.add(nextPropertyGroup); @@ -151,9 +151,9 @@ public class TemplateDescriptor { return rootElement; } else { String nextPGElementName = null; - List/*<Element>*/ propertyGroupList = TemplateEngine.getChildrenOfElement(rootElement); + List<Element> propertyGroupList = TemplateEngine.getChildrenOfElement(rootElement); for (int i = 0, l = propertyGroupList.size(); i < l; i++) { - Element nextPGElement = (Element) propertyGroupList.get(i); + Element nextPGElement = propertyGroupList.get(i); if (isNestedElement(nextPGElement)) nextPGElementName = nextPGElement.getNodeName(); if (nextPGElementName.equalsIgnoreCase(PROPERTY_GROUP) && isNestedElement(nextPGElement)) { @@ -173,10 +173,10 @@ public class TemplateDescriptor { * @param propertyGroupElement * traverse the complex property-group element */ - private void propertyElements(Map/*<String, String>*/ defaults, Element propertyGroupElement) { - List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(propertyGroupElement); + private void propertyElements(Map<String, String> defaults, Element propertyGroupElement) { + List<Element> children = TemplateEngine.getChildrenOfElement(propertyGroupElement); for (int i = 0, l = children.size(); i < l; i++) { - Element propertyElement = (Element) children.get(i); + Element propertyElement = children.get(i); String key = propertyElement.getAttribute(ID); String value = propertyElement.getAttribute(DEFAULT); if (key != null && !key.equals("")) { //$NON-NLS-1$ @@ -202,7 +202,7 @@ public class TemplateDescriptor { * * @return Vector. */ - public List/*<String>*/ getPersistTrueIDs() { + public List<String> getPersistTrueIDs() { return persistVector; } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java index 0b7437170d9..dd6b7cbd339 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -35,7 +34,7 @@ import org.w3c.dom.NodeList; /** * TemplateEngine is implemented as a Singleton. TemplateEngine is responsible for - * creating SharedDefaults and initializing the SharedDefaults. Template instances + * creating SharedDefaults and initialising the SharedDefaults. Template instances * are obtained from TemplateEngine. * * @since 4.0 @@ -53,13 +52,13 @@ public class TemplateEngine { /** * This is a Map <WizardID, TemplateInfo>. */ - private Map/*<String, List<TemplateInfo>>*/ templateInfoMap; + private Map<String, List<TemplateInfo>> templateInfoMap; /** * TemplateEngine constructor, create and initialise SharedDefaults. */ private TemplateEngine() { - templateInfoMap = new LinkedHashMap/*<String, List<TemplateInfo>>*/(); + templateInfoMap = new LinkedHashMap<String, List<TemplateInfo>>(); initializeTemplateInfoMap(); } @@ -68,7 +67,7 @@ public class TemplateEngine { */ public TemplateCore[] getTemplates() { TemplateInfo[] templateInfoArray = getTemplateInfos(); - List/*<TemplateCore>*/ tcores = new ArrayList/*<TemplateCore>*/(); + List<TemplateCore> tcores = new ArrayList<TemplateCore>(); for (int i=0; i<templateInfoArray.length; i++) { TemplateInfo info = templateInfoArray[i]; try { @@ -77,7 +76,7 @@ public class TemplateEngine { CCorePlugin.log(CCorePlugin.createStatus(e.getMessage(), e)); } } - return (TemplateCore[]) tcores.toArray(new TemplateCore[tcores.size()]); + return tcores.toArray(new TemplateCore[tcores.size()]); } /** @@ -120,7 +119,7 @@ public class TemplateEngine { */ public TemplateCore[] getTemplates(String projectType, String toolChain, String usageFilter) { TemplateInfo[] templateInfoArray = getTemplateInfos(projectType, toolChain, usageFilter); - List/*<Template>*/ templatesList = new ArrayList/*<Template>*/(); + List<TemplateCore> templatesList = new ArrayList<TemplateCore>(); for (int i=0; i<templateInfoArray.length; i++) { TemplateInfo info = templateInfoArray[i]; try { @@ -129,7 +128,7 @@ public class TemplateEngine { CCorePlugin.log(tie); } } - return (TemplateCore[]) templatesList.toArray(new TemplateCore[templatesList.size()]); + return templatesList.toArray(new TemplateCore[templatesList.size()]); } public TemplateCore[] getTemplates(String projectType, String toolChain) { @@ -157,7 +156,7 @@ public class TemplateEngine { * * @return */ - public static Map/*<String, String>*/ getSharedDefaults() { + public static Map<String, String> getSharedDefaults() { return SharedDefaults.getInstance().getSharedDefaultsMap(); } @@ -173,11 +172,9 @@ public class TemplateEngine { * @param aSharedValue */ public void updateSharedDefaults(TemplateCore template) { - Map/*<String, String>*/ tobePersisted = new HashMap/*<String, String>*/(); - Map/*<String, String>*/ valueStore = template.getValueStore(); - - for (Iterator i = template.getPersistTrueIDs().iterator(); i.hasNext();) { - String key = (String) i.next(); + Map<String, String> tobePersisted = new HashMap<String, String>(); + Map<String, String> valueStore = template.getValueStore(); + for(String key : template.getPersistTrueIDs()) { tobePersisted.put(key, valueStore.get(key)); } SharedDefaults.getInstance().updateShareDefaultsMap(tobePersisted); @@ -236,7 +233,7 @@ public class TemplateEngine { } IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN); - Set toolChainIdSet = new LinkedHashSet(); + Set<String> toolChainIdSet = new LinkedHashSet<String>(); for (int k=0; k < toolChainConfigs.length; k++) { toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID)); } @@ -245,9 +242,9 @@ public class TemplateEngine { pluginId, toolChainIdSet, extraPagesProvider, isCategory); if (!templateInfoMap.containsKey(projectType)) { - templateInfoMap.put(projectType, new ArrayList/*<TemplateInfo>*/()); + templateInfoMap.put(projectType, new ArrayList<TemplateInfo>()); } - ((List/*<TemplateInfo>*/)templateInfoMap.get(projectType)).add(templateInfo); + (templateInfoMap.get(projectType)).add(templateInfo); } } // Check for tool Chains added to the templates outside template info definition @@ -267,7 +264,7 @@ public class TemplateEngine { templateId = config.getAttribute(TemplateEngineHelper.ID); IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN); - Set toolChainIdSet = new LinkedHashSet(); + Set<String> toolChainIdSet = new LinkedHashSet<String>(); for (int k=0; k < toolChainConfigs.length; k++) { toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID)); } @@ -295,12 +292,11 @@ public class TemplateEngine { * @return an array of TemplateInfo objects (never null) */ public TemplateInfo[] getTemplateInfos(String projectType, String toolChain, String usageFilter) { - List/*<TemplateInfo>*/ templateInfoList = (List/*<TemplateInfo*/) templateInfoMap.get(projectType.trim()); - List/*<TemplateInfo>*/ matchedTemplateInfoList = new ArrayList/*<TemplateInfo>*/(); + List<TemplateInfo> templateInfoList = templateInfoMap.get(projectType.trim()); + List<TemplateInfo> matchedTemplateInfoList = new ArrayList<TemplateInfo>(); if (templateInfoList != null) { - for (Iterator i = templateInfoList.iterator(); i.hasNext(); ) { - TemplateInfo templateInfo = (TemplateInfo) i.next(); + for(TemplateInfo templateInfo : templateInfoList) { String filterPattern = templateInfo.getFilterPattern(); String[] toolChains = templateInfo.getToolChainIds(); @@ -324,7 +320,7 @@ public class TemplateEngine { } } } - return (TemplateInfo[]) matchedTemplateInfoList.toArray(new TemplateInfo[matchedTemplateInfoList.size()]); + return matchedTemplateInfoList.toArray(new TemplateInfo[matchedTemplateInfoList.size()]); } public TemplateInfo[] getTemplateInfos(String projectType, String toolChain) { @@ -340,12 +336,11 @@ public class TemplateEngine { * @return */ public TemplateInfo[] getTemplateInfos() { - List/*<TemplateInfo>*/ infoList = new ArrayList/*<TemplateInfo>*/(); - for (Iterator i = templateInfoMap.values().iterator(); i.hasNext();) { - infoList.addAll((List/*<TemplateInfo>*/)i.next()); + List<TemplateInfo> infoList = new ArrayList<TemplateInfo>(); + for(List<TemplateInfo> infos : templateInfoMap.values()) { + infoList.addAll(infos); } - - return (TemplateInfo[]) infoList.toArray(new TemplateInfo[infoList.size()]); + return infoList.toArray(new TemplateInfo[infoList.size()]); } @@ -354,7 +349,7 @@ public class TemplateEngine { * * @return */ - public Map/*<String, List<TemplateInfo>>*/ getTemplateInfoMap() { + public Map<String, List<TemplateInfo>> getTemplateInfoMap() { return templateInfoMap; } @@ -375,13 +370,13 @@ public class TemplateEngine { * * @since 4.0 */ - public static List/*<Element>*/ getChildrenOfElement(Element element) { - List/*<Element>*/ list = new ArrayList/*<Element>*/(); + public static List<Element> getChildrenOfElement(Element element) { + List<Element> list = new ArrayList<Element>(); NodeList children = element.getChildNodes(); for (int i = 0, l = children.getLength(); i < l; i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { - list.add(child); + list.add((Element) child); } } return list; @@ -396,13 +391,13 @@ public class TemplateEngine { * * @since 4.0 */ - public static List/*<Element>*/ getChildrenOfElementByTag(Element element, String tag) { - List/*<Element>*/ list = new ArrayList/*<Element>*/(); + public static List<Element> getChildrenOfElementByTag(Element element, String tag) { + List<Element> list = new ArrayList<Element>(); NodeList children = element.getChildNodes(); for (int i = 0, l = children.getLength(); i < l; i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(tag)) { - list.add(child); + list.add((Element) child); } } return list; diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java index 6802f700941..3dccdb3a2ab 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,7 +11,6 @@ package org.eclipse.cdt.core.templateengine; import java.lang.reflect.InvocationTargetException; -import java.util.Iterator; import java.util.List; import org.eclipse.cdt.core.CCorePlugin; @@ -22,7 +21,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; public class TemplateEngineUtil { - public static void log(Throwable t) { if (t == null) { return; @@ -34,10 +32,9 @@ public class TemplateEngineUtil { ResourcesPlugin.getPlugin().getLog().log(((CoreException) t).getStatus()); } if (t instanceof ProcessFailureException) { do { - List/*<IStatus>*/ statuses = ((ProcessFailureException) t).getStatuses(); + List<IStatus> statuses = ((ProcessFailureException) t).getStatuses(); if (statuses != null) { - for(Iterator i = statuses.iterator(); i.hasNext(); ) { - IStatus status = (IStatus) i.next(); + for(IStatus status : statuses) { ResourcesPlugin.getPlugin().getLog().log(status); } } @@ -47,5 +44,4 @@ public class TemplateEngineUtil { ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, t.getMessage() == null ? t.toString() : t.getMessage() , t)); } } - } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java index 98d5df7e87c..0db3de1389a 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,12 +21,12 @@ public class TemplateInfo { private String filterPattern; private String templatePath; private String pluginId; - private Set toolChainIdSet; - private Object pagesProvider; /* IPagesAfterTemplateSelectionProvider */ + private Set<String> toolChainIdSet; + private Object pagesProvider; /*IPagesAfterTemplateSelectionProvider*/ private boolean isCategory; private String icon; private String templateId; - private List configs; + private List<?> configs; /*This seems to be used for storing build-system specific configurations*/ /** * @@ -40,7 +40,7 @@ public class TemplateInfo { * @param isCategory */ public TemplateInfo(String templateId, String projectTypeId, String filterPattern, String templatePath, - String pluginId, Set toolChainIdSet, + String pluginId, Set<String> toolChainIdSet, Object extraPagesProvider, boolean isCategory) { this.templateId = templateId; this.filterPattern = filterPattern; @@ -99,18 +99,18 @@ public class TemplateInfo { * @return the toolChainIds */ public String[] getToolChainIds() { - return (String[]) toolChainIdSet.toArray(new String[toolChainIdSet.size()]); + return toolChainIdSet.toArray(new String[toolChainIdSet.size()]); } - public void setToolChainSet(Set toolChainIdSet) { + public void setToolChainSet(Set<String> toolChainIdSet) { this.toolChainIdSet = toolChainIdSet; } - public List getConfigurations() { + public List<?> getConfigurations() { return configs; } - public void setConfigurations(List configs) { + public void setConfigurations(List<?> configs) { this.configs = configs; } @@ -144,7 +144,6 @@ public class TemplateInfo { } /* - * (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java index f3f59406f48..9a13faaeceb 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,7 +13,6 @@ package org.eclipse.cdt.core.templateengine.process; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -40,12 +39,12 @@ import org.w3c.dom.Element; public class ConditionalProcessGroup { private TemplateCore template; - private Set/*<String>*/ macros; + private Set<String> macros; private String conditionString; private String lValue; private String rValue; private Operator op; - private List/*<Process>*/ processes; + private List<Process> processes; private String id; /** @@ -106,7 +105,7 @@ public class ConditionalProcessGroup { private void collectMacros(String value) { if (value != null) { if (macros == null) { - macros = new HashSet/*<String>*/(); + macros = new HashSet<String>(); } macros.addAll(ProcessHelper.getReplaceKeys(value)); } @@ -125,15 +124,15 @@ public class ConditionalProcessGroup { } /** - * Creates the Proccess from the process Elements. + * Creates the Process from the process Elements. * @param template * @param processElements */ - private void createProcessObjects(TemplateCore template, List/*<Element>*/ processElements) { + private void createProcessObjects(TemplateCore template, List<Element> processElements) { this.template = template; - this.processes = new ArrayList/*<Process>*/(processElements.size()); + this.processes = new ArrayList<Process>(processElements.size()); for (int j = 0, l = processElements.size(); j < l; j++) { - Element processElem = (Element) processElements.get(j); + Element processElem = processElements.get(j); if (processElem.getNodeName().equals(TemplateDescriptor.PROCESS)) { String processId = id + "--> Process " + (j + 1) + " (" + processElem.getAttribute(Process.ELEM_TYPE) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ processes.add(new Process(template, processElem, processId)); @@ -153,8 +152,7 @@ public class ConditionalProcessGroup { * @return boolean, as true if the Processes are ready to process */ private boolean areProcessesReady() { - for(Iterator i = processes.iterator(); i.hasNext(); ) { - Process process = (Process) i.next(); + for(Process process : processes) { if (!process.isReadyToProcess()) { return false; } @@ -168,9 +166,8 @@ public class ConditionalProcessGroup { */ private boolean areMacrosForConditionEvaluationExpandable() { if (macros != null) { - Map/*<String, String>*/ valueStore = template.getValueStore(); - for(Iterator i = macros.iterator(); i.hasNext(); ) { - String value = (String) i.next(); + Map<String, String> valueStore = template.getValueStore(); + for(String value : macros) { if (valueStore.get(value) == null) { return false; } @@ -190,13 +187,12 @@ public class ConditionalProcessGroup { if (!areMacrosForConditionEvaluationExpandable()) { return false; } - Map/*<String, String>*/ valueStore = template.getValueStore(); + Map<String, String> valueStore = template.getValueStore(); String lValue = this.lValue; String rValue = this.rValue; - for(Iterator i = macros.iterator(); i.hasNext(); ) { - String value = (String) i.next(); - lValue = lValue.replaceAll(ProcessHelper.START_PATTERN + value + ProcessHelper.END_PATTERN, (String) valueStore.get(value)); - rValue = rValue.replaceAll(ProcessHelper.START_PATTERN + value + ProcessHelper.END_PATTERN, (String) valueStore.get(value)); + for(String value : macros) { + lValue = lValue.replaceAll(ProcessHelper.START_PATTERN + value + ProcessHelper.END_PATTERN, valueStore.get(value)); + rValue = rValue.replaceAll(ProcessHelper.START_PATTERN + value + ProcessHelper.END_PATTERN, valueStore.get(value)); } if(op.equals(Operator.EQUALS)) { return lValue.equals(rValue); @@ -213,18 +209,17 @@ public class ConditionalProcessGroup { * @return List contains the IStatus. * @throws ProcessFailureException */ - public List/*<IStatus>*/ process(IProgressMonitor monitor) throws ProcessFailureException { + public List<IStatus> process(IProgressMonitor monitor) throws ProcessFailureException { if (!areMacrosForConditionEvaluationExpandable()) { throw new ProcessFailureException(getUnexpandableMacroMessage()); } if (!isConditionValueTrue()) { - List/*<IStatus>*/ statuses = new ArrayList/*<IStatus>*/(1); + List<IStatus> statuses = new ArrayList<IStatus>(1); statuses.add(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.INFO, TemplateEngineMessages.getString("ConditionalProcessGroup.notExecuting") + id, null)); //$NON-NLS-1$ return statuses; } - List/*<IStatus>*/ statuses = new ArrayList/*<IStatus>*/(processes.size()); - for(Iterator i = processes.iterator(); i.hasNext(); ) { - Process process = (Process) i.next(); + List<IStatus> statuses = new ArrayList<IStatus>(processes.size()); + for(Process process : processes) { try { statuses.add(process.process(monitor)); } catch (ProcessFailureException e) { @@ -240,9 +235,8 @@ public class ConditionalProcessGroup { */ private String getUnexpandableMacroMessage() { if (macros != null) { - Map/*<String, String>*/ valueStore = template.getValueStore(); - for(Iterator i = macros.iterator(); i.hasNext(); ) { - String value = (String) i.next(); + Map<String, String> valueStore = template.getValueStore(); + for(String value : macros) { if (valueStore.get(value) == null) { return TemplateEngineMessages.getString("ConditionalProcessGroup.unexpandableMacro") + value; //$NON-NLS-1$ } @@ -255,7 +249,7 @@ public class ConditionalProcessGroup { * Returns the Macros as a Set. * @return Set, contains macros */ - public Set/*<String>*/ getMacros() { + public Set<String> getMacros() { return macros; } @@ -263,18 +257,17 @@ public class ConditionalProcessGroup { * Returns All Macros as a Set. * @return Set, contains macros */ - public Set/*<String>*/ getAllMacros() { - Set/*<String>*/ set = null; + public Set<String> getAllMacros() { + Set<String> set = null; if (macros != null) { - set = new HashSet/*<String>*/(); + set = new HashSet<String>(); set.addAll(macros); } - for(Iterator i = processes.iterator(); i.hasNext(); ) { - Process process = (Process) i.next(); - Set/*<String>*/ subSet = process.getMacros(); + for(Process process : processes) { + Set<String> subSet = process.getMacros(); if (subSet != null) { if (set == null) { - set = new HashSet/*<String>*/(); + set = new HashSet<String>(); } set.addAll(subSet); } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/Process.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/Process.java index cad1c6e38a5..d9d612d9ae9 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/Process.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/Process.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -61,14 +61,14 @@ public class Process { * @param element */ private void buildArgs(TemplateCore template, Element element) { - List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(element); + List<Element> children = TemplateEngine.getChildrenOfElement(element); ProcessParameter[] params = processRunner.getProcessParameters(); - List/*<ProcessArgument>*/ list = new ArrayList/*<ProcessArgument>*/(params.length); + List<ProcessArgument> list = new ArrayList<ProcessArgument>(params.length); int childIndex = 0; for(int i=0; i<params.length; i++) { ProcessParameter param = params[i]; boolean childrenRemain = childIndex < children.size(); - Element child = (Element) (childrenRemain ? children.get(childIndex) : null); + Element child = (childrenRemain ? children.get(childIndex) : null); if (param.isExternal() && (!childrenRemain || !param.getName().equals(child.getAttribute(ProcessArgument.ELEM_NAME)))) { list.add(new ProcessArgument(template, param)); } else if (childrenRemain) { @@ -77,9 +77,9 @@ public class Process { } } while (childIndex < children.size()) { - list.add(new ProcessArgument(template, (Element) children.get(childIndex++))); + list.add(new ProcessArgument(template, children.get(childIndex++))); } - args = (ProcessArgument[]) list.toArray(new ProcessArgument[list.size()]); + args = list.toArray(new ProcessArgument[list.size()]); } /** @@ -178,15 +178,15 @@ public class Process { * Returns the Macros. * @return */ - public Set/*<String>*/ getMacros() { - Set/*<String>*/ set = null; + public Set<String> getMacros() { + Set<String> set = null; if (args != null) { for(int i=0; i<args.length; i++) { ProcessArgument arg = args[i]; - Set/*<String>*/ subSet = arg.getMacros(); + Set<String> subSet = arg.getMacros(); if (subSet != null) { if (set == null) { - set = new HashSet/*<String>*/(); + set = new HashSet<String>(); } set.addAll(subSet); } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessArgument.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessArgument.java index f65a0e67afc..987410f1935 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessArgument.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessArgument.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,16 +11,13 @@ package org.eclipse.cdt.core.templateengine.process; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; - import org.eclipse.cdt.core.templateengine.TemplateCore; import org.eclipse.cdt.core.templateengine.TemplateEngine; import org.w3c.dom.Element; - /** * ProcessArgument class responsible for constructing process Arguments by taking info from Template. */ @@ -47,7 +44,7 @@ public class ProcessArgument { private TemplateCore template; - private Set/*<String>*/ macros; + private Set<String> macros; private boolean resolved; private ProcessParameter externalParam; @@ -66,21 +63,21 @@ public class ProcessArgument { collectMacros(simpleValue); } else if (elemName.equals(ELEM_SIMPLE_ARRAY)) { type = ProcessParameter.SIMPLE_ARRAY; - List/*<Element>*/ valueElements = TemplateEngine.getChildrenOfElementByTag(elem, ELEM_ELEMENT); + List<Element> valueElements = TemplateEngine.getChildrenOfElementByTag(elem, ELEM_ELEMENT); simpleValueArray = new String[valueElements.size()]; for (int i = 0, l = valueElements.size(); i < l; i++) { - simpleValueArray[i] = ((Element)valueElements.get(i)).getAttribute(ELEM_VALUE); + simpleValueArray[i] = (valueElements.get(i)).getAttribute(ELEM_VALUE); collectMacros(simpleValueArray[i]); } } else if (elemName.equals(ELEM_COMPLEX)) { type = ProcessParameter.COMPLEX; - List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(elem); + List<Element> children = TemplateEngine.getChildrenOfElement(elem); complexValue = new ProcessArgument[children.size()]; for (int i = 0, l = children.size(); i < l; i++) { - complexValue[i] = new ProcessArgument(template, (Element) children.get(i)); - Set/*<String>*/ subMacros = complexValue[i].getMacros(); + complexValue[i] = new ProcessArgument(template, children.get(i)); + Set<String> subMacros = complexValue[i].getMacros(); if (macros == null) { - macros = new HashSet/*<String>*/(); + macros = new HashSet<String>(); } if (subMacros != null) { macros.addAll(subMacros); @@ -88,18 +85,18 @@ public class ProcessArgument { } } else if (elemName.equals(ELEM_COMPLEX_ARRAY)) { type = ProcessParameter.COMPLEX_ARRAY; - List/*<Element>*/ valueElements = TemplateEngine.getChildrenOfElementByTag(elem, ELEM_ELEMENT); + List<Element> valueElements = TemplateEngine.getChildrenOfElementByTag(elem, ELEM_ELEMENT); complexValueArray = new ProcessArgument[valueElements.size()][]; for (int i = 0, l = valueElements.size(); i < l; i++) { - List/*<Element>*/ children = TemplateEngine.getChildrenOfElement((Element)valueElements.get(i)); + List<Element> children = TemplateEngine.getChildrenOfElement(valueElements.get(i)); complexValueArray[i] = new ProcessArgument[children.size()]; for (int j = 0, l2 = children.size(); j < l2; j++) { - complexValueArray[i][j] = new ProcessArgument(template, (Element) children.get(j)); - Set/*<String>*/ subMacros = complexValueArray[i][j].getMacros(); + complexValueArray[i][j] = new ProcessArgument(template, children.get(j)); + Set<String> subMacros = complexValueArray[i][j].getMacros(); if (subMacros != null) { if (macros == null) { - macros = new HashSet/*<String>*/(); + macros = new HashSet<String>(); } macros.addAll(subMacros); } @@ -116,7 +113,7 @@ public class ProcessArgument { this.template = template; name = param.getName(); type = param.getType(); - macros = new HashSet/*<String>*/(); + macros = new HashSet<String>(); macros.add(name); simpleValue = ProcessHelper.getReplaceMarker(name); this.externalParam = param; @@ -131,7 +128,7 @@ public class ProcessArgument { return; } if (macros == null) { - macros = new HashSet/*<String>*/(); + macros = new HashSet<String>(); } macros.addAll(ProcessHelper.getReplaceKeys(value)); } @@ -242,9 +239,8 @@ public class ProcessArgument { if (macros == null || macros.size() == 0) { return true; } - Map/*<String, String>*/ valueStore = template.getValueStore(); - for(Iterator i = macros.iterator(); i.hasNext(); ) { - String macro = (String) i.next(); + Map<String, String> valueStore = template.getValueStore(); + for(String macro : macros) { if (valueStore.get(macro) == null) { return false; } @@ -283,9 +279,8 @@ public class ProcessArgument { if (macros == null || macros.size() == 0) { return null; } - Map/*<String, String>*/ valueStore = template.getValueStore(); - for(Iterator i = macros.iterator(); i.hasNext(); ) { - String macro = (String) i.next(); + Map<String, String> valueStore = template.getValueStore(); + for(String macro : macros) { if (valueStore.get(macro) == null) { return macro; } @@ -319,7 +314,7 @@ public class ProcessArgument { * Returns the Macros as Set. * @return Set, contains the Macros. */ - public Set/*<String>*/ getMacros() { + public Set<String> getMacros() { return macros; } @@ -328,11 +323,11 @@ public class ProcessArgument { * */ public void resolve() { - Map/*<String, String>*/ valueStore = template.getValueStore(); + Map<String, String> valueStore = template.getValueStore(); switch (type) { case ProcessParameter.SIMPLE: if (externalParam != null) { - resolvedSimpleValue = (String) template.getValueStore().get(name); + resolvedSimpleValue = template.getValueStore().get(name); } else { resolvedSimpleValue = simpleValue; if (macros != null && !macros.isEmpty()) { diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessFailureException.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessFailureException.java index 4c874d9e6e9..f20f078499b 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessFailureException.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessFailureException.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,12 +12,14 @@ package org.eclipse.cdt.core.templateengine.process; import java.util.List; +import org.eclipse.core.runtime.IStatus; + public class ProcessFailureException extends Exception { private static final long serialVersionUID = 1766239661286962870L; - private List/*<IStatus>*/ statuses; + private List<IStatus> statuses; /** - * Constructor based on the msg. + * Constructor based on the message. * @param msg */ public ProcessFailureException(String msg) { @@ -25,7 +27,7 @@ public class ProcessFailureException extends Exception { } /** - * Constructor based on the msg and cause. + * Constructor based on the message and cause. * @param cause */ public ProcessFailureException(Throwable cause) { @@ -33,7 +35,7 @@ public class ProcessFailureException extends Exception { } /** - * Constructor based on the msg and cause. + * Constructor based on the message and cause. * @param msg * @param cause */ @@ -42,16 +44,16 @@ public class ProcessFailureException extends Exception { } /** - * Constructor based on the msg and causes. + * Constructor based on the message and causes. * @param msg * @param statuses */ - public ProcessFailureException(String msg, List/*<IStatus>*/ statuses) { + public ProcessFailureException(String msg, List<IStatus> statuses) { super(msg); this.statuses = statuses; } - public ProcessFailureException(String msg, Throwable cause, List/*<IStatus>*/ statuses) { + public ProcessFailureException(String msg, Throwable cause, List<IStatus> statuses) { super(msg, cause); this.statuses = statuses; } @@ -60,7 +62,7 @@ public class ProcessFailureException extends Exception { * Returns the Statuses. * @return List, contains the IStatus. */ - public List/*<IStatus>*/ getStatuses() { + public List<IStatus> getStatuses() { return statuses; } } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java index d8d7f0d14ea..2a5bd44b61c 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Bala Torati (Symbian) - Initial API and implementation + * Mark Espiritu (VastSystems) - bug 215283 *******************************************************************************/ package org.eclipse.cdt.core.templateengine.process; @@ -71,24 +72,18 @@ public class ProcessHelper { * $(item), vector contains 'item' as one item. , ) is the end pattern. * * @param str, - * A given string may contains replace markers. - * @param pattern - * start pattern (e.g., $( is the start pattern) - * @param endPat - * end pattern (e.g., ) is the end pattern) - * @return a set of all replace marker strings. - * + * A given string possibly containing markers. + * @return the set of names occurring within markers * @since 4.0 */ - public static Set/*<String>*/ getReplaceKeys(String str) { - int start = 0; - int end = 0; - Set/*<String>*/ replaceStrings = new HashSet/*<String>*/(); + public static Set<String> getReplaceKeys(String str) { + Set<String> replaceStrings = new HashSet<String>(); + int start= 0, end= 0; while ((start = str.indexOf(START_PATTERN, start)) >= 0) { end = str.indexOf(END_PATTERN, start); if (end != -1) { replaceStrings.add(str.substring(start + START_PATTERN.length(), end)); - start = end + START_PATTERN.length(); + start = end + END_PATTERN.length(); } else start++; } @@ -177,7 +172,7 @@ public class ProcessHelper { /** - * Returns the Macro Value after Exanding the Macros. + * Returns the Macro Value after expanding the Macros. * @param string * @param macros * @param valueStore @@ -185,41 +180,19 @@ public class ProcessHelper { * * @since 4.0 */ - public static String getValueAfterExpandingMacros(String string, Set/*<String>*/ macros, Map/*<String, String>*/ valueStore) { - for (Iterator i = macros.iterator(); i.hasNext();) { - String key = (String) i.next(); - String value = (String) valueStore.get(key); + public static String getValueAfterExpandingMacros(String string, Set<String> macros, Map<String, String> valueStore) { + for (Iterator<String> i = macros.iterator(); i.hasNext();) { + String key = i.next(); + String value = valueStore.get(key); if (value != null) { - string = replace(START_PATTERN + key + END_PATTERN, value, string); + string = string.replace(START_PATTERN + key + END_PATTERN, value); } } return string; } - - /** - * This is equivalent to Java 5.0 version of - * String.replace(CharSequence target, CharSequence replacement) method. - * @since 4.0 - */ - private static String replace(String target, String replacement, String string) { - try { - StringBuffer stringBuffer = new StringBuffer(string); - - int index = string.length(); - int offset = target.length(); - - while ((index=string.lastIndexOf(target, index-1)) != -1) { - stringBuffer.replace(index, index+offset, replacement); - } - - return stringBuffer.toString(); - } catch (StringIndexOutOfBoundsException e) { - return string; - } - } /** - * Consturct and Return the Replacment Markers + * Construct and return the replacement markers * after adding the patterns to the macro. * @param macro * @return diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunnerFactory.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunnerFactory.java index fa9c2f4a62d..fd465c4fc46 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunnerFactory.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunnerFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,7 +23,6 @@ import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; - /** * Factory class for creating the Process Runners. */ @@ -37,18 +36,18 @@ public class ProcessRunnerFactory { instance = new ProcessRunnerFactory(); } - private Map/*<String, ProcessRunner>*/ processRunnerMap; + private Map<String, ProcessRunner> processRunnerMap; private ProcessRunnerFactory() { initializeProcessRunners(); } /** - * initializes the process runners. + * Initialises the process runners. * */ private synchronized void initializeProcessRunners() { - processRunnerMap = new HashMap/*<String, ProcessRunner>*/(); + processRunnerMap = new HashMap<String, ProcessRunner>(); IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_PROCESSES); IExtension[] extensions = point.getExtensions(); for(int i=0; i<extensions.length; i++) { @@ -61,21 +60,20 @@ public class ProcessRunnerFactory { if (processType != null) { try { ProcessRunner runner = (ProcessRunner) element.createExecutableExtension(ELEM_PROCESS_RUNNER); - List/*<ProcessParameter>*/ params = null; + List<ProcessParameter> params = null; IConfigurationElement[] elementChildren = element.getChildren(); for (int k=0; k<elementChildren.length; k++) { if (params == null) { - params = new ArrayList/*<ProcessParameter>*/(); + params = new ArrayList<ProcessParameter>(); } params.add(new ProcessParameter(elementChildren[k])); } if (params != null) { - runner.setProcessParameters((ProcessParameter[])params.toArray(new ProcessParameter[params.size()])); + runner.setProcessParameters(params.toArray(new ProcessParameter[params.size()])); } processRunnerMap.put(prefix + processType, runner); } catch (CoreException e) { TemplateEngineUtil.log(e); -// TemplateEngine.showError(e.getMessage(), e); } } } @@ -83,7 +81,7 @@ public class ProcessRunnerFactory { } /** - * Process Runners Factory instace. + * Process Runners Factory instance. * @return */ public static ProcessRunnerFactory getDefault() { @@ -96,6 +94,6 @@ public class ProcessRunnerFactory { * @return */ public ProcessRunner getProcessRunner(String processType) { - return (ProcessRunner) processRunnerMap.get(processType); + return processRunnerMap.get(processType); } } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java index 6aab5776ac3..e2bce626344 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,6 @@ package org.eclipse.cdt.core.templateengine.process; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -30,7 +29,7 @@ import org.w3c.dom.Element; public class TemplateProcessHandler { private TemplateCore template; - private List/*<ConditionalProcessGroup>*/ conditionalProcessGroupList; + private List<ConditionalProcessGroup> conditionalProcessGroupList; public TemplateProcessHandler(TemplateCore template) { this.template = template; @@ -38,20 +37,19 @@ public class TemplateProcessHandler { } /** - * initializes the template descriptor and Root Elements. - * + * Initialises the template descriptor and Root Elements. */ private void initialize() { TemplateDescriptor desc = template.getTemplateDescriptor(); Element root = desc.getRootElement(); - conditionalProcessGroupList = new ArrayList/*<ConditionalProcessGroup>*/(); - List/*<Element>*/ nodeList = TemplateEngine.getChildrenOfElementByTag(root, TemplateDescriptor.IF); + conditionalProcessGroupList = new ArrayList<ConditionalProcessGroup>(); + List<Element> nodeList = TemplateEngine.getChildrenOfElementByTag(root, TemplateDescriptor.IF); for (int j = 0, l = nodeList.size(); j < l; j++) { - conditionalProcessGroupList.add(new ConditionalProcessGroup(template, (Element) nodeList.get(j), j + 1)); + conditionalProcessGroupList.add(new ConditionalProcessGroup(template, nodeList.get(j), j + 1)); } //Collect all free-hanging processes in one ConditionalProcessGroup object with condition true. nodeList = TemplateEngine.getChildrenOfElementByTag(root, TemplateDescriptor.PROCESS); - conditionalProcessGroupList.add(new ConditionalProcessGroup(template, (Element[]) nodeList.toArray(new Element[nodeList.size()]))); + conditionalProcessGroupList.add(new ConditionalProcessGroup(template, nodeList.toArray(new Element[nodeList.size()]))); } /** @@ -61,25 +59,25 @@ public class TemplateProcessHandler { * @throws ProcessFailureException */ public IStatus[] processAll(IProgressMonitor monitor) throws ProcessFailureException { - List/*<IStatus>*/ allStatuses = new ArrayList/*<IStatus>*/(); - for (Iterator i = conditionalProcessGroupList.iterator(); i.hasNext();) { + List<IStatus> allStatuses = new ArrayList<IStatus>(); + for(ConditionalProcessGroup cpg : conditionalProcessGroupList) { try { - allStatuses.addAll(((ConditionalProcessGroup)i.next()).process(monitor)); + allStatuses.addAll(cpg.process(monitor)); } catch (ProcessFailureException e) { throw new ProcessFailureException(e.getMessage(), e, allStatuses); } } - return (IStatus[]) allStatuses.toArray(new IStatus[allStatuses.size()]); + return allStatuses.toArray(new IStatus[allStatuses.size()]); } /** * Returns all macros * @return */ - public Set/*<String>*/ getAllMacros() { - Set/*<String>*/ set = new HashSet/*<String>*/(); - for (Iterator i = conditionalProcessGroupList.iterator(); i.hasNext();) { - Set/*<String>*/ subSet = ((ConditionalProcessGroup)i.next()).getAllMacros(); + public Set<String> getAllMacros() { + Set<String> set = new HashSet<String>(); + for(ConditionalProcessGroup cpg : conditionalProcessGroupList) { + Set<String> subSet = cpg.getAllMacros(); if (subSet != null) { set.addAll(subSet); } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/CreateSourceFolder.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/CreateSourceFolder.java index 102646ceed2..54cccb98312 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/CreateSourceFolder.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/CreateSourceFolder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Symbian Software Limited and others. + * Copyright (c) 2007, 2008 Symbian Software Limited and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -104,14 +104,14 @@ public class CreateSourceFolder extends ProcessRunner { for(int i=0; i < configs.length; i++){ ICConfigurationDescription config = configs[i]; ICSourceEntry[] entries = config.getSourceEntries(); - Set set = new HashSet(); + Set<ICSourceEntry> set = new HashSet<ICSourceEntry>(); for (int j=0; j < entries.length; j++) { if(new Path(entries[j].getValue()).segmentCount() == 1) continue; set.add(entries[j]); } set.add(newEntry); - config.setSourceEntries((ICSourceEntry[])set.toArray(new ICSourceEntry[set.size()])); + config.setSourceEntries(set.toArray(new ICSourceEntry[set.size()])); } CCorePlugin.getDefault().setProjectDescription(projectHandle, description, false, monitor); @@ -126,7 +126,7 @@ public class CreateSourceFolder extends ProcessRunner { */ private void createFolder(String targetPath, IProgressMonitor monitor, IPath projPath, ICProject cProject) throws CModelException { IPathEntry[] entries = cProject.getRawPathEntries(); - List/*<IPathEntry>*/ newEntries = new ArrayList/*<IPathEntry>*/(entries.length + 1); + List<IPathEntry> newEntries = new ArrayList<IPathEntry>(entries.length + 1); int projectEntryIndex= -1; IPath path = projPath.append(targetPath); @@ -151,7 +151,7 @@ public class CreateSourceFolder extends ProcessRunner { newEntries.add(CoreModel.newSourceEntry(path)); } - cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), monitor); + cProject.setRawPathEntries(newEntries.toArray(new IPathEntry[newEntries.size()]), monitor); } } |