本文整理汇总了Java中org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver类的典型用法代码示例。如果您正苦于以下问题:Java PlaceholderResolver类的具体用法?Java PlaceholderResolver怎么用?Java PlaceholderResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlaceholderResolver类属于org.springframework.util.PropertyPlaceholderHelper包,在下文中一共展示了PlaceholderResolver类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: replacePlaceholders
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; //导入依赖的package包/类
/**
* Replaces each occurence of ${SOME_VALUE} with the varible SOME_VALUE in 'variables'
* If any error occures during parsing, i.e: variable doesn't exist, bad syntax, etc...
* a {@link PlaceholderResolutionException} is thrown, otherwise the new string after all replacements have been
* made will be returned.
*
* @param variables The variables map to match placeholders against
* @param value the string, possibly containing placeholders
* @return the value after placeholder replacement have been made
* @throws PlaceholderResolutionException if an empty placeholder is found
* or a place holder with no suitable value in 'variables'
*/
public static String replacePlaceholders(final Map<String, String> variables, final String value) throws PlaceholderResolutionException {
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${","}");
return helper.replacePlaceholders(value, new PlaceholderResolver() {
public String resolvePlaceholder(String key) {
if (key.isEmpty()) {
throw new PlaceholderResolutionException("Placeholder in '" + value + "' has to have a length of at least 1");
}
String result = variables.get(key);
if (result == null) {
throw new PlaceholderResolutionException("Missing value for placeholder: '" + key + "' in '" + value + "'");
}
return result;
}
});
}
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:30,代码来源:PlaceholderReplacer.java
示例2: StaticStringValueResolver
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; //导入依赖的package包/类
public StaticStringValueResolver(final Map<String, String> values) {
this.helper = new PropertyPlaceholderHelper("${", "}", ":", false);
this.resolver = new PlaceholderResolver() {
@Override
public String resolvePlaceholder(String placeholderName) {
return values.get(placeholderName);
}
};
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:StandaloneMockMvcBuilder.java
示例3: render
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; //导入依赖的package包/类
@Override
public void render(Map<String, ?> model, HttpServletRequest request,
HttpServletResponse response) throws Exception {
if (response.getContentType() == null) {
response.setContentType(getContentType());
}
Map<String, Object> map = new HashMap<String, Object>(model);
map.put("path", request.getContextPath());
PlaceholderResolver resolver = new ExpressionResolver(getExpressions(), map);
String result = this.helper.replacePlaceholders(this.template, resolver);
response.getWriter().append(result);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:ErrorMvcAutoConfiguration.java
示例4: render
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; //导入依赖的package包/类
@Override
public void render(Map<String, ?> model, HttpServletRequest request,
HttpServletResponse response) throws Exception {
if (response.getContentType() == null) {
response.setContentType(getContentType());
}
Map<String, Object> map = new HashMap<String, Object>(model);
map.put("path", request.getContextPath());
PlaceholderResolver resolver = new ExpressionResolver(this.expressions, map);
String result = this.helper.replacePlaceholders(this.template, resolver);
response.getWriter().append(result);
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:13,代码来源:ErrorMvcAutoConfiguration.java
示例5: SpelView
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; //导入依赖的package包/类
public SpelView(String template) {
this.template = template;
this.context.addPropertyAccessor(new MapAccessor());
this.helper = new PropertyPlaceholderHelper("${", "}");
this.resolver = new PlaceholderResolver() {
public String resolvePlaceholder(String name) {
Expression expression = parser.parseExpression(name);
Object value = expression.getValue(context);
return value==null ? null : value.toString();
}
};
}
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:13,代码来源:WhitelabelApprovalEndpoint.java
示例6: replacePlaceholders
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; //导入依赖的package包/类
/**
* replace placeholder in properties file with value;
* @param placeholders placeholder to replace
*/
public final void replacePlaceholders(Map<String, String> placeholders) {
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper(placeholderPrefix, placeholderSuffix, valueSeparator,
ignoreUnresolvablePlaceholders);
PlaceholderResolver resolver = new PlaceholderConfigurerResolver(placeholders);
for (Object key : this.properties.keySet()) {
Object val = this.properties.get(key);
this.properties.setProperty(key.toString(), helper.replacePlaceholders(val.toString(), resolver));
}
}
开发者ID:devacfr,项目名称:spring-restlet,代码行数:15,代码来源:PropertiesModule.java
示例7: initVarResolver
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private PlaceholderResolver initVarResolver(MessageHeaders headers) {
String name = DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER;
Map<String, String> vars = (Map<String, String>) headers.get(name);
return new DestinationVariablePlaceholderResolver(vars);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:SendToMethodReturnValueHandler.java
示例8: parseStringValue
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; //导入依赖的package包/类
/**
* Parse the given String value for placeholder resolution.
* @param strVal the String value to parse
* @param props the Properties to resolve placeholders against
* @param visitedPlaceholders the placeholders that have already been visited
* during the current resolution attempt (ignored in this version of the code)
* @deprecated as of Spring 3.0, in favor of using {@link #resolvePlaceholder}
* with {@link org.springframework.util.PropertyPlaceholderHelper}.
* Only retained for compatibility with Spring 2.5 extensions.
*/
@Deprecated
protected String parseStringValue(String strVal, Properties props, Set<?> visitedPlaceholders) {
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper(
placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders);
PlaceholderResolver resolver = new PropertyPlaceholderConfigurerResolver(props);
return helper.replacePlaceholders(strVal, resolver);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:PropertyPlaceholderConfigurer.java
注:本文中的org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论