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 CountMatchesTag extends StringTagSupport { 35 36 private String substring; 37 38 public CountMatchesTag() { 39 super(); 40 } 41 42 47 public String getSubstring() { 48 return this.substring; 49 } 50 51 56 public void setSubstring(String substring) { 57 this.substring = substring; 58 } 59 60 61 62 public String changeString(String text) throws JspException { 63 return ""+StringUtils.countMatches(text, substring); 64 } 65 66 public void initAttributes() { 67 68 this.substring = null; 69 70 } 71 72 } 73 | Popular Tags |