Mercurial > hg > thermostat-tools-eclipse
changeset 41:2d3178148dd6
Fixed getExtension(String name). UNTESTED
author | Andriy Petrus <apetrus@redhat.com> |
---|---|
date | Fri, 06 Dec 2013 17:48:50 -0500 |
parents | 430763b455c1 |
children | 89834669ad98 |
files | src/com/redhat/thermostat/plugin/eclipse/model/PluginModel.java |
diffstat | 1 files changed, 11 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/redhat/thermostat/plugin/eclipse/model/PluginModel.java Fri Dec 06 13:56:21 2013 -0500 +++ b/src/com/redhat/thermostat/plugin/eclipse/model/PluginModel.java Fri Dec 06 17:48:50 2013 -0500 @@ -348,7 +348,7 @@ } public List<String> getExtensions() { - + //TODO return null; } @@ -356,30 +356,29 @@ XPath xpath = xPathfactory.newXPath(); String expressionString; XPathExpression expr; - Node node; NodeList nodeList; + ArrayList<Bundle> bundles = new ArrayList<Bundle>(); + Bundle bundle; try { - expressionString = "/plugin/extensions/extension[name/text() = '" + name + "']"; - expr = xpath.compile(expressionString); - node = (Node) expr.evaluate(doc, XPathConstants.NODE); - expressionString = "/plugin/extensions/extension[name/text() = '" + name + "']/bundles"; expr = xpath.compile(expressionString); nodeList = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); - ArrayList<Bundle> bundles = new ArrayList<Bundle>(); - for(int i = 0; i < nodeList.getLength(); i++){ - Bundle bundle = new Bundle ("name", "version");//TODO get name and version from the node list from here + expr = xpath.compile("//name"); + String extensionName = (String) expr.evaluate(nodeList.item(i), XPathConstants.STRING); + + expr = xpath.compile("//version"); + String extensionVersion = (String) expr.evaluate(nodeList.item(i), XPathConstants.STRING); + + bundle = new Bundle (extensionName, extensionVersion); bundles.add(bundle); } - - return new Extension(name, new ArrayList<Bundle>()); } catch (XPathExpressionException e) { e.printStackTrace(); } - return null; + return new Extension(name, bundles); } }