KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > scrape > ScrapeTag


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.scrape;
18
19 import java.util.*;
20 import javax.servlet.jsp.*;
21 import javax.servlet.jsp.tagext.*;
22
23 /**
24  * ScrapeTag - JSP tag <b>scrape</b> is used for setting the begin and end
25  * anchors of a scrape to be preformed by the parent tag of this
26  * tag, PageTag.
27  * <p>
28  * JSP Tag Lib Descriptor
29  * <p><pre>
30  * &lt;name&gt;scrape&lt;/name&gt;
31  * &lt;tagclass&gt;org.apache.taglibs.scrape.ScrapeTag&lt;/tagclass&gt;
32  * &lt;bodycontent&gt;empty&lt;/bodycontent&gt;
33  * &lt;info&gt;
34  * Does the scraping of the page named in the parent page tag
35  * &lt;/info&gt;
36  *
37  * &lt;attribute&gt;
38  * &lt;name&gt;id&lt;/name&gt;
39  * &lt;required&gt;true&lt;/required&gt;
40  * &lt;rtexprval&gt;false&lt;/rtexprval&gt;
41  * &lt;/attribute&gt;
42  * &lt;attribute&gt;
43  * &lt;name&gt;begin&lt;/name&gt;
44  * &lt;required&gt;true&lt;/required&gt;
45  * &lt;rtexprval&gt;false&lt;/rtexprval&gt;
46  * &lt;/attribute&gt;
47  * &lt;attribute&gt;
48  * &lt;name&gt;end&lt;/name&gt;
49  * &lt;required&gt;true&lt;/required&gt;
50  * &lt;rtexprval&gt;false&lt;/rtexprval&gt;
51  * &lt;/attribute&gt;
52  * &lt;attribute&gt;
53  * &lt;name&gt;strip&lt;/name&gt;
54  * &lt;required&gt;false&lt;/required&gt;
55  * &lt;rtexprval&gt;false&lt;/rtexprval&gt;
56  * &lt;/attribute&gt;
57  * &lt;attribute&gt;
58  * &lt;name&gt;anchors&lt;/name&gt;
59  * &lt;required&gt;false&lt;/required&gt;
60  * &lt;rtexprval&gt;false&lt;/rtexprval&gt;
61  * &lt;/attribute&gt;
62  * </pre></p></p>
63  *
64  * @author Rich Catlett
65  *
66  * @version 1.0
67  *
68  * @see ScrapeData
69  *
70  */

71 public class ScrapeTag extends TagSupport {
72
73     // the beginning anchor for the scrape
74
private String JavaDoc begin;
75     // the ending anchor for the scrape
76
private String JavaDoc end;
77     // flag determines if anchors are to be removed from result
78
private String JavaDoc anchor = "false";
79     // flag determines if tags are to be striped from the result
80
private String JavaDoc strip = "false";
81
82     /**
83      * implementation of method from the Tag interface that tells the JSP
84      * what to do upon encountering the end tag for this tag
85      *
86      * @throws JSPException thrown when error occurs in processing the body
87      * of this method
88      *
89      * @return EVAL_PAGE int telling the tag handler that the rest of the jsp
90      * page is to be evaluated
91      */

92   public final int doEndTag() throws JspException {
93       // parent tag must be a PageTag, gives access to methods in parent
94
PageTag myParent = (PageTag)findAncestorWithClass(this, PageTag.class);
95
96       if(myParent==null) {
97          throw new JspException("ScrapeTag without PageTag");
98       } else {
99          // place scrapedata object in scrapes HashMap in PageData object
100
myParent.setScrape(id, begin, end, anchor, strip);
101
102       }
103       return EVAL_PAGE;
104   }
105
106     /**
107      * setter method for the beginning anchor for this scrape
108      *
109      * @param begin anchor for the beginning of this scrape
110      *
111      */

112   public final void setBegin(String JavaDoc begin) {
113       this.begin = begin;
114   }
115
116     /**
117      * setter method for the ending anchor for this scrape
118      *
119      * @param end anchor for the end of this scrape
120      */

121   public final void setEnd(String JavaDoc end) {
122       this.end = end;
123   }
124
125     /**
126      * setter method for anchors
127      *
128      * @param anchors value to determine if anchors are included in result
129      *
130      */

131   public final void setAnchors(String JavaDoc anchors) {
132       anchor = anchors;
133   }
134
135     /**
136      * setter method for strip
137      *
138      * @param strip value determines if tags are to be removed from result
139      *
140      */

141   public final void setStrip(String JavaDoc strip) {
142     this.strip = strip;
143     }
144 }
145
Popular Tags