1 17 package javax.servlet.jsp.tagext; 18 19 import java.io.Serializable ; 20 import java.util.Enumeration ; 21 import java.util.Hashtable ; 22 23 import javax.servlet.jsp.JspException ; 24 import javax.servlet.jsp.PageContext ; 25 26 39 40 public class TagSupport implements IterationTag , Serializable { 41 42 75 76 public static final Tag findAncestorWithClass(Tag from, Class klass) { 77 boolean isInterface = false; 78 79 if (from == null || 80 klass == null || 81 (!Tag .class.isAssignableFrom(klass) && 82 !(isInterface = klass.isInterface()))) { 83 return null; 84 } 85 86 for (;;) { 87 Tag tag = from.getParent(); 88 89 if (tag == null) { 90 return null; 91 } 92 93 if ((isInterface && klass.isInstance(tag)) || 94 klass.isAssignableFrom(tag.getClass())) 95 return tag; 96 else 97 from = tag; 98 } 99 } 100 101 109 110 public TagSupport() { } 111 112 120 121 public int doStartTag() throws JspException { 122 return SKIP_BODY; 123 } 124 125 133 134 public int doEndTag() throws JspException { 135 return EVAL_PAGE; 136 } 137 138 139 147 148 public int doAfterBody() throws JspException { 149 return SKIP_BODY; 150 } 151 152 154 155 160 161 public void release() { 162 parent = null; 163 id = null; 164 if( values != null ) { 165 values.clear(); 166 } 167 values = null; 168 } 169 170 176 177 public void setParent(Tag t) { 178 parent = t; 179 } 180 181 187 188 public Tag getParent() { 189 return parent; 190 } 191 192 197 198 public void setId(String id) { 199 this.id = id; 200 } 201 202 207 208 public String getId() { 209 return id; 210 } 211 212 218 219 public void setPageContext(PageContext pageContext) { 220 this.pageContext = pageContext; 221 } 222 223 229 230 public void setValue(String k, Object o) { 231 if (values == null) { 232 values = new Hashtable <String , Object >(); 233 } 234 values.put(k, o); 235 } 236 237 243 244 public Object getValue(String k) { 245 if (values == null) { 246 return null; 247 } else { 248 return values.get(k); 249 } 250 } 251 252 257 258 public void removeValue(String k) { 259 if (values != null) { 260 values.remove(k); 261 } 262 } 263 264 270 271 public Enumeration <String > getValues() { 272 if (values == null) { 273 return null; 274 } 275 return values.keys(); 276 } 277 278 280 private Tag parent; 281 private Hashtable <String , Object > values; 282 285 protected String id; 286 287 289 292 protected PageContext pageContext; 293 } 294 295 | Popular Tags |