1 16 package org.apache.taglibs.string; 17 18 import javax.servlet.jsp.JspException ; 19 import org.apache.commons.lang.StringUtils; 20 21 34 public class ChompTag extends StringTagSupport { 35 36 private String delimiter; 37 38 public ChompTag() { 39 super(); 40 } 41 42 47 public String getDelimiter() { 48 return this.delimiter; 49 } 50 51 56 public void setDelimiter(String delimiter) { 57 this.delimiter = delimiter; 58 } 59 60 public String changeString(String text) throws JspException { 61 return StringUtils.substringBeforeLast(text, delimiter); 62 } 63 64 public void initAttributes() { 65 66 this.delimiter = "\n"; 67 68 } 69 70 } 71 | Popular Tags |