1 21 22 package org.opensubsystems.core.www; 23 24 import javax.servlet.jsp.JspException ; 25 import javax.servlet.jsp.tagext.BodyContent ; 26 import javax.servlet.jsp.tagext.BodyTagSupport ; 27 28 import org.opensubsystems.core.util.GlobalConstants; 29 import org.opensubsystems.core.util.StringUtils; 30 31 41 public class StringLimitTag extends BodyTagSupport 42 { 43 45 48 private static final long serialVersionUID = -6436264560155159257L; 49 50 54 protected String m_strLimit; 55 56 58 61 public StringLimitTag( 62 ) 63 { 64 super(); 65 } 66 67 69 72 public int doStartTag( 73 ) throws JspException 74 { 75 return (EVAL_BODY_BUFFERED); 78 } 79 80 83 public int doEndTag( 84 ) throws JspException 85 { 86 BodyContent content = getBodyContent(); 88 89 if (content != null) 90 { 91 int iLimit = Integer.parseInt(m_strLimit); 92 if (GlobalConstants.ERROR_CHECKING) 93 { 94 assert iLimit > 0 : "Limit has to be positive number."; 95 } 96 97 TagUtils.write(pageContext, 98 StringUtils.limitStringLength(iLimit, content.getString())); 99 } 100 101 return (EVAL_PAGE); 102 } 103 104 107 public String getLimit( 108 ) 109 { 110 return m_strLimit; 111 } 112 113 116 public void setLimit( 117 String strLimit 118 ) 119 { 120 m_strLimit = strLimit; 121 } 122 } 123 | Popular Tags |