buildframework/helium/sf/java/legacy/src/com/nokia/ant/Database.java
changeset 628 7c4a911dc066
parent 588 c7c26511138f
--- a/buildframework/helium/sf/java/legacy/src/com/nokia/ant/Database.java	Wed Jun 16 16:51:40 2010 +0300
+++ b/buildframework/helium/sf/java/legacy/src/com/nokia/ant/Database.java	Fri Aug 13 14:59:05 2010 +0300
@@ -1,20 +1,20 @@
 /*
-* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
- 
+ * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: 
+ *
+ */
+
 package com.nokia.ant;
 
 import info.bliki.wiki.model.WikiModel;
@@ -58,13 +58,11 @@
 import org.dom4j.io.SAXReader;
 import org.dom4j.io.XMLWriter;
 
-
 /**
  * Reads the current ant project and a fileset and generates a xml file with a summary of targets,
  * macros and properties.
  */
-public class Database
-{
+public class Database {
     private Project project;
     private ResourceCollection rc;
     private Task task;
@@ -73,9 +71,8 @@
     private HashMap<String, List<String>> globalSignalList = new HashMap<String, List<String>>();
     private HashMap<String, String> map = new HashMap<String, String>();
     private Document signaldoc;
-    
-    public Database(Project project, ResourceCollection rc, Task task)
-    {
+
+    public Database(Project project, ResourceCollection rc, Task task) {
         this.project = project;
         this.rc = rc;
         this.task = task;
@@ -97,33 +94,29 @@
     public void log(String msg, int level) {
         if (task != null) {
             task.log(msg, level);
-        } else if (debug) {            
+        }
+        else if (debug) {
             project.log(msg, level);
         }
     }
 
-
-    public void setRefid(Reference r)
-    {
+    public void setRefid(Reference r) {
         Object object = r.getReferencedObject();
-        if (!(object instanceof ResourceCollection))
-        {
+        if (!(object instanceof ResourceCollection)) {
             throw new BuildException(r.getRefId() + " doesn\'t denote a ResourceCollection");
         }
         rc = (ResourceCollection) object;
     }
 
     public Document createDOM() throws DocumentException, IOException {
-        //log("Building Ant project database", Project.MSG_DEBUG);
+        // log("Building Ant project database", Project.MSG_DEBUG);
         Element root = DocumentHelper.createElement("antDatabase");
         Document outDoc = DocumentHelper.createDocument(root);
         ArrayList<String> antFiles = getAntFiles(getProject(), homeFilesOnly);
-        for (String antFile : antFiles)
-        {
-            readSignals(root, antFile);
+        for (String antFile : antFiles) {
+            readSignals(antFile);
         }
-        for (String antFile : antFiles)
-        {
+        for (String antFile : antFiles) {
             parseAntFile(root, antFile);
         }
 
@@ -141,53 +134,53 @@
             }
             XMLWriter out = new XMLWriter(outStream, OutputFormat.createPrettyPrint());
             out.write(outDoc);
-        } catch (DocumentException e) {
+        }
+        catch (DocumentException e) {
             throw new BuildException(e.getMessage());
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             throw new BuildException(e.getMessage());
         }
     }
 
     @SuppressWarnings("unchecked")
-    private void readSignals(Element root, String antFile) throws DocumentException, IOException
-    {
+    private void readSignals(String antFile) throws DocumentException, IOException {
         SAXReader xmlReader = new SAXReader();
         Document antDoc = xmlReader.read(new File(antFile));
 
         XPath xpath = DocumentHelper.createXPath("//hlm:signalListenerConfig");
         xpath.setNamespaceURIs(map);
         List<Element> signalNodes = xpath.selectNodes(antDoc);
-        for (Element propertyNode : signalNodes)
-        {
+        for (Element propertyNode : signalNodes) {
             signaldoc = antDoc;
             String signalid = propertyNode.attributeValue("id");
 
             String signaltarget = propertyNode.attributeValue("target");
             List<String> existinglist = globalSignalList.get(signaltarget);
             String failbuild = signalType(signalid, signaldoc);
-            if (existinglist == null)
+            if (existinglist == null) {
                 existinglist = new ArrayList<String>();
+            }
             existinglist.add(signalid + "," + failbuild);
             globalSignalList.put(signaltarget, existinglist);
         }
     }
 
     @SuppressWarnings("unchecked")
-    private String signalType(String signalid, Document antDoc)
-    {
-        XPath xpath2 = DocumentHelper.createXPath("//hlm:signalListenerConfig[@id='" + signalid + "']/signalNotifierInput/signalInput");
+    private String signalType(String signalid, Document antDoc) {
+        XPath xpath2 = DocumentHelper.createXPath("//hlm:signalListenerConfig[@id='" + signalid
+            + "']/signalNotifierInput/signalInput");
         xpath2.setNamespaceURIs(map);
         List<Element> signalNodes3 = xpath2.selectNodes(antDoc);
 
-        for (Element propertyNode3 : signalNodes3)
-        {
+        for (Element propertyNode3 : signalNodes3) {
             String signalinputid = propertyNode3.attributeValue("refid");
 
-            XPath xpath3 = DocumentHelper.createXPath("//hlm:signalInput[@id='" + signalinputid + "']");
+            XPath xpath3 = DocumentHelper.createXPath("//hlm:signalInput[@id='" + signalinputid
+                + "']");
             xpath3.setNamespaceURIs(map);
             List<Element> signalNodes4 = xpath3.selectNodes(antDoc);
-            for (Element propertyNode4 : signalNodes4)
-            {
+            for (Element propertyNode4 : signalNodes4) {
                 return propertyNode4.attributeValue("failbuild");
             }
         }
@@ -201,8 +194,7 @@
      * @throws IOException
      */
     @SuppressWarnings("unchecked")
-    private void parseAntFile(Element root, String antFile) throws DocumentException, IOException
-    {
+    private void parseAntFile(Element root, String antFile) throws DocumentException, IOException {
         log("Processing Ant file: " + antFile, Project.MSG_DEBUG);
         SAXReader xmlReader = new SAXReader();
         Document antDoc = xmlReader.read(new File(antFile));
@@ -222,8 +214,7 @@
 
         // descriptionElement.setText(description);
 
-        if (!antFile.contains("antlib.xml") && description.equals(""))
-        {
+        if (!antFile.contains("antlib.xml") && description.equals("")) {
             log("Project has no comment: " + projectName, Project.MSG_WARN);
         }
 
@@ -232,78 +223,67 @@
 
         // Project import statements
         List importNodes = antDoc.selectNodes("//import");
-        for (Iterator iterator = importNodes.iterator(); iterator.hasNext();)
-        {
+        for (Iterator iterator = importNodes.iterator(); iterator.hasNext();) {
             Element importCurrentNode = (Element) iterator.next();
-            addTextElement(projectElement, "fileDependency", importCurrentNode
-                    .attributeValue("file"));
+            addTextElement(projectElement, "fileDependency", importCurrentNode.attributeValue("file"));
         }
 
         projectElement.addElement("pythonDependency");
 
         // Project exec statements
         List<Element> execNodes = antDoc.selectNodes("//exec//arg");
-        for (Element argNode : execNodes)
-        {
+        for (Element argNode : execNodes) {
             String argValue = argNode.attributeValue("value");
 
-            if (argValue == null)
+            if (argValue == null) {
                 argValue = argNode.attributeValue("line");
+            }
 
-            if (argValue != null)
-            {
+            if (argValue != null) {
                 Pattern filePattern = Pattern.compile(".pl|.py|.bat|.xml|.txt");
                 Matcher fileMatcher = filePattern.matcher(argValue);
-                if (fileMatcher.find())
-                {
+                if (fileMatcher.find()) {
                     addTextElement(projectElement, "fileDependency", argValue);
                 }
             }
         }
 
         List<Element> targetNodes = antDoc.selectNodes("//target");
-        for (Element targetNode : targetNodes)
-        {
+        for (Element targetNode : targetNodes) {
             processTarget(targetNode, projectElement);
         }
 
         // Process macrodef and scriptdef tasks
         // TODO - maybe scriptdefs should be separate?
         List macroNodes = antDoc.selectNodes("//macrodef | //scriptdef");
-        for (Iterator iterator = macroNodes.iterator(); iterator.hasNext();)
-        {
+        for (Iterator iterator = macroNodes.iterator(); iterator.hasNext();) {
             Element macroNode = (Element) iterator.next();
             processMacro(macroNode, projectElement, antFile);
         }
 
         // Project properties
         List propertyNodes = antDoc.selectNodes("//property");
-        for (Iterator iterator = propertyNodes.iterator(); iterator.hasNext();)
-        {
+        for (Iterator iterator = propertyNodes.iterator(); iterator.hasNext();) {
             Element propertyNode = (Element) iterator.next();
             processProperty(propertyNode, projectElement);
         }
     }
 
-    public ArrayList<String> getAntFiles()
-    {
+    public ArrayList<String> getAntFiles() {
         return getAntFiles(getProject(), true);
     }
 
-    public ArrayList<String> getAntFiles(Project project)
-    {
+    public ArrayList<String> getAntFiles(Project project) {
         return getAntFiles(project, true);
     }
 
     /**
-     * Get the list of all Ant files we want to process. These can be project
-     * and antlib files.
+     * Get the list of all Ant files we want to process. These can be project and antlib files.
      * 
      * @return antFiles a list of ant files to be processed
      */
     @SuppressWarnings("unchecked")
-    public ArrayList<String> getAntFiles(Project project, boolean homeOnly)
-    {
+    public ArrayList<String> getAntFiles(Project project, boolean homeOnly) {
         ArrayList<String> antFiles = new ArrayList<String>();
 
         Map<String, Target> targets = project.getTargets();
@@ -313,61 +293,54 @@
         try {
             projectHome = new File(project.getProperty("helium.dir")).getCanonicalPath();
 
-            while (targetsIter.hasNext())
-            {
+            while (targetsIter.hasNext()) {
                 Target target = targetsIter.next();
                 String projectPath = new File(target.getLocation().getFileName()).getCanonicalPath();
 
-                if (!antFiles.contains(projectPath))
-                {
-                    if (homeOnly)
-                    {
-                        if (!projectPath.contains(projectHome))
-                        {
+                if (!antFiles.contains(projectPath)) {
+                    if (homeOnly) {
+                        if (!projectPath.contains(projectHome)) {
                             antFiles.add(projectPath);
                         }
-                    }
-                    else
+                    } else {
                         antFiles.add(projectPath);
-                }
-            }
-
-            if (rc != null)
-            {
-                Iterator extraFilesIter = rc.iterator();
-                while (extraFilesIter.hasNext())
-                {
-                    FileResource fileResource = (FileResource) extraFilesIter.next();
-                    String extrafile = fileResource.getFile().getCanonicalPath();
-
-                    if (!antFiles.contains(fileResource.toString()) && !fileResource.getFile().getName().startsWith("test_"))
-                    {
-                        if (homeOnly)
-                        {
-                            if (!extrafile.contains(projectHome))
-                            {
-                                antFiles.add(extrafile);
-                            }
-                        }
-                        else
-                            antFiles.add(extrafile);
                     }
                 }
             }
 
-        } catch (IOException e) { 
-            log(e.getMessage(), Project.MSG_ERR); 
+            if (rc != null) {
+                Iterator extraFilesIter = rc.iterator();
+                while (extraFilesIter.hasNext()) {
+                    FileResource fileResource = (FileResource) extraFilesIter.next();
+                    String extrafile = fileResource.getFile().getCanonicalPath();
+
+                    if (!antFiles.contains(fileResource.toString())
+                        && !fileResource.getFile().getName().startsWith("test_")) {
+                        if (homeOnly) {
+                            if (!extrafile.contains(projectHome)) {
+                                antFiles.add(extrafile);
+                            }
+                        }
+                        else {
+                            antFiles.add(extrafile);
+                        }
+                    }
+                }
+            }
+
+        }
+        catch (IOException e) {
+            log(e.getMessage(), Project.MSG_ERR);
             e.printStackTrace();
         }
         return antFiles;
     }
 
-    //--------------------------------- PRIVATE METHODS ------------------------------------------
+    // --------------------------------- PRIVATE METHODS ------------------------------------------
 
     @SuppressWarnings("unchecked")
     private void processMacro(Element macroNode, Element outProjectNode, String antFile)
-    throws IOException, DocumentException
-    {
+        throws IOException, DocumentException {
         String macroName = macroNode.attributeValue("name");
         log("Processing macro: " + macroName, Project.MSG_DEBUG);
 
@@ -389,29 +362,31 @@
         // TODO - Later we should find the line number from the XML input.
         addTextElement(outmacroNode, "location", antFile + ":1:");
 
-        List<Node> statements = macroNode.selectNodes("//scriptdef[@name='" + macroName + "']/attribute | //macrodef[@name='" + macroName + "']/attribute");
+        List<Node> statements = macroNode.selectNodes("//scriptdef[@name='" + macroName
+            + "']/attribute | //macrodef[@name='" + macroName + "']/attribute");
         String usage = "";
-        for (Node statement : statements)
-        {
+        for (Node statement : statements) {
             String defaultval = statement.valueOf("@default");
-            if (defaultval.equals(""))
+            if (defaultval.equals("")) {
                 defaultval = "value";
-            else
+            } else {
                 defaultval = "<i>" + defaultval + "</i>";
+            }
             usage = usage + " " + statement.valueOf("@name") + "=\"" + defaultval + "\"";
         }
 
         String macroElements = "";
-        statements = macroNode.selectNodes("//scriptdef[@name='" + macroName + "']/element | //macrodef[@name='" + macroName + "']/element");
-        for (Node statement : statements)
-        {
+        statements = macroNode.selectNodes("//scriptdef[@name='" + macroName
+            + "']/element | //macrodef[@name='" + macroName + "']/element");
+        for (Node statement : statements) {
             macroElements = "&lt;" + statement.valueOf("@name") + "/&gt;\n" + macroElements;
         }
-        if (macroElements.equals(""))
+        if (macroElements.equals("")) {
             addTextElement(outmacroNode, "usage", "&lt;hlm:" + macroName + " " + usage + "/&gt;");
-        else
-            addTextElement(outmacroNode, "usage", "&lt;hlm:" + macroName + " " + usage + "&gt;\n" + macroElements + "&lt;/hlm:" + macroName + "&gt;");
-
+        } else {
+            addTextElement(outmacroNode, "usage", "&lt;hlm:" + macroName + " " + usage + "&gt;\n"
+                + macroElements + "&lt;/hlm:" + macroName + "&gt;");
+        }
 
         // Add dependencies
         // Enumeration dependencies = antmacro.getDependencies();
@@ -423,53 +398,45 @@
         // dependencyElement.addAttribute("type","direct");
         // }
 
-        callAntTargetVisitor(macroNode, outmacroNode, outProjectNode);
+        callAntTargetVisitor(macroNode, outmacroNode);
 
         // Add documentation
         // Get comment element before the macro element to extract macro doc
         List<Node> children = macroNode.selectNodes("preceding-sibling::node()");
-        if (children.size() > 0)
-        {
+        if (children.size() > 0) {
             // Scan past the text nodes, which are most likely whitespace
             int index = children.size() - 1;
             Node child = (Node) children.get(index);
-            while (index > 0 && child.getNodeType() == Node.TEXT_NODE)
-            {
+            while (index > 0 && child.getNodeType() == Node.TEXT_NODE) {
                 index--;
                 child = (Node) children.get(index);
             }
 
             // Check if there is a comment node
             String commentText = null;
-            if (child.getNodeType() == Node.COMMENT_NODE)
-            {
+            if (child.getNodeType() == Node.COMMENT_NODE) {
                 Comment macroComment = (Comment) child;
                 commentText = macroComment.getStringValue().trim();
                 log(macroName + " comment: " + commentText, Project.MSG_DEBUG);
             }
-            else
-            {
+            else {
                 log("Macro has no comment: " + macroName, Project.MSG_WARN);
             }
 
             insertDocumentation(outmacroNode, commentText);
-
-            Node previousNode = children.get(children.size() - 1);
         }
 
         // Get names of all properties used in this macro
         ArrayList properties = new ArrayList();
         Visitor visitor = new AntPropertyVisitor(properties);
         macroNode.accept(visitor);
-        for (Iterator iterator = properties.iterator(); iterator.hasNext();)
-        {
+        for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
             String property = (String) iterator.next();
             addTextElement(outmacroNode, "propertyDependency", property);
         }
     }
 
-    private void callAntTargetVisitor(Element targetNode, Element outTargetNode, Element outProjectNode)
-    {
+    private void callAntTargetVisitor(Element targetNode, Element outTargetNode) {
         // Add antcall/runtarget dependencies
         ArrayList<String> antcallTargets = new ArrayList<String>();
         ArrayList<String> logs = new ArrayList<String>();
@@ -477,34 +444,31 @@
         ArrayList<String> executables = new ArrayList<String>();
         Visitor visitorTarget = new AntTargetVisitor(antcallTargets, logs, signals, executables);
         targetNode.accept(visitorTarget);
-        for (String antcallTarget : antcallTargets)
-        {
+        for (String antcallTarget : antcallTargets) {
             Element dependencyElement = addTextElement(outTargetNode, "dependency", antcallTarget);
             dependencyElement.addAttribute("type", "exec");
         }
 
-        for (String log : logs)
-        {
+        for (String log : logs) {
             addTextElement(outTargetNode, "log", log);
         }
 
-        if (globalSignalList.get(targetNode.attributeValue("name")) != null)
+        if (globalSignalList.get(targetNode.attributeValue("name")) != null) {
             signals.addAll(globalSignalList.get(targetNode.attributeValue("name")));
+        }
 
-        for (String signal : signals)
-        {
+        for (String signal : signals) {
             addTextElement(outTargetNode, "signal", signal);
         }
 
-        for (String executable : executables)
-        {
+        for (String executable : executables) {
             addTextElement(outTargetNode, "executable", executable);
         }
     }
 
     @SuppressWarnings("unchecked")
-    private void processTarget(Element targetNode, Element outProjectNode) throws IOException, DocumentException
-    {
+    private void processTarget(Element targetNode, Element outProjectNode) throws IOException,
+        DocumentException {
         String targetName = targetNode.attributeValue("name");
         log("Processing target: " + targetName, Project.MSG_DEBUG);
 
@@ -512,35 +476,28 @@
         // Get comment element before the target element to extract target doc
         String commentText = "";
         List<Node> children = targetNode.selectNodes("preceding-sibling::node()");
-        if (children.size() > 0)
-        {
+        if (children.size() > 0) {
             // Scan past the text nodes, which are most likely whitespace
             int index = children.size() - 1;
             Node child = children.get(index);
-            while (index > 0 && child.getNodeType() == Node.TEXT_NODE)
-            {
+            while (index > 0 && child.getNodeType() == Node.TEXT_NODE) {
                 index--;
                 child = (Node) children.get(index);
             }
 
             // Check if there is a comment node
-            if (child.getNodeType() == Node.COMMENT_NODE)
-            {
+            if (child.getNodeType() == Node.COMMENT_NODE) {
                 Comment targetComment = (Comment) child;
                 commentText = targetComment.getStringValue().trim();
 
                 log(targetName + " comment: " + commentText, Project.MSG_DEBUG);
             }
-            else
-            {
+            else {
                 log("Target has no comment: " + targetName, Project.MSG_WARN);
             }
-
-            Node previousNode = children.get(children.size() - 1);
         }
 
-        if (!commentText.contains("Private:"))
-        {
+        if (!commentText.contains("Private:")) {
             Element outTargetNode = outProjectNode.addElement("target");
 
             addTextElement(outTargetNode, "name", targetNode.attributeValue("name"));
@@ -553,21 +510,21 @@
             Project project = getProject();
             Target antTarget = (Target) project.getTargets().get(targetName);
 
-            if (antTarget == null)
+            if (antTarget == null) {
                 return;
+            }
 
             addTextElement(outTargetNode, "location", antTarget.getLocation().toString());
 
             // Add dependencies
             Enumeration dependencies = antTarget.getDependencies();
-            while (dependencies.hasMoreElements())
-            {
+            while (dependencies.hasMoreElements()) {
                 String dependency = (String) dependencies.nextElement();
                 Element dependencyElement = addTextElement(outTargetNode, "dependency", dependency);
                 dependencyElement.addAttribute("type", "direct");
             }
 
-            callAntTargetVisitor(targetNode, outTargetNode, outProjectNode);
+            callAntTargetVisitor(targetNode, outTargetNode);
 
             // Process the comment text as MediaWiki syntax and convert to HTML
             insertDocumentation(outTargetNode, commentText);
@@ -576,8 +533,7 @@
             ArrayList properties = new ArrayList();
             Visitor visitor = new AntPropertyVisitor(properties);
             targetNode.accept(visitor);
-            for (Iterator iterator = properties.iterator(); iterator.hasNext();)
-            {
+            for (Iterator iterator = properties.iterator(); iterator.hasNext();) {
                 String property = (String) iterator.next();
                 addTextElement(outTargetNode, "propertyDependency", property);
             }
@@ -591,48 +547,45 @@
         }
     }
 
-    private void processProperty(Element propertyNode, Element outProjectNode) throws IOException
-    {
+    private void processProperty(Element propertyNode, Element outProjectNode) throws IOException {
         String propertyName = propertyNode.attributeValue("name");
         log("Processing Property: " + propertyName, Project.MSG_DEBUG);
 
         Element outPropertyNode = outProjectNode.addElement("property");
         addTextElement(outPropertyNode, "name", propertyNode.attributeValue("name"));
-        if (propertyNode.attributeValue("value") == null)
-        {
+        if (propertyNode.attributeValue("value") == null) {
             addTextElement(outPropertyNode, "defaultValue", propertyNode.attributeValue("location"));
         }
-        else
-        {
+        else {
             addTextElement(outPropertyNode, "defaultValue", propertyNode.attributeValue("value"));
         }
     }
 
-    private void insertDocumentation(Element outNode, String commentText) throws IOException, DocumentException
-    {
-        if (commentText != null)
-        {
+    private void insertDocumentation(Element outNode, String commentText) throws IOException,
+        DocumentException {
+        if (commentText != null) {
             WikiModel wikiModel = new WikiModel("", "");
-            if (!commentText.contains("</pre>") && (commentText.contains("**") || commentText.contains("==") || commentText.contains("- -")))
-            {
+            if (!commentText.contains("</pre>")
+                && (commentText.contains("**") || commentText.contains("==") || commentText.contains("- -"))) {
                 commentText = commentText.replace("**", "").replace("==", "").replace("- -", "").trim();
                 log("Warning: Comment code has invalid syntax: " + commentText, Project.MSG_WARN);
             }
-            if (commentText.startsWith("-"))
+            if (commentText.startsWith("-")) {
                 commentText = commentText.replace("-", "");
+            }
             commentText = commentText.trim();
 
             String commentTextCheck = commentText.replace("deprecated>", "").replace("tt>", "").replace("todo>", "");
-            if (commentTextCheck.contains(">") && !commentTextCheck.contains("</pre>"))
+            if (commentTextCheck.contains(">") && !commentTextCheck.contains("</pre>")) {
                 log("Warning: Comment code needs <pre> tags around it: " + commentText, Project.MSG_WARN);
+            }
 
             commentText = filterTextNewlines(commentText);
             commentText = wikiModel.render(commentText);
 
             // If <deprecated> tag exists in the comment, then parse the
             // deprecated message.
-            if (commentText.indexOf("&#60;deprecated&#62;") != -1)
-            {
+            if (commentText.indexOf("&#60;deprecated&#62;") != -1) {
                 int deprecatedMsgStart = commentText.indexOf("&#60;deprecated&#62;") + 20;
                 int deprecatedMsgEnd = commentText.indexOf("&#60;/deprecated&#62;");
 
@@ -643,55 +596,45 @@
                 // remove <deprecated> part from description field.
                 int commentTextLength = commentText.length();
                 String documentationMsgStart = commentText.substring(1, deprecatedMsgStart - 20);
-                String documentationMsgEnd = commentText.substring(deprecatedMsgEnd + 21,
-                        commentTextLength);
+                String documentationMsgEnd = commentText.substring(deprecatedMsgEnd + 21, commentTextLength);
                 String documentationMsg = documentationMsgStart.concat(documentationMsgEnd);
                 commentText = documentationMsg.trim();
             }
         }
-        else
-        {
+        else {
             commentText = "";
         }
         // Get the documentation element as a document
-        String documentationText = "<documentation>" + commentText +
-                                 "</documentation>";
+        String documentationText = "<documentation>" + commentText + "</documentation>";
         Document docDoc = DocumentHelper.parseText(documentationText);
         outNode.add(docDoc.getRootElement());
         log("HTML comment: " + commentText, Project.MSG_DEBUG);
     }
 
-    private Element addTextElement(Element parent, String name, String text)
-    {
+    private Element addTextElement(Element parent, String name, String text) {
         Element element = addTextElement(parent, name, text, false);
 
         return element;
     }
 
-    private Element addTextElement(Element parent, String name, String text, boolean escape)
-    {
+    private Element addTextElement(Element parent, String name, String text, boolean escape) {
         Element element = parent.addElement(name);
-        if (text != null)
-        {
-            if (escape)
-            {
+        if (text != null) {
+            if (escape) {
                 element.addCDATA(text);
             }
-            else
-            {
+            else {
                 element.setText(text);
             }
         }
         return element;
     }
 
-    private String filterTextNewlines(String text) throws IOException
-    {
+    private String filterTextNewlines(String text) throws IOException {
         BufferedReader in = new BufferedReader(new StringReader(text));
         StringBuilder out = new StringBuilder();
         String line = in.readLine();
-        while (line != null)
-        {
+        while (line != null) {
             out.append(line.trim());
             out.append("\n");
             line = in.readLine();
@@ -705,20 +648,19 @@
      * @param outProjectNode
      * @throws IOException
      */
-    private void buildTaskDefs( Element root ) throws DocumentException, IOException
-    {
+    private void buildTaskDefs(Element root) throws DocumentException, IOException {
         Element projectElement = root.addElement("project");
         projectElement.addElement("name");
         insertDocumentation(projectElement, "");
-        HashMap < String, String > tasks = getHeliumAntTasks();
+        HashMap<String, String> tasks = getHeliumAntTasks();
 
-        for ( String taskName : tasks.keySet() ) {
-            String className = tasks.get( taskName );
+        for (String taskName : tasks.keySet()) {
+            String className = tasks.get(taskName);
             log("Processing TaskDef: " + taskName, Project.MSG_DEBUG);
 
             Element outTaskDefNode = projectElement.addElement("taskdef");
-            addTextElement( outTaskDefNode, "name", taskName );
-            addTextElement( outTaskDefNode, "classname",  className );
+            addTextElement(outTaskDefNode, "name", taskName);
+            addTextElement(outTaskDefNode, "classname", className);
         }
     }
 
@@ -728,31 +670,31 @@
      * @return
      */
     @SuppressWarnings("unchecked")
-    private HashMap < String, String > getHeliumAntTasks() {
+    private HashMap<String, String> getHeliumAntTasks() {
 
         // 1. Get all the task definitions from the project
-        Hashtable <String, Class<?> > allTaskdefs = getProject().getTaskDefinitions();
+        Hashtable<String, Class<?>> allTaskdefs = getProject().getTaskDefinitions();
         // 2. Filter the list by applying criteria
-        return filterTasks( allTaskdefs );
+        return filterTasks(allTaskdefs);
     }
 
     /**
-     * Method is used to filter tasks. 
+     * Method is used to filter tasks.
      * 
      * @param allTaskdefs
      * @param criteria
      */
-    private HashMap < String, String > filterTasks( Hashtable<String, Class<?> > allTaskdefs ) {
-        HashMap <String, String> tasks = new HashMap <String, String>();
+    private HashMap<String, String> filterTasks(Hashtable<String, Class<?>> allTaskdefs) {
+        HashMap<String, String> tasks = new HashMap<String, String>();
 
-        Enumeration <String> taskdefsenum = allTaskdefs.keys();
-        while ( taskdefsenum.hasMoreElements() ) {
+        Enumeration<String> taskdefsenum = allTaskdefs.keys();
+        while (taskdefsenum.hasMoreElements()) {
             String key = taskdefsenum.nextElement();
             Class<?> clazz = allTaskdefs.get(key);
             String className = clazz.getName();
-            if ( key.contains("nokia.com") && className.startsWith("com.nokia") && 
-                    className.contains("ant.taskdefs") ) {
-                tasks.put( getTaskName( key ), clazz.getName() );
+            if (key.contains("nokia.com") && className.startsWith("com.nokia")
+                && className.contains("ant.taskdefs")) {
+                tasks.put(getTaskName(key), clazz.getName());
             }
         }
         return tasks;
@@ -764,63 +706,52 @@
      * @param text
      * @return
      */
-    private String getTaskName( String text ) {
+    private String getTaskName(String text) {
         int lastIndex = text.lastIndexOf(':');
-        return text.substring( lastIndex + 1 );
+        return text.substring(lastIndex + 1);
     }
 
-    //----------------------------------- PRIVATE CLASSES -----------------------------------------
+    // ----------------------------------- PRIVATE CLASSES -----------------------------------------
 
-    private class AntPropertyVisitor extends VisitorSupport
-    {
+    private class AntPropertyVisitor extends VisitorSupport {
         private List<String> propertyList;
 
-        public AntPropertyVisitor(List<String> propertyList)
-        {
+        public AntPropertyVisitor(List<String> propertyList) {
             this.propertyList = propertyList;
         }
 
-        public void visit(Attribute node)
-        {
+        public void visit(Attribute node) {
             String text = node.getStringValue();
             extractUsedProperties(text);
         }
 
-        public void visit(CDATA node)
-        {
+        public void visit(CDATA node) {
             String text = node.getText();
             extractUsedProperties(text);
         }
 
-        public void visit(Text node)
-        {
+        public void visit(Text node) {
             String text = node.getText();
             extractUsedProperties(text);
         }
 
-        public void visit(Element node)
-        {
-            if (node.getName().equals("property"))
-            {
+        public void visit(Element node) {
+            if (node.getName().equals("property")) {
                 String propertyName = node.attributeValue("name");
-                if (!propertyList.contains(propertyName))
-                {
+                if (!propertyList.contains(propertyName)) {
                     propertyList.add(propertyName);
                     log("property matches :" + propertyName, Project.MSG_DEBUG);
                 }
             }
         }
 
-        private void extractUsedProperties(String text)
-        {
+        private void extractUsedProperties(String text) {
             Pattern p1 = Pattern.compile("\\$\\{([^@$}]*)\\}");
             Matcher m1 = p1.matcher(text);
             log(text, Project.MSG_DEBUG);
-            while (m1.find())
-            {
+            while (m1.find()) {
                 String group = m1.group(1);
-                if (!propertyList.contains(group))
-                {
+                if (!propertyList.contains(group)) {
                     propertyList.add(group);
                 }
                 log("property matches: " + group, Project.MSG_DEBUG);
@@ -829,11 +760,9 @@
             Pattern p2 = Pattern.compile("\\$\\{([^\n]*\\})\\}");
             Matcher m2 = p2.matcher(text);
             log(text, Project.MSG_DEBUG);
-            while (m2.find())
-            {
+            while (m2.find()) {
                 String group = m2.group(1);
-                if (!propertyList.contains(group))
-                {
+                if (!propertyList.contains(group)) {
                     propertyList.add(group);
                 }
                 log("property matches: " + group, Project.MSG_DEBUG);
@@ -842,11 +771,9 @@
             Pattern p3 = Pattern.compile("\\$\\{(\\@\\{[^\n]*)\\}");
             Matcher m3 = p3.matcher(text);
             log(text, Project.MSG_DEBUG);
-            while (m3.find())
-            {
+            while (m3.find()) {
                 String group = m3.group(1);
-                if (!propertyList.contains(group))
-                {
+                if (!propertyList.contains(group)) {
                     propertyList.add(group);
                 }
                 log("property matches: " + group, Project.MSG_DEBUG);
@@ -854,32 +781,28 @@
         }
     }
 
-    private class AntTargetVisitor extends VisitorSupport
-    {
+    private class AntTargetVisitor extends VisitorSupport {
         private List<String> targetList;
         private List<String> logList;
         private List<String> signalList;
         private List<String> executableList;
 
-        public AntTargetVisitor(List<String> targetList, List<String> logList, List<String> signalList, List<String> executableList)
-        {
+        public AntTargetVisitor(List<String> targetList, List<String> logList,
+            List<String> signalList, List<String> executableList) {
             this.targetList = targetList;
             this.logList = logList;
             this.signalList = signalList;
             this.executableList = executableList;
         }
 
-        public void visit(Element node)
-        {
+        public void visit(Element node) {
             String name = node.getName();
-            if (name.equals("antcall") || name.equals("runtarget"))
-            {
+            if (name.equals("antcall") || name.equals("runtarget")) {
                 String text = node.attributeValue("target");
                 extractTarget(text);
             }
 
-            if (!name.equals("include") && !name.equals("exclude"))
-            {
+            if (!name.equals("include") && !name.equals("exclude")) {
                 String text = node.attributeValue("name");
                 addLog(text);
                 text = node.attributeValue("output");
@@ -894,37 +817,32 @@
                 addLog(text);
             }
 
-            if (name.equals("signal") || name.equals("execSignal"))
-            {
+            if (name.equals("signal") || name.equals("execSignal")) {
                 String signalid = getProject().replaceProperties(node.attributeValue("name"));
                 String failbuild = signalType(signalid, signaldoc);
 
-                if (signalList != null)
-                {
-                    if (failbuild != null)
+                if (signalList != null) {
+                    if (failbuild != null) {
                         signalList.add(signalid + "," + failbuild);
-                    else
+                    } else {
                         signalList.add(signalid);
+                    }
                 }
             }
 
-            if (name.equals("exec") || name.equals("preset.exec"))
-            {
+            if (name.equals("exec") || name.equals("preset.exec")) {
                 String text = node.attributeValue("executable");
                 executableList.add(text);
                 log("Executable: " + text, Project.MSG_DEBUG);
             }
         }
 
-        private void addLog(String text)
-        {
-            if (text != null && logList != null)
-            {
-                for (String log : text.split(" "))
-                {
+        private void addLog(String text) {
+            if (text != null && logList != null) {
+                for (String log : text.split(" ")) {
                     String fulllogname = getProject().replaceProperties(log);
-                    if (!logList.contains(log) && (fulllogname.endsWith(".log") || fulllogname.endsWith(".html")))
-                    {
+                    if (!logList.contains(log)
+                        && (fulllogname.endsWith(".log") || fulllogname.endsWith(".html"))) {
                         log = log.replace("--log=", "");
                         logList.add(log);
                     }
@@ -932,12 +850,10 @@
             }
         }
 
-        private void extractTarget(String text)
-        {
+        private void extractTarget(String text) {
             String iText = getProject().replaceProperties(text);
             targetList.add(iText);
         }
 
     }
 }
-