KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > taglib > test > IterationTestTag


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 package org.apache.cocoon.taglib.test;
17
18 import org.apache.cocoon.taglib.IterationTag;
19 import org.apache.cocoon.taglib.TagSupport;
20 import org.xml.sax.Attributes JavaDoc;
21 import org.xml.sax.SAXException JavaDoc;
22
23 /**
24  * @author <a HREF="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
25  * @version CVS $Id: IterationTestTag.java 30932 2004-07-29 17:35:38Z vgritsenko $
26  */

27 public class IterationTestTag extends TagSupport implements IterationTag {
28
29     private int i = 0;
30     private int count = 2;
31     
32     /*
33      * @see Tag#doStartTag(String, String, String, Attributes)
34      */

35     public int doStartTag(String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc qName, Attributes JavaDoc atts) throws SAXException JavaDoc {
36         if (count > 0)
37             return EVAL_BODY;
38         return SKIP_BODY;
39     }
40     
41     /*
42      * @see IterationTag#doAfterBody()
43      */

44     public int doAfterBody() throws SAXException JavaDoc {
45         if (++i >= count)
46             return SKIP_BODY;
47         return EVAL_BODY_AGAIN;
48     }
49     
50     public void setCount(String JavaDoc count) {
51         this.count = Integer.parseInt(count);
52     }
53
54     /*
55      * @see Recyclable#recycle()
56      */

57     public void recycle() {
58         i = 0;
59         count = 2;
60         super.recycle();
61     }
62 }
63
Popular Tags