nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joew...@apache.org
Subject [21/50] [abbrv] incubator-nifi git commit: NIFI-503: Removed dependencies on commons-lang3 and commons-io
Date Mon, 20 Apr 2015 03:12:58 GMT
NIFI-503: Removed dependencies on commons-lang3 and commons-io


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

Branch: refs/heads/NIFI-271
Commit: e18c0a7d267460293a7e5a0189b223607212354f
Parents: 512ac9c
Author: Mark Payne <markap14@hotmail.com>
Authored: Fri Apr 10 09:37:53 2015 -0400
Committer: Mark Payne <markap14@hotmail.com>
Committed: Fri Apr 10 09:37:53 2015 -0400

----------------------------------------------------------------------
 .../nifi-framework/nifi-documentation/pom.xml       |  8 --------
 .../documentation/html/HtmlDocumentationWriter.java | 15 ++++++++++++---
 .../html/HtmlProcessorDocumentationWriter.java      | 16 +++++++++++-----
 .../html/HtmlDocumentationWriterTest.java           |  8 ++++++++
 4 files changed, 31 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e18c0a7d/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
index e522d30..5995f5c 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
@@ -33,14 +33,6 @@
             <artifactId>nifi-properties</artifactId>
         </dependency>
         <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-processor-utils</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e18c0a7d/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
index 34b1327..243aaa3 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
@@ -26,7 +26,6 @@ import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.nifi.annotation.behavior.DynamicProperties;
 import org.apache.nifi.annotation.behavior.DynamicProperty;
 import org.apache.nifi.annotation.documentation.CapabilityDescription;
@@ -212,13 +211,23 @@ public class HtmlDocumentationWriter implements DocumentationWriter
{
         xmlStreamWriter.writeEndElement();
         xmlStreamWriter.writeStartElement("p");
         if (tags != null) {
-            final String tagString = StringUtils.join(tags.value(), ", ");
+            final String tagString = join(tags.value(), ", ");
             xmlStreamWriter.writeCharacters(tagString);
         } else {
             xmlStreamWriter.writeCharacters("None.");
         }
         xmlStreamWriter.writeEndElement();
-
+    }
+    
+    static String join(final String[] toJoin, final String delimiter) {
+    	final StringBuilder sb = new StringBuilder();
+    	for (int i=0; i < toJoin.length; i++) {
+    		sb.append(toJoin[i]);
+    		if ( i < toJoin.length - 1 ) {
+    			sb.append(delimiter);
+    		}
+    	}
+    	return sb.toString();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e18c0a7d/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
index bc355f7..c253a4d 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
@@ -23,7 +23,6 @@ import java.util.List;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.nifi.annotation.behavior.DynamicRelationship;
 import org.apache.nifi.annotation.behavior.ReadsAttribute;
 import org.apache.nifi.annotation.behavior.ReadsAttributes;
@@ -67,6 +66,13 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter
{
         handleWritesAttributes(xmlStreamWriter, processor);
     }
 
+    private String defaultIfBlank(final String test, final String defaultValue) {
+    	if ( test == null || test.trim().isEmpty() ) {
+    		return defaultValue;
+    	}
+    	return test;
+    }
+    
     /**
      * Writes out just the attributes that are being read in a table form.
      * 
@@ -91,10 +97,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter
{
             for (ReadsAttribute attribute : attributesRead) {
                 xmlStreamWriter.writeStartElement("tr");
                 writeSimpleElement(xmlStreamWriter, "td",
-                        StringUtils.defaultIfBlank(attribute.attribute(), "Not Specified"));
+                        defaultIfBlank(attribute.attribute(), "Not Specified"));
                 // TODO allow for HTML characters here.
                 writeSimpleElement(xmlStreamWriter, "td",
-                        StringUtils.defaultIfBlank(attribute.description(), "Not Specified"));
+                        defaultIfBlank(attribute.description(), "Not Specified"));
                 xmlStreamWriter.writeEndElement();
                 
             }
@@ -129,10 +135,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter
{
             for (WritesAttribute attribute : attributesRead) {
                 xmlStreamWriter.writeStartElement("tr");
                 writeSimpleElement(xmlStreamWriter, "td",
-                        StringUtils.defaultIfBlank(attribute.attribute(), "Not Specified"));
+                        defaultIfBlank(attribute.attribute(), "Not Specified"));
                 // TODO allow for HTML characters here.
                 writeSimpleElement(xmlStreamWriter, "td",
-                        StringUtils.defaultIfBlank(attribute.description(), "Not Specified"));
+                        defaultIfBlank(attribute.description(), "Not Specified"));
                 xmlStreamWriter.writeEndElement();
             }
             xmlStreamWriter.writeEndElement();

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e18c0a7d/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
index 9d7926e..90ff09f 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java
@@ -30,10 +30,18 @@ import org.apache.nifi.reporting.ReportingTask;
 import org.junit.Test;
 
 import static org.apache.nifi.documentation.html.XmlValidator.assertContains;
+import static org.junit.Assert.assertEquals;
 
 public class HtmlDocumentationWriterTest {
 
 	@Test
+	public void testJoin() {
+		assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[] {"a",  "b", "c"}, ",
"));
+		assertEquals("a, b", HtmlDocumentationWriter.join(new String[] {"a", "b"}, ", "));
+		assertEquals("a", HtmlDocumentationWriter.join(new String[] {"a"}, ", "));
+	}
+	
+	@Test
 	public void testDocumentControllerService() throws InitializationException, IOException
{
 
 		ControllerService controllerService = new FullyDocumentedControllerService();


Mime
View raw message