Java Code Examples for org.apache.wicket.util.string.interpolator.VariableInterpolator

The following examples show how to use org.apache.wicket.util.string.interpolator.VariableInterpolator. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: onedev   Source File: FormComponent.java    License: MIT License 5 votes vote down vote up
private String substitute(String string, final Map<String, Object> vars)
	throws IllegalStateException
{
	return new VariableInterpolator(string, Application.get()
		.getResourceSettings()
		.getThrowExceptionOnMissingResource())
	{
		private static final long serialVersionUID = 1L;

		@SuppressWarnings({ "rawtypes", "unchecked" })
		@Override
		protected String getValue(String variableName)
		{
			Object value = vars.get(variableName);
			
			if (value == null ||value instanceof String)
			{
				return String.valueOf(value);
			}
			
			IConverter converter = getConverter(value.getClass());
			
			if (converter == null)
			{
				return Strings.toString(value);
			}
			else
			{
				return converter.convertToString(value, getLocale());
			}
		}
	}.toString();
}
 
Example 2
Source Project: the-app   Source File: ImageLinkModel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String getObject() {
    VariableInterpolator interpolator = new MapVariableInterpolator(TEMPLATE, ImmutableMap.builder()
            .put("contextPath", parent.getRequestCycle().getRequest().getContextPath())
            .put("type", productInfoModel.getObject().getType().getUrlname())
            .put("name", productInfoModel.getObject().getUrlname())
            .build());
    return interpolator.toString();
}
 
Example 3
Source Project: AppStash   Source File: ImageLinkModel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String getObject() {
    VariableInterpolator interpolator = new MapVariableInterpolator(TEMPLATE, ImmutableMap.builder()
            .put("contextPath", parent.getRequestCycle().getRequest().getContextPath())
            .put("type", productInfoModel.getObject().getType().getUrlname())
            .put("name", productInfoModel.getObject().getUrlname())
            .build());
    return interpolator.toString();
}