camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [3/3] git commit: CAMEL-7876 Added the old construction method back and updated the javadoc
Date Sun, 28 Sep 2014 03:30:32 GMT
CAMEL-7876 Added the old construction method back and updated the javadoc


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

Branch: refs/heads/master
Commit: c9e1bc87e6265044244d254036e827050ee2bd83
Parents: 78b9b8f
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Sun Sep 28 11:20:07 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Sun Sep 28 11:20:07 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/util/GroupIterator.java    | 29 ++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c9e1bc87/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java b/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java
index 4b6f9ad..d03e717 100644
--- a/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java
+++ b/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.util.Iterator;
 import java.util.Scanner;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.NoTypeConversionAvailableException;
 
@@ -37,13 +38,14 @@ import org.apache.camel.NoTypeConversionAvailableException;
  */
 public final class GroupIterator implements Iterator<Object>, Closeable {
 
+    private final CamelContext camelContext;
     private final Exchange exchange;
     private final Iterator<?> it;
     private final String token;
     private final int group;
     private boolean closed;
     private final ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
+    
     /**
      * Creates a new group iterator
      *
@@ -52,9 +54,32 @@ public final class GroupIterator implements Iterator<Object>, Closeable
{
      * @param token         then token used to separate between the parts, use <tt>null</tt>
to not add the token
      * @param group         number of parts to group together
      * @throws IllegalArgumentException is thrown if group is not a positive number
+     * @deprecated  Please use GroupIterator(Exchange exchange, Iterator<?> it, String
token, int group) instead
+     */
+    @Deprecated 
+    public GroupIterator(CamelContext camelContext, Iterator<?> it, String token, int
group) {
+        this.exchange = null;
+        this.camelContext = camelContext;
+        this.it = it;
+        this.token = token;
+        this.group = group;
+        if (group <= 0) {
+            throw new IllegalArgumentException("Group must be a positive number, was: " +
group);
+        }
+    }
+
+    /**
+     * Creates a new group iterator
+     *
+     * @param exchange  the exchange used to create this group iterator
+     * @param it            the iterator to group
+     * @param token         then token used to separate between the parts, use <tt>null</tt>
to not add the token
+     * @param group         number of parts to group together
+     * @throws IllegalArgumentException is thrown if group is not a positive number
      */
     public GroupIterator(Exchange exchange, Iterator<?> it, String token, int group)
{
         this.exchange = exchange;
+        this.camelContext = exchange.getContext();
         this.it = it;
         this.token = token;
         this.group = group;
@@ -130,7 +155,7 @@ public final class GroupIterator implements Iterator<Object>, Closeable
{
                 bos.write(bytes);
             } else if (data != null) {
                 // convert to input stream
-                InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class,
data);
+                InputStream is = context.getTypeConverter().mandatoryConvertTo(InputStream.class,
data);
                 IOHelper.copy(is, bos);
             }
 


Mime
View raw message