You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/08/04 09:50:45 UTC

[camel] branch master updated (a21fe32 -> 096ec2a)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from a21fe32  CAMEL-13783: Polished
     new b0e60be  CAMEL-13774: Add Java8 Stream to Iterator as type converter.
     new 5d8b414  Delete not used method
     new 3675829  CAMEL-13774: Add Java8 Stream to Iterator as type converter.
     new 096ec2a  Polished

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/dataformat/zipfile/ZipFileDataFormat.java       |  4 ++--
 .../main/java/org/apache/camel/converter/IOConverter.java |  4 ----
 .../java/org/apache/camel/converter/ObjectConverter.java  |  1 +
 .../org/apache/camel/converter/ObjectConverterTest.java   | 10 ++++++++++
 .../java/org/apache/camel/processor/SimpleMockTest.java   |  2 ++
 .../main/java/org/apache/camel/support/ObjectHelper.java  | 15 +++++++++++----
 6 files changed, 26 insertions(+), 10 deletions(-)


[camel] 02/04: Delete not used method

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5d8b4142ca8a63b03222a7b2a459413cf12a3d80
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Aug 4 11:37:05 2019 +0200

    Delete not used method
---
 .../src/main/java/org/apache/camel/converter/IOConverter.java         | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/converter/IOConverter.java b/core/camel-base/src/main/java/org/apache/camel/converter/IOConverter.java
index 8f99cbe..6a068f7 100644
--- a/core/camel-base/src/main/java/org/apache/camel/converter/IOConverter.java
+++ b/core/camel-base/src/main/java/org/apache/camel/converter/IOConverter.java
@@ -94,10 +94,6 @@ public final class IOConverter {
         return IOHelper.toWriter(os, ExchangeHelper.getCharsetName(exchange));
     }
 
