1 16 package org.apache.taglibs.string; 17 18 import javax.servlet.jsp.JspException ; 19 import org.apache.taglibs.string.util.StringW; 20 import org.apache.commons.lang.math.NumberUtils; 21 22 45 public class TruncateNicelyTag extends StringTagSupport { 46 47 private String stripMarkup; 48 private String lower; 49 private String upper; 50 private String appendToEnd; 51 52 public TruncateNicelyTag() { 53 super(); 54 } 55 56 60 public String getLower() { 61 return this.lower; 62 } 63 64 68 public void setLower(String l) { 69 this.lower = l; 70 } 71 72 76 public String getUpper() { 77 return this.upper; 78 } 79 80 84 public void setUpper(String u) { 85 this.upper = u; 86 } 87 88 public String getAppendToEnd() { 89 return this.appendToEnd; 90 } 91 92 public void setAppendToEnd(String s) { 93 this.appendToEnd = s; 94 } 95 96 public String changeString(String text) throws JspException { 97 98 int l = NumberUtils.stringToInt(lower); 99 int u = NumberUtils.stringToInt(upper); 100 101 return StringW.truncateNicely(text, l, u, this.appendToEnd); 102 } 103 104 public void initAttributes() { 105 106 this.lower = "10"; 107 this.upper = "-1"; 108 this.appendToEnd = "..."; 109 110 } 111 112 } 113 | Popular Tags |