/* the purpose of this method is to handle situations where a partial with a wildcard placeholder
is called with parameters that share key names with the partial. The value from the parameters should win
776840
function setValue(object, key, value) {
  if (key in object === true) return;
  object[key] = value;
}
1059580
private void setProperties(final JSONObject jsonObject, final List<Object> paramlist, final StringBuilder sql) {
        final Iterator<String> keys = jsonObject.keys();

        final StringBuilder insertString = new StringBuilder();
        final StringBuilder wildcardString = new StringBuilder();

        boolean isFirst = true;
        String key;
        Object value;

        while (keys.hasNext()) {
            key = keys.next();

            if (isFirst) {
                insertString.append("(").append(key);
                wildcardString.append("(?");
                isFirst = false;
            } else {
                insertString.append(",").append(key);
                wildcardString.append(",?");
            }

            value = jsonObject.get(key);
            paramlist.add(value);

            if (!keys.hasNext()) {
                insertString.append(")");
                wildcardString.append(")");
            }
        }

        sql.append("insert into ").append(getName()).append(insertString).append(" values ").append(wildcardString);
    }
39470
function(url, key, value) {
    var queryStrPos = url.indexOf('?');
    var anchorStrPos = url.lastIndexOf('#');
    
    var paramSeparator = '&';
    
    if(queryStrPos < 0) {
        // There's no query string.
        paramSeparator = '?';
    }
    
    if (anchorStrPos > 0) {
        // There's an anchor at the end, we need to insert our parameter before it
        var urlBeforeAnchor = url.substring(0, anchorStrPos);
        var urlAnchor = url.substring(anchorStrPos);
        return urlBeforeAnchor + paramSeparator + key + '=' + value + urlAnchor;
    } else {
        return url + paramSeparator + key + '=' + value;
    }
}
1252160
function(key, ctx, partials, returnFound) {
      var val = false,
          v = null,
          found = false,
          doModelGet = this.options.modelGet;

      for (var i = ctx.length - 1; i >= 0; i--) {
        v = ctx[i];
        val = findInScope(key, v, doModelGet);
        if (val != null) {
          found = true;
          break;
        }
      }

      if (!found) {
        return (returnFound) ? false : "";
      }

      if (!returnFound && typeof val == 'function') {
        val = this.mv(val, ctx, partials);
      }

      return val;
    }
1312961
private void throwExStrParam(MethodVisitor mv, Class<?> exCls) {
		String exSig = Type.getInternalName(exCls);
		mv.visitTypeInsn(NEW, exSig);
		mv.visitInsn(DUP);
		mv.visitLdcInsn("mapping " + this.className + " failed to map field:");
		mv.visitVarInsn(ALOAD, 2);
		mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "concat", "(Ljava/lang/String;)Ljava/lang/String;");
		mv.visitMethodInsn(INVOKESPECIAL, exSig, "<init>", "(Ljava/lang/String;)V");
		mv.visitInsn(ATHROW);
	}
1304969
private <T extends ProgramElementDoc> void mapTypeParameters(Map<String,List<T>> map, Object doc,
            T holder) {
        TypeVariable[] typeVariables;
        if (doc instanceof ClassDoc) {
            typeVariables = ((ClassDoc) doc).typeParameters();
        } else if (doc instanceof WildcardType) {
            for (Type extendsBound : ((WildcardType) doc).extendsBounds()) {
                addTypeParameterToMap(map, extendsBound, holder);
            }
            for (Type superBound : ((WildcardType) doc).superBounds()) {
                addTypeParameterToMap(map, superBound, holder);
            }
            return;
        } else if (doc instanceof ParameterizedType) {
            for (Type typeArgument : ((ParameterizedType) doc).typeArguments()) {
                addTypeParameterToMap(map, typeArgument, holder);
            }
            return;
        } else if (doc instanceof ExecutableMemberDoc) {
            typeVariables = ((ExecutableMemberDoc) doc).typeParameters();
        } else if (doc instanceof FieldDoc) {
            Type fieldType = ((FieldDoc) doc).type();
            mapTypeParameters(map, fieldType, holder);
            return;
        } else {
            return;
        }
        for (TypeVariable typeVariable : typeVariables) {
            for (Type bound : typeVariable.bounds()) {
                addTypeParameterToMap(map, bound, holder);
            }
        }
    }
297703
public FoxHttpRequestBuilder addFoxHttpPlaceholderEntry(String placeholder, String value) {
        foxHttpRequest.getFoxHttpClient().getFoxHttpPlaceholderStrategy().addPlaceholder(placeholder, value);
        return this;
    }
1006882
@Override
    public <K, V> MapAttribute<X, K, V> getDeclaredMap(String paramName, Class<K> keyClazz, Class<V> valueClazz)
    {
        PluralAttribute<X, ?, ?> declaredAttrib = getDeclaredPluralAttribute(paramName);

        if (onCheckMapAttribute(declaredAttrib, valueClazz))
        {
            if (valueClazz != null && valueClazz.equals(((MapAttribute<X, K, V>) declaredAttrib).getKeyJavaType()))
            {
                return (MapAttribute<X, K, V>) declaredAttrib;

            }
        }

        throw new IllegalArgumentException(
                "attribute of the given name and type is not present in the managed MapAttribute type, for name:"
                        + paramName + " , value type:" + valueClazz + "key tpye:" + keyClazz);
    }
302034
private Object getParameterValue(ControlBeanContext context, Method method, Object[] args) {
        Object value;
        try {
            value = context.getParameterValue(method, _nameQualifiers[0], args);
        } catch (IllegalArgumentException iae) {
            throw new ControlException("Invalid argument name in SQL statement: " + _nameQualifiers[0], iae);
        }

        for (int i = 1; i < _nameQualifiers.length; i++) {
            // handle maps, properties, and fields...
            value = extractValue(value, _nameQualifiers[i - 1], _nameQualifiers[i]);
        }
        return value;
    }
1289637
PartialMatch findOrCreate(char[] key)
  {

    if (tc.isEntryEnabled())
      tc.entry(this,cclass, "findOrCreate", "key: " + new String(key));

    for (PartialMatch pm = this;; pm = pm.next)
    {
      if (Arrays.equals(key, pm.key))
      {
        if (tc.isEntryEnabled())
          tc.exit(this,cclass, "findOrCreate", "pm: " + pm);
        return pm;
      }
      if (pm.next == null || pm.next.key.length > key.length)
      {
        // We didn't get an exact key match, so we need to make a new PartialMatch
        // structure
        pm.next = newPartialMatch(key, pm.next);

        if (tc.isEntryEnabled())
          tc.exit(this,cclass, "findOrCreate", "pm.next: " + pm.next);

        return pm.next;
      }
    }
  }
957715
@Override
    public void property(String name, String value, int nameValueSeparatorIndex)
            throws OperationFormatException {

        if(name != null) {
            // TODO this is not nice
            if(name.length() > 1 && name.charAt(0) == '-' && name.charAt(1) == '-') {
                assertValidParameterName(name.substring(2));
            } else if(name.length() > 0 && name.charAt(0) == '-') {
                assertValidParameterName(name.substring(1));
            } else {
                assertValidParameterName(name);
            }
        }

        if (value.isEmpty()) {
            throw new OperationFormatException("Parameter '" + value + "' is missing value.");
        }

        validatedProperty(name, value, nameValueSeparatorIndex);
    }
480018
private static boolean matchWildCards(String name, String template) {
        int wildcardIndex = template.indexOf("*");
        if (wildcardIndex == -1) {
            return name.equals(template);
        }

        boolean isBeginning = true;
        String beforeWildcard;
        String afterWildcard = template;
        while (wildcardIndex != -1) {
            beforeWildcard = afterWildcard.substring(0, wildcardIndex);
            afterWildcard = afterWildcard.substring(wildcardIndex + 1);

            int beforeStartIndex = name.indexOf(beforeWildcard);
            if ((beforeStartIndex == -1) || (isBeginning && beforeStartIndex != 0)) {
                return false;
            }
            isBeginning = false;

            name = name.substring(beforeStartIndex + beforeWildcard.length());
            wildcardIndex = afterWildcard.indexOf("*");
        }

        return name.endsWith(afterWildcard);
    }
165620
public void fillParameterValues(Map<String, Object> valuesMap) {
        AssertUtils.assertNotNull(valuesMap, "Value map cannot be null");

        if (this.sqlParameterNames != null) {

            String parameterName = null;
            this.sqlParameterValues = new ArrayList<Object>();

            // using for instead of iterator because this way I control position
            // I am getting.
            for (int i = 0; i < this.sqlParameterNames.size(); i++) {
                parameterName = this.sqlParameterNames.get(i);

                if (valuesMap.containsKey(parameterName) == true) {
                    this.sqlParameterValues.add(valuesMap.get(parameterName));
                } else {
                    throw new IllegalArgumentException(String.format(HandlersConstants.ERROR_PARAMETER_NOT_FOUND, parameterName));
                }
            }
        }
    }
255669
public ResourceAddress resolve(String... wildcards) {
        return resolve(new StatementContext() {
            @Override
            public String get(String key) {
                return null;
            }

            @Override
            public String[] getTuple(String key) {
                return null;
            }

            @Override
            public String resolve(String key) {
                return null;
            }

            @Override
            public String[] resolveTuple(String key) {
                return null;
            }

            @Override
            public LinkedList<String> collect(String key) {
                return null;
            }

            @Override
            public LinkedList<String[]> collectTuples(String key) {
                return null;
            }
        }, wildcards);
    }
1024093
function invokePartialWrapper(partial, context, options) {
  var env = Handlebars;
  if (options.hash) {
    context = Object.assign({}, context, options.hash);
    if (options.ids) {
      options.ids[0] = true;
    }
  }

  partial = env.VM.resolvePartial.call(env.VM, partial, context, options);
  var result = env.VM.invokePartial.call(env.VM, partial, context, options);

  if (result == null && env.compile) {
    options.partials[options.name] = env.compile(partial, options);
    result = options.partials[options.name](context, options);
  }

  if (result != null) {
    if (options.indent) {
      let lines = result.split('\n');
      for (let i = 0, l = lines.length; i < l; i++) {
        if (!lines[i] && i + 1 === l) {
          break;
        }

        lines[i] = options.indent + lines[i];
      }
      result = lines.join('\n');
    }
    return result;
  }

  throw new Exception('The partial ' + options.name + ' could not be compiled when running in runtime-only mode');
}
794857
function(key, ctx, partials, returnFound) {
      var val = false,
          v = null,
          found = false;

      for (var i = ctx.length - 1; i >= 0; i--) {
        v = ctx[i];
        if (v && typeof v == 'object' && key in v) {
          val = v[key];
          found = true;
          break;
        }
      }

      if (!found) {
        return (returnFound) ? false : "";
      }

      if (!returnFound && typeof val == 'function') {
        val = this.lv(val, ctx, partials);
      }

      return val;
    }
119690
function expandArrayPlaceholders(args){
	var sql = args[0];
	var params = args[1];
	if (!Array.isArray(params) || params.length === 0)
		return;
	var assocLengthsOfArrayParams = {};
	for (var i=0; i<params.length; i++)
		if (Array.isArray(params[i])){
			if (params[i].length === 0)
				throw Error("empty array in query params");
			assocLengthsOfArrayParams[i] = params[i].length;
		}
	if (Object.keys(assocLengthsOfArrayParams).length === 0)
		return;
	var arrParts = sql.split('?');
	if (arrParts.length - 1 !== params.length)
		throw Error("wrong parameter count");
	var expanded_sql = "";
	for (var i=0; i<arrParts.length; i++){
		expanded_sql += arrParts[i];
		if (i === arrParts.length-1) // last part
			break;
		var len = assocLengthsOfArrayParams[i];
		if (len) // array
			expanded_sql += _.fill(Array(len), "?").join(",");
		else
			expanded_sql += "?";
	}
	var flattened_params = _.flatten(params);
	args[0] = expanded_sql;
	args[1] = flattened_params;
}