Documentation added, class/functions renaming

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bef145fd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bef145fd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bef145fd

Branch: refs/heads/master
Commit: bef145fd7636ac0db1206e1f38f933e1a925555c
Parents: 3815553
Author: nkukhar <kukha...@gmail.com>
Authored: Mon Feb 9 23:49:23 2015 -0800
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Feb 10 09:50:08 2015 +0100

----------------------------------------------------------------------
 .../camel/maven/CamelSpringNamespace.java       |   7 +-
 .../java/org/apache/camel/maven/Constants.java  |   3 +
 .../camel/maven/DocumentationEnricher.java      |  52 +++----
 .../java/org/apache/camel/maven/DomFinder.java  |  41 ++++++
 .../java/org/apache/camel/maven/DomParser.java  |  38 -----
 .../maven/EipDocumentationEnricherMojo.java     | 142 +++++++++++++++++++
 .../maven/EipDocumentationGeneratorMojo.java    | 133 -----------------
 .../org/apache/camel/maven/PackageHelper.java   |   6 +-
 8 files changed, 223 insertions(+), 199 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bef145fd/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/CamelSpringNamespace.java
----------------------------------------------------------------------
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/CamelSpringNamespace.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/CamelSpringNamespace.java
index d64d0b9..4466045 100644
--- 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/CamelSpringNamespace.java
+++ 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/CamelSpringNamespace.java
@@ -19,14 +19,17 @@ package org.apache.camel.maven;
 import javax.xml.namespace.NamespaceContext;
 import java.util.Iterator;
 
