/**
  * Match input parameter values with the parameters declared to be used in the call.
  *
  * @param inParameters the input values
  * @return a Map containing the matched parameter names with the value taken from the input
  */
 public Map<String, ?> matchInParameterValuesWithCallParameters(Map<String, ?> inParameters) {
   if (!this.metaDataProvider.isProcedureColumnMetaDataUsed()) {
     return inParameters;
   }
   Map<String, String> callParameterNames =
       new HashMap<String, String>(this.callParameters.size());
   for (SqlParameter parameter : this.callParameters) {
     if (parameter.isInputValueProvided()) {
       String parameterName = parameter.getName();
       String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
       if (parameterNameToMatch != null) {
         callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName);
       }
     }
   }
   Map<String, Object> matchedParameters = new HashMap<String, Object>(inParameters.size());
   for (String parameterName : inParameters.keySet()) {
     String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
     String callParameterName = callParameterNames.get(parameterNameToMatch.toLowerCase());
     if (callParameterName == null) {
       if (logger.isDebugEnabled()) {
         Object value = inParameters.get(parameterName);
         if (value instanceof SqlParameterValue) {
           value = ((SqlParameterValue) value).getValue();
         }
         if (value != null) {
           logger.debug(
               "Unable to locate the corresponding IN or IN-OUT parameter for \""
                   + parameterName
                   + "\" in the parameters used: "
                   + callParameterNames.keySet());
         }
       }
     } else {
       matchedParameters.put(callParameterName, inParameters.get(parameterName));
     }
   }
   if (matchedParameters.size() < callParameterNames.size()) {
     for (String parameterName : callParameterNames.keySet()) {
       String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
       String callParameterName = callParameterNames.get(parameterNameToMatch.toLowerCase());
       if (!matchedParameters.containsKey(callParameterName)) {
         logger.warn(
             "Unable to locate the corresponding parameter value for '"
                 + parameterName
                 + "' within the parameter values provided: "
                 + inParameters.keySet());
       }
     }
   }
   if (logger.isDebugEnabled()) {
     logger.debug("Matching " + inParameters.keySet() + " with " + callParameterNames.values());
     logger.debug("Found match for " + matchedParameters.keySet());
   }
   return matchedParameters;
 }
 public Map<String, ?> matchInParameterValuesWithCallParameters(Object[] parameterValues) {
   Map<String, Object> matchedParameters = new HashMap<String, Object>(parameterValues.length);
   int i = 0;
   for (SqlParameter parameter : this.callParameters) {
     if (parameter.isInputValueProvided()) {
       String parameterName = parameter.getName();
       matchedParameters.put(parameterName, parameterValues[i++]);
     }
   }
   return matchedParameters;
 }
  /**
   * Match input parameter values with the parameters declared to be used in the call.
   *
   * @param parameterSource the input values
   * @return a Map containing the matched parameter names with the value taken from the input
   */
  public Map<String, Object> matchInParameterValuesWithCallParameters(
      SqlParameterSource parameterSource) {
    // For parameter source lookups we need to provide case-insensitive lookup support
    // since the database metadata is not necessarily providing case sensitive parameter names.
    Map<String, String> caseInsensitiveParameterNames =
        SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);

    Map<String, String> callParameterNames =
        new HashMap<String, String>(this.callParameters.size());
    Map<String, Object> matchedParameters = new HashMap<String, Object>(this.callParameters.size());
    for (SqlParameter parameter : this.callParameters) {
      if (parameter.isInputValueProvided()) {
        String parameterName = parameter.getName();
        String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
        if (parameterNameToMatch != null) {
          callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName);
        }
        if (parameterName != null) {
          if (parameterSource.hasValue(parameterName)) {
            matchedParameters.put(
                parameterName,
                SqlParameterSourceUtils.getTypedValue(parameterSource, parameterName));
          } else {
            String lowerCaseName = parameterName.toLowerCase();
            if (parameterSource.hasValue(lowerCaseName)) {
              matchedParameters.put(
                  parameterName,
                  SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName));
            } else {
              String englishLowerCaseName = parameterName.toLowerCase(Locale.ENGLISH);
              if (parameterSource.hasValue(englishLowerCaseName)) {
                matchedParameters.put(
                    parameterName,
                    SqlParameterSourceUtils.getTypedValue(parameterSource, englishLowerCaseName));
              } else {
                String propertyName = JdbcUtils.convertUnderscoreNameToPropertyName(parameterName);
                if (parameterSource.hasValue(propertyName)) {
                  matchedParameters.put(
                      parameterName,
                      SqlParameterSourceUtils.getTypedValue(parameterSource, propertyName));
                } else {
                  if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
                    String sourceName = caseInsensitiveParameterNames.get(lowerCaseName);
                    matchedParameters.put(
                        parameterName,
                        SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName));
                  } else {
                    logger.warn(
                        "Unable to locate the corresponding parameter value for '"
                            + parameterName
                            + "' within the parameter values provided: "
                            + caseInsensitiveParameterNames.values());
                  }
                }
              }
            }
          }
        }
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug(
          "Matching "
              + caseInsensitiveParameterNames.values()
              + " with "
              + callParameterNames.values());
      logger.debug("Found match for " + matchedParameters.keySet());
    }
    return matchedParameters;
  }