1 16 package org.apache.taglibs.string; 17 18 import javax.servlet.jsp.JspException ; 19 import org.apache.commons.lang.StringUtils; 20 import org.apache.commons.lang.math.NumberUtils; 21 22 40 public class LeftPadTag extends StringTagSupport { 41 42 private String delimiter; 43 private String width; 44 45 public LeftPadTag() { 46 super(); 47 } 48 49 54 public String getDelimiter() { 55 return this.delimiter; 56 } 57 58 63 public void setDelimiter(String delimiter) { 64 this.delimiter = delimiter; 65 } 66 67 68 73 public String getWidth() { 74 return this.width; 75 } 76 77 82 public void setWidth(String width) { 83 this.width = width; 84 } 85 86 87 88 public String changeString(String text) throws JspException { 89 return StringUtils.leftPad(text, NumberUtils.stringToInt(width), delimiter); 90 } 91 92 public void initAttributes() { 93 94 this.delimiter = " "; 95 96 this.width = "0"; 97 98 } 99 100 } 101 | Popular Tags |