KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > tag > common > xml > ExprSupport


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.standard.tag.common.xml;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20 import javax.servlet.jsp.JspTagException JavaDoc;
21 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
22
23 /**
24  * <p>Tag handler for &lt;expr&gt; in JSTL's XML library.</p>
25  *
26  * @author Shawn Bayern
27  */

28
29 public abstract class ExprSupport extends TagSupport JavaDoc {
30
31     //*********************************************************************
32
// Internal state
33

34     private String JavaDoc select; // tag attribute
35
protected boolean escapeXml; // tag attribute
36

37     //*********************************************************************
38
// Construction and initialization
39

40     /**
41      * Constructs a new handler. As with TagSupport, subclasses should
42      * not provide other constructors and are expected to call the
43      * superclass constructor.
44      */

45     public ExprSupport() {
46         super();
47         init();
48     }
49
50     // resets local state
51
private void init() {
52     select = null;
53         escapeXml = true;
54     }
55
56
57     //*********************************************************************
58
// Tag logic
59

60     // applies XPath expression from 'select' and prints the result
61
public int doStartTag() throws JspException JavaDoc {
62         try {
63         XPathUtil xu = new XPathUtil(pageContext);
64         String JavaDoc result = xu.valueOf(XPathUtil.getContext(this), select);
65         org.apache.taglibs.standard.tag.common.core.OutSupport.out(
66               pageContext, escapeXml, result);
67         return SKIP_BODY;
68         } catch (java.io.IOException JavaDoc ex) {
69         throw new JspTagException JavaDoc(ex.toString(), ex);
70         }
71     }
72
73     // Releases any resources we may have (or inherit)
74
public void release() {
75         super.release();
76         init();
77     }
78
79
80     //*********************************************************************
81
// Attribute accessors
82

83     public void setSelect(String JavaDoc select) {
84     this.select = select;
85     }
86 }
87
Popular Tags