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 38 public class CenterTag extends StringTagSupport { 39 40 private String delimiter; 41 private String width; 42 43 public CenterTag() { 44 super(); 45 } 46 47 52 public String getDelimiter() { 53 return this.delimiter; 54 } 55 56 61 public void setDelimiter(String delimiter) { 62 this.delimiter = delimiter; 63 } 64 65 66 71 public String getWidth() { 72 return this.width; 73 } 74 75 80 public void setWidth(String width) { 81 this.width = width; 82 } 83 84 85 86 public String changeString(String text) throws JspException { 87 return StringUtils.center(text, NumberUtils.stringToInt(width), delimiter); 88 } 89 90 public void initAttributes() { 91 92 this.delimiter = " "; 93 94 this.width = "0"; 95 96 } 97 98 } 99 | Popular Tags |