Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 the original author or authors.
   *
   * Licensed 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.dbflute.twowaysql.node;
 
 

Author(s):
modified by jflute (originated in S2Dao)
 
 public class BindVariableNode extends VariableNode {
 
     // ===================================================================================
     //                                                                         Constructor
     //                                                                         ===========
     public BindVariableNode(String expressionString testValueString specifiedSqlboolean blockNullParameter,
             NodeAdviceFactory nodeAdviceFactory) {
         super(expressiontestValuespecifiedSqlblockNullParameternodeAdviceFactory);
     }
 
     // ===================================================================================
     //                                                                              Accept
     //                                                                              ======
     @Override
     protected void doProcess(CommandContext ctxBoundValue boundValueLoopInfo loopInfo) {
         final Object finalValue = boundValue.getTargetValue();
         final Class<?> finalType = boundValue.getTargetType();
         if (isInScope()) {
             if (finalValue == null) { // in-scope does not allow null value
                 throwBindOrEmbeddedCommentParameterNullValueException(boundValue);
             }
             if (Collection.class.isAssignableFrom(finalType)) {
                 bindArray(ctx, ((Collection<?>) finalValue).toArray());
             } else if (finalType.isArray()) {
                 bindArray(ctxfinalValue);
             } else {
                 throwBindOrEmbeddedCommentInScopeNotListException(boundValue);
             }
         } else {
             ctx.addSql("?"finalValuefinalType); // if null, bind as null
             if (isAcceptableLikeSearch(loopInfo)) {
                 setupRearOption(ctxboundValue);
             }
         }
     }
 
     protected void bindArray(CommandContext ctxObject array) {
         if (array == null) {
             return;
         }
         final int length = Array.getLength(array);
         if (length == 0) {
         }
         Class<?> clazz = null;
         for (int i = 0; i < length; ++i) {
             final Object currentElement = Array.get(arrayi);
             if (currentElement != null) {
                 clazz = currentElement.getClass();
                 break;
             }
         }
         if (clazz == null) {
         }
         ctx.addSql("(");
         int validCount = 0;
         for (int i = 0; i < length; ++i) {
             final Object currentElement = Array.get(arrayi);
             if (currentElement != null) {
                 if (validCount > 0) {
                     ctx.addSql(", ");
                 }
                 ctx.addSql("?"currentElementclazz);
                 ++validCount;
             }
         }
         ctx.addSql(")");
     }
 
     // ===================================================================================
     //                                                                      Implementation
     //                                                                      ==============
    @Override
    protected ParameterCommentType getCommentType() {
        return .;
    }
New to GrepCode? Check out our FAQ X