1 16 17 package org.apache.taglibs.xtags.xpath; 18 19 import java.util.List ; 20 21 import javax.servlet.jsp.JspException ; 22 23 import org.dom4j.Node; 24 import org.dom4j.NodeFilter; 25 import org.dom4j.DocumentHelper; 26 27 32 public class IfTag extends AbstractTag { 33 34 35 private NodeFilter nodeFilter; 36 37 38 public IfTag() { 39 } 40 41 public int doStartTag() throws JspException { 44 if ( evaluate() ) { 45 return EVAL_BODY_INCLUDE; 46 } 47 return SKIP_BODY; 48 } 49 50 public boolean evaluate() throws JspException { 53 if ( nodeFilter != null ) { 54 return matches( nodeFilter ); 55 } 56 return false; 57 } 58 59 public void setTest( String test ) { 60 nodeFilter = createXPathFilter( test ); 61 } 62 63 public void setFilter( NodeFilter nodeFilter ) { 64 this.nodeFilter = nodeFilter; 65 } 66 } 67 | Popular Tags |