Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Creative commons Attribution-NonCommercial license. http://creativecommons.org/licenses/by-nc/2.5/au/deed.en_GB NO WARRANTY IS GIVEN OR IMPLIED, USE AT YOUR OWN RISK.
 
 package base.template;
 
public class StringAttributeRenderer implements AttributeRenderer {
	public String toString(Object oString formatLocale locale) {
		if(format == null || o == null) {
			return (String)o;
		}
		if(format.equals("html")) {
			return StringHelper.escapeHtml((String)o);
		}
		if(format.equals("uppercase")) {
			return ((String)o).toUpperCase();
		}
		if(format.equals("lowercase")) {
			return ((String)o).toLowerCase();
		}
		if(format.equals("url")) {
			return StringHelper.urlEscape((String)o);
		}
		if(format.startsWith("max")) {
			return StringHelper.maxLength((String)o, Integer.parseInt(format.substring(3)));
		}
		if(format.startsWith("htmlmax")) {
			return StringHelper.escapeHtml(StringHelper.maxLength((String)o, Integer.parseInt(format.substring(7))));
		}
		return (String)o;
	}
New to GrepCode? Check out our FAQ X