1 17 package javax.servlet.jsp.tagext; 18 19 import javax.servlet.jsp.JspContext ; 20 import javax.servlet.jsp.JspException ; 21 import java.io.IOException ; 22 23 34 public class SimpleTagSupport 35 implements SimpleTag 36 { 37 38 private JspTag parentTag; 39 40 41 private JspContext jspContext; 42 43 44 private JspFragment jspBody; 45 46 50 public SimpleTagSupport() { 51 } 52 53 69 public void doTag() 70 throws JspException , IOException 71 { 72 } 73 74 82 public void setParent( JspTag parent ) { 83 this.parentTag = parent; 84 } 85 86 91 public JspTag getParent() { 92 return this.parentTag; 93 } 94 95 103 public void setJspContext( JspContext pc ) { 104 this.jspContext = pc; 105 } 106 107 113 protected JspContext getJspContext() { 114 return this.jspContext; 115 } 116 117 125 public void setJspBody( JspFragment jspBody ) { 126 this.jspBody = jspBody; 127 } 128 129 135 protected JspFragment getJspBody() { 136 return this.jspBody; 137 } 138 139 178 public static final JspTag findAncestorWithClass( 179 JspTag from, Class <?> klass) 180 { 181 boolean isInterface = false; 182 183 if (from == null || klass == null 184 || (!JspTag .class.isAssignableFrom(klass) 185 && !(isInterface = klass.isInterface()))) { 186 return null; 187 } 188 189 for (;;) { 190 JspTag parent = null; 191 if( from instanceof SimpleTag ) { 192 parent = ((SimpleTag )from).getParent(); 193 } 194 else if( from instanceof Tag ) { 195 parent = ((Tag )from).getParent(); 196 } 197 if (parent == null) { 198 return null; 199 } 200 201 if (parent instanceof TagAdapter ) { 202 parent = ((TagAdapter ) parent).getAdaptee(); 203 } 204 205 if ((isInterface && klass.isInstance(parent)) 206 || klass.isAssignableFrom(parent.getClass())) { 207 return parent; 208 } 209 210 from = parent; 211 } 212 } 213 } 214 | Popular Tags |