KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > tag > common > core > ForTokensSupport


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.core;
18
19 import java.util.StringTokenizer JavaDoc;
20
21 import javax.servlet.jsp.JspTagException JavaDoc;
22 import javax.servlet.jsp.jstl.core.LoopTagSupport;
23
24 /**
25  * <p>Support for tag handlers for &lt;forTokens&gt;, the tokenizing
26  * iteration tag in JSTL 1.0. This class extends LoopTagSupport and
27  * provides ForTokens-specific functionality. The rtexprvalue and
28  * expression-evaluating libraries each have handlers that extend this
29  * class.</p>
30  *
31  * @see javax.servlet.jsp.jstl.core.LoopTagSupport
32  * @author Shawn Bayern
33  */

34
35 public abstract class ForTokensSupport extends LoopTagSupport {
36
37     //*********************************************************************
38
// Implementation overview
39

40     /*
41      * This handler simply constructs a StringTokenizer based on its input
42      * and relays tokens to the iteration implementation that it inherits.
43      * The 'items' and 'delims' attributes are expected to be provided by
44      * a subtag (presumably in the rtexprvalue or expression-evaluating
45      * versions of the JSTL library).
46      */

47
48
49     //*********************************************************************
50
// ForEachTokens-specific state (protected)
51

52     protected String JavaDoc items; // 'items' attribute
53
protected String JavaDoc delims; // 'delims' attribute
54
protected StringTokenizer JavaDoc st; // digested tokenizer
55

56
57     //*********************************************************************
58
// Iteration control methods
59

60     /*
61      * These just create and use a StringTokenizer.
62      * We inherit semantics and Javadoc from LoopTagSupport.
63      */

64
65     protected void prepare() throws JspTagException JavaDoc {
66       st = new StringTokenizer JavaDoc(items, delims);
67     }
68
69     protected boolean hasNext() throws JspTagException JavaDoc {
70         return st.hasMoreElements();
71     }
72
73     protected Object JavaDoc next() throws JspTagException JavaDoc {
74         return st.nextElement();
75     }
76
77
78     //*********************************************************************
79
// Tag logic and lifecycle management
80

81
82     // Releases any resources we may have (or inherit)
83
public void release() {
84         super.release();
85         items = delims = null;
86         st = null;
87     }
88
89 }
90
Popular Tags