1 16 17 package org.apache.taglibs.regexp; 18 19 import java.util.*; 20 import org.apache.oro.text.*; 21 import org.apache.oro.text.perl.*; 22 import org.apache.oro.text.regex.*; 23 import javax.servlet.*; 24 import javax.servlet.http.*; 25 import javax.servlet.jsp.*; 26 import javax.servlet.jsp.tagext.*; 27 28 72 73 public class ExistsMatchTag extends TagSupport 74 { 75 private String regexpid = null; 76 private String textid = null; 77 private boolean value = true; 78 79 84 public final int doStartTag() throws JspException 85 { 86 boolean result = false; 87 88 TextData td = (TextData)pageContext.getAttribute(textid,PageContext.PAGE_SCOPE); 89 if( td == null ) 90 throw new JspException( 91 "regexp tag existsmatch could not find text tag with id: " + 92 textid); 93 RegexpData rd = (RegexpData)pageContext.getAttribute(regexpid,PageContext.PAGE_SCOPE); 94 if( rd == null ) 95 throw new JspException( 96 "regexp tag existsmatch could not find regexp tag with id: " + 97 regexpid); 98 99 Perl5Util perl = new Perl5Util(rd.getPatternCache()); 100 if( perl.match(rd.getRegexp(),td.getText()) ) 101 result = true; 102 103 if( value == result ) 104 return EVAL_BODY_INCLUDE; 105 106 return SKIP_BODY; 107 } 108 109 114 public final void setRegexp(String str) 115 { 116 regexpid = str; 117 } 118 119 124 public final void setText(String str) 125 { 126 textid = str; 127 } 128 129 134 public final void setValue(boolean value) 135 { 136 this.value = value; 137 } 138 139 } 140 | Popular Tags |