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

The following examples show how to use org.apache.wicket.util.string.interpolator.VariableInterpolator. 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 File: FormComponent.java    From onedev with 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 File: ImageLinkModel.java    From the-app with 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 File: ImageLinkModel.java    From AppStash with 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();
}