查找模板 KEY 中所有的 :name, :name.property 参数替换成实际值。

@param key - 作为模板的 KEY
@param parameters - 传入的参数

@return 最终的缓存 KEY
@author 廖涵 in355hz@gmail.com
960122
private static String buildKey(String key, Map<String, Object> parameters) {
        // 匹配符合  :name 格式的参数
        Matcher matcher = PATTERN.matcher(key);
        if (matcher.find()) {

            StringBuilder builder = new StringBuilder();

            int index = 0;

            do {
                // 提取参数名称
                final String name = matcher.group(1).trim();

                Object value = null;

                // 解析  a.b.c 类型的名称 
                int find = name.indexOf('.');
                if (find >= 0) {

                    // 用  BeanWrapper 获取属性值
                    Object bean = parameters.get(name.substring(0, find));
                    if (bean != null) {
                        value = new BeanWrapperImpl(bean)
                                .getPropertyValue(name.substring(find + 1));
                    }

                } else {

                    // 获取参数值
                    value = parameters.get(name);
                }

                // 拼装参数值
                builder.append(key.substring(index, matcher.start()));
                builder.append(value);

                index = matcher.end();

            } while (matcher.find());

            // 拼装最后一段
            builder.append(key.substring(index));

            return builder.toString();
        }

        return key;
    }
274356
public static String getCipher(Map<String, Object> parameters) {
    return (String)parameters.get(ENCRYPTION_CIPHER_KEY);
  }
500984
@Override
	public Object doOutParameter(final String key, final Object val) {
		LOG.debug("Out parameter - Key:{}, value:{}", key, val);
		return val;
	}
1252715
public static String lookupParameterValue(String key, String string) {
		Pattern p = Pattern.compile("\\[" + key + "=[^\\]]*\\]");
		Matcher m = p.matcher(string);
		m.find();
    	String f = m.group();
    	int p1 = f.indexOf('=');
    	int p2 = f.indexOf(']');
    	return f.substring(p1+1, p2);
	}
75036
private static Map<String,String> parameterScanner(String parameters){
	
		String[] parametersArray = parameters.split(";");
		
		Map<String, String> localParametersMap = new HashMap<String, String>();
		
		for(int count=0;count < parametersArray.length; count++){
			String[] parameter  = parametersArray[count].split("=");
			localParametersMap.put(parameter[0], parameter[1]);
		}
		
		return localParametersMap;
	}
265313
public SqlPara getSqlPara(String key, Object... paras) {
		Template template = getSqlTemplate(key);
		if (template == null) {
			return null;
		}
		
		SqlPara sqlPara = new SqlPara();
		Map data = new HashMap();
		data.put(SQL_PARA_KEY, sqlPara);
		data.put(PARA_ARRAY_KEY, paras);
		sqlPara.setSql(template.renderToString(data));
		// data 为本方法中创建，不会污染用户数据，无需移除 SQL_PARA_KEY、PARA_ARRAY_KEY
		return sqlPara;
	}
297860
@NotNull
    protected Map<String, Object> toParameterTypes(ParameterElement... parameters) {
        final LinkedHashMap<String, Object> map = new LinkedHashMap<>(parameters.length);
        for (ParameterElement ce : parameters) {
            final ClassElement type = ce.getType();
            if (type == null) {
                continue;
            }
            final Type typeReference = getTypeForElement(type);
            map.put(ce.getName(), typeReference);
        }

        return map;
    }
1205662
def key(self, key=""):
    
    params = join_params(self.parameters, {"key": key})

    return self.__class__(**params)
644092
public String mandatoryParam(String key) {
    String value = param(key);
    checkArgument(value != null && !value.isEmpty(), format(MSG_PARAMETER_MISSING, key));
    return value;
  }
1070528
public String getMessage(String key, Object param)
    {
        return getMessage(key, new Object[]{param});
    }
645527
public String getMessage(String key, Locale locale, Object[] parameters)
	{
		if (null == locale)
		{
			return getMessage(key, parameters);
		}
		if (null == parameters)
		{
			return getMessage(key, locale);
		}
		if (null != key)
		{
			MessageFormat _messageFormat = new MessageFormat(getMessage(key, locale));
			return _messageFormat.format(parameters);
		}

		return null;
	}
509956
@SuppressWarnings("rawtypes")
	public Parameter createSubParameter(final String propertyName) {
		String subParameterName = parameterName + "." + propertyName;
		Object subValue = null;
		if (value != null) {
			if (value instanceof Map) {
				subValue = ((Map) value).get(propertyName);
				if (subValue == null) {
					LOG.warn("Set subparameter value to NULL because property can not be accessed.[{}]",
							subParameterName);
				}
			} else {
				try {
					// フィールドアクセスで値の取得を実施
					Field field = value.getClass().getDeclaredField(propertyName);
					field.setAccessible(true);
					subValue = field.get(value);
				} catch (NoSuchFieldException e) {
					// メソッドアクセスで値の取得を実施
					try {
						String prefix = boolean.class.equals(value.getClass()) ? "is" : "get";
						Method method = value.getClass()
								.getMethod(prefix + StringUtils.capitalize(propertyName));
						subValue = method.invoke(value);
					} catch (Exception e2) {
						LOG.warn("Set subparameter value to NULL because property can not be accessed.[{}]",
								subParameterName, e2);
					}
				} catch (Exception e) {
					LOG.warn("Set subparameter value to NULL because property can not be accessed.[{}]",
							subParameterName, e);
				}
			}
		}

		return new Parameter(subParameterName, subValue);
	}
302675
public ParameterValue getParameter(String name) {
        if (!getParameters().containsKey(name)) {
            return buildParameterValue();
        }

        return getParameters().get(name);
    }
1301844
private String getParameterValue(CmsObject cms, String key) {

        if (m_parameters == null) {
            m_parameters = getParameterMap(getStringValue(cms));
        }
        return getParameterValue(cms, m_parameters, key);
    }
198149
protected String generateParameterString(List<Parameter> parameters) {
    if (parameters == null) {
      return "";
    }

    StringBuilder parameterStringBuilder = new StringBuilder();
    boolean first = true;

    for (Parameter parameter : parameters) {
      if (first) {
        first = false;
      } else {
        parameterStringBuilder.append("&");
      }

      parameterStringBuilder.append(urlEncode(parameter.name));
      parameterStringBuilder.append("=");
      parameterStringBuilder.append(urlEncode(parameter.value));
    }

    return parameterStringBuilder.toString();
  }
853633
public String getMessage(String key, Object... params)
    {
        String message = getMessage(key);
        MessageFormat fmt = new MessageFormat(message);  
        return fmt.format(params);  
    }
61820
protected static String generateQueryString(Map<String, Object> parameters) {
        if (parameters == null || parameters.size() == 0) {
            return "";
        }
        StringBuilder result = new StringBuilder();
        try {
            for(Map.Entry<String, Object> entry : parameters.entrySet()) {
                // Check to see if the key/value isn't null or empty string
                if (entry.getKey() != null && (entry.getValue() != null && !entry.getValue().toString().equals(""))) {
                    result.append('&').append(URLEncoder.encode(entry.getKey(), "utf-8")).append("=")
                            .append(URLEncoder.encode(entry.getValue().toString(), "utf-8"));
                }
            }
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }

        return result.length() == 0 ? "" : "?" + result.substring(1);
    }