KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > examples > taglib > LocalesTag


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.examples.taglib;
18
19 import java.util.Locale JavaDoc;
20 import javax.servlet.jsp.JspException JavaDoc;
21 import javax.servlet.jsp.jstl.core.LoopTagSupport;
22
23 /**
24  * <p>Tag handler for &lt;locales&gt;
25  *
26  * @author Felipe Leme <jstl@felipeal.net>
27  * @version $Revision: 1.3 $ $Date: 2004/02/28 01:01:41 $
28  */

29 public class LocalesTag extends LoopTagSupport {
30
31     private static final Locale JavaDoc[] locales = Locale.getAvailableLocales();
32     private int pointer;
33     private String JavaDoc varTotal;
34
35     public void setVarTotal( String JavaDoc value ) {
36     varTotal = value;
37     }
38
39     public void prepare() {
40     pointer = 0;
41     if ( varTotal!=null && varTotal.length()>0 ) {
42         pageContext.setAttribute( varTotal, new Integer JavaDoc(locales.length) );
43     }
44     
45     }
46
47     public boolean hasNext() {
48     return pointer < locales.length;
49     }
50
51     public Object JavaDoc next() {
52     return locales[ pointer++ ];
53     }
54   
55     public void setBegin( int value ) {
56     super.begin = value;
57     }
58   
59     public void setEnd( int value ) {
60     super.end = value;
61     }
62 }
63
Popular Tags