Source Code Cross Referenced for MonthsTag.java in  » Web-Framework » cocoon » org » apache » cocoon » taglib » datetime » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » cocoon » org.apache.cocoon.taglib.datetime 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.cocoon.taglib.datetime;
019:
020:        import java.text.DateFormatSymbols;
021:        import java.util.Locale;
022:
023:        import org.apache.cocoon.taglib.IterationTag;
024:        import org.apache.cocoon.taglib.TagSupport;
025:        import org.apache.cocoon.taglib.VarTagSupport;
026:        import org.apache.cocoon.taglib.i18n.LocaleTag;
027:        import org.xml.sax.Attributes;
028:        import org.xml.sax.SAXException;
029:
030:        /**
031:         * Tag <b>months</b>, used to loop through all the months of the year.
032:         * <p>
033:         * The script variable of name <b>var</b> is availble only within the
034:         * body of the <b>months</b> tag.
035:         *
036:         * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
037:         * @version CVS $Id: MonthsTag.java 433543 2006-08-22 06:22:54Z crossley $
038:         */
039:        public class MonthsTag extends VarTagSupport implements  IterationTag {
040:            private String[] short_months = null;
041:            private String[] long_months = null;
042:            private int month;
043:            private int month_num;
044:
045:            /**
046:             * Initializes tag so it can loop through the months of the year.
047:             *
048:             * @return EVAL_BODY
049:             */
050:            public final int doStartTag(String namespaceURI, String localName,
051:                    String qName, Attributes atts) throws SAXException {
052:                // Initialize variables
053:                month = 0;
054:                month_num = 1;
055:
056:                Locale locale = null;
057:                LocaleTag localeTag = (LocaleTag) TagSupport
058:                        .findAncestorWithClass(this , LocaleTag.class);
059:                if (localeTag != null) {
060:                    locale = localeTag.getLocale();
061:                } else {
062:                    locale = Locale.getDefault();
063:                }
064:
065:                DateFormatSymbols dfs = new DateFormatSymbols(locale);
066:                short_months = dfs.getShortMonths();
067:                long_months = dfs.getMonths();
068:
069:                // Make sure we skip any blank array elements
070:                while (month < long_months.length
071:                        && (long_months[month] == null || long_months[month]
072:                                .length() == 0)) {
073:                    month++;
074:                }
075:
076:                if (month >= short_months.length)
077:                    return SKIP_BODY;
078:
079:                setVariable(var, this );
080:                return EVAL_BODY;
081:            }
082:
083:            /*
084:             * @see Tag#doEndTag(String, String, String)
085:             */
086:            public int doEndTag(String namespaceURI, String localName,
087:                    String qName) throws SAXException {
088:                removeVariable(var);
089:                return EVAL_PAGE;
090:            }
091:
092:            /**
093:             * Method called at end of each months tag.
094:             *
095:             * @return EVAL_BODY_TAG if there is another month, or SKIP_BODY if there are no more months
096:             */
097:            public final int doAfterBody() throws SAXException {
098:                // See if we are done looping through months
099:                month++;
100:                month_num++;
101:                if (month >= short_months.length)
102:                    return SKIP_BODY;
103:
104:                // Make sure we skip any blank array elements
105:                while (month < long_months.length
106:                        && (long_months[month] == null || long_months[month]
107:                                .length() == 0)) {
108:                    month++;
109:                }
110:
111:                if (month >= short_months.length)
112:                    return SKIP_BODY;
113:
114:                // There is another month, so loop again
115:                return EVAL_BODY_AGAIN;
116:            }
117:
118:            /**
119:             * Returns the short name of the month.
120:             *
121:             * @return String - short name of the month
122:             */
123:            public final String getShortMonth() {
124:                return short_months[month];
125:            }
126:
127:            /**
128:             * Returns the long name of the month.
129:             *
130:             * @return String - long name of the month
131:             */
132:            public final String getMonth() {
133:                return long_months[month];
134:            }
135:
136:            /**
137:             * Returns the number of the month.
138:             *             
139:             * @return String - number of the month
140:             */
141:            public final String getMonthOfYear() {
142:                if (month_num < 10)
143:                    return "0" + month_num;
144:                return "" + month_num;
145:            }
146:
147:            /*
148:             * @see Recyclable#recycle()
149:             */
150:            public void recycle() {
151:                this.short_months = null;
152:                this.long_months = null;
153:                super.recycle();
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.