+/**
+ * Default namespace for xsd schema.
+ */
 public class CamelSpringNamespace implements NamespaceContext {
 
   @Override
   public String getNamespaceURI(String prefix) {
-    if (prefix == null){
+    if (prefix == null) {
       throw new IllegalArgumentException("The prefix cannot be null.");
     }
-    if ("xs".equals(prefix)){
+    if ("xs".equals(prefix)) {
       return "http://www.w3.org/2001/XMLSchema";;
     }
     return null;

http://git-wip-us.apache.org/repos/asf/camel/blob/bef145fd/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/Constants.java
----------------------------------------------------------------------
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/Constants.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/Constants.java
index 18a9abf..745026c 100644
--- 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/Constants.java
+++ 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/Constants.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.maven;
 
+/**
+ * Stores mojo related constants.
+ */
 public final class Constants {
   private Constants(){}
 

http://git-wip-us.apache.org/repos/asf/camel/blob/bef145fd/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java
----------------------------------------------------------------------
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java
index 5a17dd7..31ab995 100644
--- 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java
+++ 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DocumentationEnricher.java
@@ -26,7 +26,11 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * Enriches xml document with documentation from json files.
+ */
 public class DocumentationEnricher {
+
   public void enrichTopLevelElementsDocumentation(Document document,
                                                   NodeList elements,
                                                   Map<String, File> jsonFiles)
@@ -35,12 +39,21 @@ public class DocumentationEnricher {
       Element item = (Element) elements.item(i);
       String name = item.getAttribute(Constants.NAME_ATTRIBUTE_NAME);
       if (jsonFiles.containsKey(name)) {
-        addDocumentation(document, item, jsonFiles.get(name));
+        addElementDocumentation(document, item, jsonFiles.get(name));
       }
     }
   }
 
-  private void addDocumentation(Document document, Element item, File jsonFile)
+  public void enrichTypeAttributesDocumentation(Document document,
+                                                NodeList attributeElements,
+                                                File jsonFile) throws 
IOException {
+    for (int j = 0; j < attributeElements.getLength(); j++) {
+      Element item = (Element) attributeElements.item(j);
+      addAttributeDocumentation(item, jsonFile, document);
+    }
+  }
+
+  private void addElementDocumentation(Document document, Element item, File 
jsonFile)
       throws IOException {
     List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema
         (Constants.MODEL_ATTRIBUTE_NAME, PackageHelper.fileToString(jsonFile), 
false);
@@ -53,28 +66,6 @@ public class DocumentationEnricher {
     }
   }
 
-  private void addDocumentation(Document document, Element item, String 
textContent) {
-    Element annotation = 
document.createElement(Constants.XS_ANNOTATION_ELEMENT_NAME);
-    Element documentation = 
document.createElement(Constants.XS_DOCUMENTATION_ELEMENT_NAME);
-    documentation.setAttribute("xml:lang", "en");
-    documentation.setTextContent(textContent);
-    annotation.appendChild(documentation);
-    if (item.getFirstChild() != null){
-      item.insertBefore(annotation, item.getFirstChild());
-    } else {
-      item.appendChild(annotation);
-    }
-  }
-
-  public void enrichTypeAttributesDocumentation(Document document,
-                                                NodeList attributeElements,
-                                                File jsonFile) throws 
IOException {
-      for (int j = 0; j < attributeElements.getLength(); j++) {
-        Element item = (Element) attributeElements.item(j);
-        addAttributeDocumentation(item, jsonFile, document);
-      }
-    }
-
   private void addAttributeDocumentation(Element item,
                                          File jsonFile,
                                          Document document)
@@ -92,4 +83,17 @@ public class DocumentationEnricher {
       }
     }
   }
+
+  private void addDocumentation(Document document, Element item, String 
textContent) {
+    Element annotation = 
document.createElement(Constants.XS_ANNOTATION_ELEMENT_NAME);
+    Element documentation = 
document.createElement(Constants.XS_DOCUMENTATION_ELEMENT_NAME);
+    documentation.setAttribute("xml:lang", "en");
+    documentation.setTextContent(textContent);
+    annotation.appendChild(documentation);
+    if (item.getFirstChild() != null){
+      item.insertBefore(annotation, item.getFirstChild());
+    } else {
+      item.appendChild(annotation);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/bef145fd/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomFinder.java
----------------------------------------------------------------------
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomFinder.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomFinder.java
new file mode 100644
index 0000000..c5c0aff
--- /dev/null
+++ 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomFinder.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+
+/**
+ * Finds xml elements where documentation can be added.
+ */
+public class DomFinder {
+
+  public NodeList findElementsAndTypes(Document document, XPath xPath) throws 
XPathExpressionException {
+    return  (NodeList) xPath.compile("/xs:schema/xs:element")
+        .evaluate(document, XPathConstants.NODESET);
+  }
+
+  public NodeList findAttributesElements(Document document, XPath xPath, 
String name) throws XPathExpressionException {
+    return (NodeList) xPath.compile(
+        "/xs:schema/xs:complexType[@name='" + name + "']//xs:attribute")
+        .evaluate(document, XPathConstants.NODESET);
+  }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/bef145fd/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomParser.java
----------------------------------------------------------------------
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomParser.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomParser.java
deleted file mode 100644
index 6149421..0000000
--- 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/DomParser.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.maven;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-
-public class DomParser {
-
-  public NodeList findElementsAndTypes(Document document, XPath xPath) throws 
XPathExpressionException {
-    return  (NodeList) xPath.compile("/xs:schema/xs:element")
-        .evaluate(document, XPathConstants.NODESET);
-  }
-
-  public NodeList findAttributesElements(Document document, XPath xPath, 
String name) throws XPathExpressionException {
-    return (NodeList) xPath.compile(
-        "/xs:schema/xs:complexType[@name='" + name + "']//xs:attribute")
-        .evaluate(document, XPathConstants.NODESET);
-  }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/bef145fd/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
----------------------------------------------------------------------
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
new file mode 100644
index 0000000..4b4a967
--- /dev/null
+++ 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Injects EIP documentation to camel schema.
+ */
+@Mojo(name = "eip-documentation-enricher", requiresDependencyResolution = 
ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
+    defaultPhase = LifecyclePhase.PACKAGE)
+public class EipDocumentationEnricherMojo extends AbstractMojo {
+
+  /**
+   * Path to camel EIP schema.
+   */
+  @Parameter(required = true)
+  File inputCamelSchemaFile;
+
+  /**
+   * Path to camel EIP schema with enriched documentation.
+   */
+  @Parameter(required = true)
+  File outputCamelSchemaFile;
+
+  /**
+   * Path to camel core project root directory.
+   */
+  @Parameter(defaultValue = "${project.build.directory}/../../..//camel-core")
+  File camelCoreDir;
+
+  @Override
+  public void execute() throws MojoExecutionException, MojoFailureException {
+    File rootDir = new File(camelCoreDir, Constants.PATH_TO_MODEL_DIR);
+    DomFinder domFinder = new DomFinder();
+    DocumentationEnricher documentationEnricher = new DocumentationEnricher();
+    Map<String, File> jsonFiles = PackageHelper.findJsonFiles(rootDir);
+    XPath xPath = buildXPath(new CamelSpringNamespace());
+    try {
+      Document document = buildNamespaceAwareDocument(inputCamelSchemaFile);
+      NodeList elementsAndTypes = domFinder.findElementsAndTypes(document, 
xPath);
+      documentationEnricher.enrichTopLevelElementsDocumentation
+          (document, elementsAndTypes, jsonFiles);
+      Map<String, String> typeToNameMap = buildTypeToNameMap(elementsAndTypes);
+      for (Map.Entry<String, String> entry : typeToNameMap.entrySet()) {
+        NodeList attributeElements = 
domFinder.findAttributesElements(document, xPath, entry.getKey());
+        if (jsonFiles.containsKey(entry.getValue())){
+          documentationEnricher.enrichTypeAttributesDocumentation
+              (document, attributeElements, jsonFiles.get(entry.getValue()));
+        }
+      }
+      saveToFile(document, outputCamelSchemaFile, buildTransformer());
+    } catch (Exception e) {
+      getLog().error(e);
+    }
+  }
+
+  private Map<String, String> buildTypeToNameMap(NodeList elementsAndTypes) {
+    Map<String, String> typeToNameMap = new HashMap<>();
+    for (int i = 0; i < elementsAndTypes.getLength(); i++) {
+      Element item = (Element) elementsAndTypes.item(i);
+      String name = item.getAttribute(Constants.NAME_ATTRIBUTE_NAME);
+      String type = item.getAttribute(Constants.TYPE_ATTRIBUTE_NAME);
+      if (name != null && type != null) {
+        type = type.replaceAll("tns:", "");
+        if (getLog().isDebugEnabled()) {
+          getLog().debug(String.format("Putting attributes type:'%s', 
name:'%s'", name, type));
+        }
+        typeToNameMap.put(type, name);
+      }
+    }
+    return typeToNameMap;
+  }
+
+  private XPath buildXPath(NamespaceContext namespaceContext) {
+    XPath xPath = XPathFactory.newInstance().newXPath();
+    xPath.setNamespaceContext(namespaceContext);
+    return xPath;
+  }
+
+  private Transformer buildTransformer() throws 
TransformerConfigurationException {
+    Transformer transformer =
+        TransformerFactory.newInstance().newTransformer();
+    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+    transformer.setOutputProperty(
+        "{http://xml.apache.org/xslt}indent-amount";, "2");
+    return transformer;
+  }
+
+  public Document buildNamespaceAwareDocument(File xml) throws 
ParserConfigurationException, IOException, SAXException {
+    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    factory.setNamespaceAware(true);
+    DocumentBuilder builder = factory.newDocumentBuilder();
+    return builder.parse(xml);
+  }
+
+  private void saveToFile(Document document, File outputFile, Transformer 
transformer) throws IOException, TransformerException {
+    StreamResult result =
+        new StreamResult(new FileOutputStream(outputFile));
+    DOMSource source = new DOMSource(document);
+    transformer.transform(source, result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/bef145fd/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationGeneratorMojo.java
----------------------------------------------------------------------
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationGeneratorMojo.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationGeneratorMojo.java
deleted file mode 100644
index 7a4a0c1..0000000
--- 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationGeneratorMojo.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.maven;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathFactory;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-@Mojo(name = "eip-documentation-enricher", requiresDependencyResolution = 
ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
-    defaultPhase = LifecyclePhase.PACKAGE)
-public class EipDocumentationGeneratorMojo extends AbstractMojo {
-
-  /**
-   * Project's source directory as specified in the POM.
-   */
-  @Parameter(required = true)
-  File inputCamelSchemaFile;
-
-  @Parameter(required = true)
-  File outputCamelSchemaFile;
-
-  @Parameter(defaultValue = "${project.build.directory}/../../..//camel-core")
-  File camelCoreDir;
-
-  @Override
-  public void execute() throws MojoExecutionException, MojoFailureException {
-    File rootDir = new File(camelCoreDir, Constants.PATH_TO_MODEL_DIR);
-    DomParser domParser = new DomParser();
-    DocumentationEnricher documentationEnricher = new DocumentationEnricher();
-    Map<String, File> jsonFiles = PackageHelper.findJsonFiles(rootDir);
-    XPath xPath = buildXPath(new CamelSpringNamespace());
-    try {
-      Document document = buildNamespaceAwareDocument(inputCamelSchemaFile);
-      NodeList elementsAndTypes = domParser.findElementsAndTypes(document, 
xPath);
-      documentationEnricher.enrichTopLevelElementsDocumentation
-          (document, elementsAndTypes, jsonFiles);
-      Map<String, String> typeToNameMap = buildTypeToNameMap(elementsAndTypes);
-      for (Map.Entry<String, String> entry : typeToNameMap.entrySet()) {
-        NodeList attributeElements = 
domParser.findAttributesElements(document, xPath, entry.getKey());
-        if (jsonFiles.containsKey(entry.getValue())){
-          documentationEnricher.enrichTypeAttributesDocumentation
-              (document, attributeElements, jsonFiles.get(entry.getValue()));
-        }
-      }
-      saveToFile(document, outputCamelSchemaFile, buildTransformer());
-    } catch (Exception e) {
-      getLog().error(e);
-    }
-  }
-
-  private Map<String, String> buildTypeToNameMap(NodeList elementsAndTypes) {
-    Map<String, String> typeToNameMap = new HashMap<>();
-    for (int i = 0; i < elementsAndTypes.getLength(); i++) {
-      Element item = (Element) elementsAndTypes.item(i);
-      String name = item.getAttribute(Constants.NAME_ATTRIBUTE_NAME);
-      String type = item.getAttribute(Constants.TYPE_ATTRIBUTE_NAME);
-      if (name != null && type != null) {
-        type = type.replaceAll("tns:", "");
-        if (getLog().isDebugEnabled()) {
-          getLog().debug(String.format("Putting attributes type:'%s', 
name:'%s'", name, type));
-        }
-        typeToNameMap.put(type, name);
-      }
-    }
-    return typeToNameMap;
-  }
-
-  private XPath buildXPath(NamespaceContext namespaceContext) {
-    XPath xPath = XPathFactory.newInstance().newXPath();
-    xPath.setNamespaceContext(namespaceContext);
-    return xPath;
-  }
-
-  private Transformer buildTransformer() throws 
TransformerConfigurationException {
-    Transformer transformer =
-        TransformerFactory.newInstance().newTransformer();
-    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-    transformer.setOutputProperty(
-        "{http://xml.apache.org/xslt}indent-amount";, "2");
-    return transformer;
-  }
-
-  public Document buildNamespaceAwareDocument(File xml) throws 
ParserConfigurationException, IOException, SAXException {
-    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-    factory.setNamespaceAware(true);
-    DocumentBuilder builder = factory.newDocumentBuilder();
-    return builder.parse(xml);
-  }
-
-  private void saveToFile(Document document, File outputFile, Transformer 
transformer) throws IOException, TransformerException {
-    StreamResult result =
-        new StreamResult(new FileOutputStream(outputFile));
-    DOMSource source = new DOMSource(document);
-    transformer.transform(source, result);
-  }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/bef145fd/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/PackageHelper.java
----------------------------------------------------------------------
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/PackageHelper.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/PackageHelper.java
index 67ec981..2470098 100644
--- 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/PackageHelper.java
+++ 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/PackageHelper.java
@@ -25,9 +25,11 @@ import java.nio.file.Paths;
 import java.util.HashMap;
 import java.util.Map;
 
+/**
+ * Utility class to find, read json files.
+ */
 public class PackageHelper {
-  private PackageHelper() {
-  }
+  private PackageHelper() {}
 
   public static String fileToString(File file) throws IOException {
     byte[] encoded = Files.readAllBytes(Paths.get(file.toURI()));

Reply via email to