Repository: camel
Updated Branches:
  refs/heads/master 02a652da3 -> a520ae768


CAMEL-9711: Make code compile on java 1.7


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

Branch: refs/heads/master
Commit: a520ae7688dea02b21129326cc7b2c7d96867eb1
Parents: 02a652d
Author: Claus Ibsen <[email protected]>
Authored: Sun Mar 20 09:01:53 2016 +0100
Committer: Claus Ibsen <[email protected]>
Committed: Sun Mar 20 09:01:53 2016 +0100

----------------------------------------------------------------------
 .../sql/DefaultSqlPrepareStatementStrategy.java | 12 +++-
 .../camel/component/sql/SqlInIterator.java      | 58 --------------------
 2 files changed, 9 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a520ae76/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlPrepareStatementStrategy.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlPrepareStatementStrategy.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlPrepareStatementStrategy.java
index 7e91e72..ff9b98a 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlPrepareStatementStrategy.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlPrepareStatementStrategy.java
@@ -36,6 +36,7 @@ import org.apache.camel.util.StringQuoteHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
+import org.springframework.util.CompositeIterator;
 
 /**
  * Default {@link SqlPrepareStatementStrategy} that supports named query 
parameters as well index based.
@@ -128,7 +129,7 @@ public class DefaultSqlPrepareStatementStrategy implements 
SqlPrepareStatementSt
             Object value = iterator.next();
 
             // special for SQL IN where we need to set dynamic number of values
-            if (value instanceof SqlInIterator) {
+            if (value instanceof CompositeIterator) {
                 Iterator it = (Iterator) value;
                 while (it.hasNext()) {
                     Object val = it.next();
@@ -210,7 +211,8 @@ public class DefaultSqlPrepareStatementStrategy implements 
SqlPrepareStatementSt
         return (map == null || map.isEmpty()) ? Collections.emptyMap() : map;
     }
 
-    protected static Iterator createInParameterIterator(Object value) {
+    @SuppressWarnings("unchecked")
+    protected static CompositeIterator createInParameterIterator(Object value) 
{
         Iterator it;
         // if the body is a String then honor quotes etc.
         if (value instanceof String) {
@@ -220,7 +222,9 @@ public class DefaultSqlPrepareStatementStrategy implements 
SqlPrepareStatementSt
         } else {
             it = ObjectHelper.createIterator(value, null);
         }
-        return new SqlInIterator(it);
+        CompositeIterator ci = new CompositeIterator();
+        ci.add(it);
+        return ci;
     }
 
     private static final class PopulateIterator implements Iterator<Object> {
@@ -251,6 +255,7 @@ public class DefaultSqlPrepareStatementStrategy implements 
SqlPrepareStatementSt
                 throw new NoSuchElementException();
             }
 
+            // is it a SQL in parameter
             boolean in = false;
             if (nextParam.startsWith("in:")) {
                 in = true;
@@ -261,6 +266,7 @@ public class DefaultSqlPrepareStatementStrategy implements 
SqlPrepareStatementSt
             try {
                 next = lookupParameter(nextParam, exchange, body);
                 if (in && next != null) {
+                    // if SQL IN we need to return an iterator that can 
iterate the parameter values
                     next = createInParameterIterator(next);
                 }
                 if (next == null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/a520ae76/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlInIterator.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlInIterator.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlInIterator.java
deleted file mode 100644
index d708ac2..0000000
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlInIterator.java
+++ /dev/null
@@ -1,58 +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.component.sql;
-
-import java.util.Iterator;
-import java.util.function.Consumer;
-
-/**
- * Iterator used for SQL IN query.
- * <p/>
- * This ensures we know the parameters is an IN parameter and the values are 
dynamic and must be
- * set using this iterator.
- */
-public class SqlInIterator implements Iterator {
-
-    private final Iterator it;
-
-    public SqlInIterator(Iterator it) {
-        this.it = it;
-    }
-
-    @Override
-    public boolean hasNext() {
-        return it.hasNext();
-    }
-
-    @Override
-    public Object next() {
-        return it.next();
-    }
-
-    @Override
-    public void remove() {
-        it.remove();
-    }
-
-    // This method should not have @Override as its a new method in Java 1.8
-    // and we need to compile for Java 1.7 also. TODO: enable again in Camel 
2.18 onwards
-    // @Override
-    @SuppressWarnings("unchecked")
-    public void forEachRemaining(Consumer action) {
-        it.forEachRemaining(action);
-    }
-}

Reply via email to