-    public static BufferedWriter toWriter(File file, boolean append, String charset) throws IOException {
-        return IOHelper.toWriter(new FileOutputStream(file, append), charset);
-    }
-
     @Converter
     public static Reader toReader(InputStream in, Exchange exchange) throws IOException {
         return IOHelper.buffered(new InputStreamReader(in, ExchangeHelper.getCharsetName(exchange)));


[camel] 03/04: CAMEL-13774: Add Java8 Stream to Iterator as type converter.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 36758291a6e784cbcbfb905895735c8c90d7b1df
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Aug 4 11:44:36 2019 +0200

    CAMEL-13774: Add Java8 Stream to Iterator as type converter.
---
 .../src/main/java/org/apache/camel/support/ObjectHelper.java           | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
index 19496e0..69b477a 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
@@ -431,6 +431,9 @@ public final class ObjectHelper {
      * @return the iterator
      */
     public static Iterator<?> createIterator(Object value, String delimiter, boolean allowEmptyValues) {
+        if (value instanceof Stream) {
+            return ((Stream) value).iterator();
+        }
         return createIterable(value, delimiter, allowEmptyValues, false).iterator();
     }
 


[camel] 01/04: CAMEL-13774: Add Java8 Stream to Iterator as type converter.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b0e60bef4f3b89cc568e85fd6dba554be30a2900
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Aug 4 11:36:50 2019 +0200

    CAMEL-13774: Add Java8 Stream to Iterator as type converter.
---
 .../java/org/apache/camel/converter/ObjectConverter.java     |  1 +
 .../java/org/apache/camel/converter/ObjectConverterTest.java | 10 ++++++++++
 .../test/java/org/apache/camel/processor/SimpleMockTest.java |  2 ++
 .../src/main/java/org/apache/camel/support/ObjectHelper.java | 12 ++++++++----
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/converter/ObjectConverter.java b/core/camel-base/src/main/java/org/apache/camel/converter/ObjectConverter.java
index 6945f49..f546448 100644
--- a/core/camel-base/src/main/java/org/apache/camel/converter/ObjectConverter.java
+++ b/core/camel-base/src/main/java/org/apache/camel/converter/ObjectConverter.java
@@ -18,6 +18,7 @@ package org.apache.camel.converter;
 
 import java.math.BigInteger;
 import java.util.Iterator;
+import java.util.stream.Stream;
 
 import org.apache.camel.Converter;
 import org.apache.camel.Exchange;
diff --git a/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java b/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java
index b533f31..f6dcfe1 100644
--- a/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/converter/ObjectConverterTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.converter;
 import java.math.BigInteger;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.stream.Stream;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -33,6 +34,15 @@ public class ObjectConverterTest extends Assert {
         assertEquals(false, it.hasNext());
     }
 
+    @Test
+    public void testStreamIterator() {
+        Iterator<?> it = ObjectConverter.iterator(Stream.of("Claus", "Jonathan", "Andrea"));
+        assertEquals("Claus", it.next());
+        assertEquals("Jonathan", it.next());
+        assertEquals("Andrea", it.next());
+        assertEquals(false, it.hasNext());
+    }
+
     @SuppressWarnings("unchecked")
     @Test
     public void testIterable() {
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SimpleMockTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SimpleMockTest.java
index 015a692..b8bd72d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/SimpleMockTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SimpleMockTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.processor;
 
+import java.util.stream.Stream;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
index 195b1c7..19496e0 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ObjectHelper.java
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.concurrent.Callable;
+import java.util.stream.Stream;
 
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -382,7 +383,7 @@ public final class ObjectHelper {
     }
 
     /**
-     * Creates an iterator over the value if the value is a collection, an
+     * Creates an iterator over the value if the value is a {@link Stream}, collection, an
      * Object[], a String with values separated by comma,
      * or a primitive type array; otherwise to simplify the caller's code,
      * we just create a singleton collection iterator over a single value
@@ -398,7 +399,7 @@ public final class ObjectHelper {
     }
 
     /**
-     * Creates an iterator over the value if the value is a collection, an
+     * Creates an iterator over the value if the value is a {@link Stream}, collection, an
      * Object[], a String with values separated by the given delimiter,
      * or a primitive type array; otherwise to simplify the caller's
      * code, we just create a singleton collection iterator over a single value
@@ -414,7 +415,7 @@ public final class ObjectHelper {
     }
 
     /**
-     * Creates an iterator over the value if the value is a collection, an
+     * Creates an iterator over the value if the value is a {@link Stream}, collection, an
      * Object[], a String with values separated by the given delimiter,
      * or a primitive type array; otherwise to simplify the caller's
      * code, we just create a singleton collection iterator over a single value
@@ -434,7 +435,7 @@ public final class ObjectHelper {
     }
 
     /**
-     * Creates an iterator over the value if the value is a collection, an
+     * Creates an iterator over the value if the value is a {@link Stream}, collection, an
      * Object[], a String with values separated by the given delimiter,
      * or a primitive type array; otherwise to simplify the caller's
      * code, we just create a singleton collection iterator over a single value
@@ -452,6 +453,9 @@ public final class ObjectHelper {
      */
     public static Iterator<?> createIterator(Object value, String delimiter,
                                                   boolean allowEmptyValues, boolean pattern) {
+        if (value instanceof Stream) {
+            return ((Stream) value).iterator();
+        }
         return createIterable(value, delimiter, allowEmptyValues, pattern).iterator();
     }
 


[camel] 04/04: Polished

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 096ec2aa953065fca5141d415d74eaf00e5aa637
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Aug 4 11:50:27 2019 +0200

    Polished
---
 .../java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
index d78b8d4..fe889f5 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
@@ -80,7 +80,7 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
         }
 
         String newFilename = filename + ".zip";
-        exchange.getOut().setHeader(FILE_NAME, newFilename);
+        exchange.getMessage().setHeader(FILE_NAME, newFilename);
     }
 
     @Override
@@ -96,7 +96,7 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
             try {
                 ZipEntry entry = zis.getNextEntry();
                 if (entry != null) {
-                    exchange.getOut().setHeader(FILE_NAME, entry.getName());
+                    exchange.getMessage().setHeader(FILE_NAME, entry.getName());
                     IOHelper.copy(zis, osb);
                 }