Source Code Cross Referenced for Holiday.java in  » Internationalization-Localization » icu4j » com » ibm » icu » util » 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 » Internationalization Localization » icu4j » com.ibm.icu.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 1996-2006, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:
008:        package com.ibm.icu.util;
009:
010:        import java.util.Date;
011:        import java.util.Locale;
012:        import java.util.MissingResourceException;
013:        import java.util.ResourceBundle;
014:
015:        /**
016:         * An abstract class representing a holiday.
017:         * @draft ICU 2.8 (retainAll)
018:         * @provisional This API might change or be removed in a future release.
019:         */
020:        public abstract class Holiday implements  DateRule {
021:            /**
022:             * @draft ICU 2.8
023:             * @provisional This API might change or be removed in a future release.
024:             */
025:            public static Holiday[] getHolidays() {
026:                return getHolidays(ULocale.getDefault());
027:            }
028:
029:            /**
030:             * @draft ICU 2.8
031:             * @provisional This API might change or be removed in a future release.
032:             */
033:            public static Holiday[] getHolidays(Locale locale) {
034:                return getHolidays(ULocale.forLocale(locale));
035:            }
036:
037:            /**
038:             * @draft ICU 3.2
039:             * @provisional This API might change or be removed in a future release.
040:             */
041:            public static Holiday[] getHolidays(ULocale locale) {
042:                Holiday[] result = noHolidays;
043:
044:                try {
045:                    ResourceBundle bundle = UResourceBundle.getBundleInstance(
046:                            "HolidayBundle", locale);
047:
048:                    result = (Holiday[]) bundle.getObject("holidays");
049:                } catch (MissingResourceException e) {
050:                }
051:                return result;
052:            }
053:
054:            /**
055:             * Return the first occurrance of this holiday on or after the given date
056:             *
057:             * @param start Only holidays on or after this date are returned.
058:             *
059:             * @return      The date on which this holiday occurs, or null if it
060:             *              does not occur on or after the start date.
061:             *
062:             * @see #firstBetween
063:             * @draft ICU 2.8
064:             * @provisional This API might change or be removed in a future release.
065:             */
066:            public Date firstAfter(Date start) {
067:                return rule.firstAfter(start);
068:            }
069:
070:            /**
071:             * Return the first occurrance of this holiday that is on or after
072:             * the given start date and before the given end date.
073:             *
074:             * @param start Only occurrances on or after this date are returned.
075:             * @param end   Only occurrances before this date are returned.
076:             *
077:             * @return      The date on which this event occurs, or null if it
078:             *              does not occur between the start and end dates.
079:             *
080:             * @see #firstAfter
081:             * @draft ICU 2.8
082:             * @provisional This API might change or be removed in a future release.
083:             */
084:            public Date firstBetween(Date start, Date end) {
085:                return rule.firstBetween(start, end);
086:            }
087:
088:            /**
089:             * Checks whether this holiday falls on the given date.  This does
090:             * <em>not</em> take time of day into account; instead it checks
091:             * whether the holiday and the given date are on the same day.
092:             *
093:             * @param date  The date to check.
094:             * @return      true if this holiday occurs on the given date.
095:             * @draft ICU 2.8
096:             * @provisional This API might change or be removed in a future release.
097:             */
098:            public boolean isOn(Date date) {
099:                //System.out.println(name + ".isOn(" + date.toString() + "):");
100:                return rule.isOn(date);
101:            }
102:
103:            /**
104:             * Check whether this holiday occurs at least once between the two
105:             * dates given.
106:             * @draft ICU 2.8
107:             * @provisional This API might change or be removed in a future release.
108:             */
109:            public boolean isBetween(Date start, Date end) {
110:                return rule.isBetween(start, end);
111:            }
112:
113:            /**
114:             * Construct a new Holiday object.  This is for use by subclasses only.
115:             * This constructs a new holiday with the given name and date rules.
116:             *
117:             * @param name  The name of this holiday.  The getDisplayName method
118:             *              uses this string as a key to look up the holiday's name a
119:             *              resource bundle object named HolidayBundle.
120:             *
121:             * @param rule  The date rules used for determining when this holiday
122:             *              falls.  Holiday's implementation of the DateRule inteface
123:             *              simply delegates to this DateRule object.
124:             * @draft ICU 2.8
125:             * @provisional This API might change or be removed in a future release.
126:             */
127:            protected Holiday(String name, DateRule rule) {
128:                this .name = name;
129:                this .rule = rule;
130:            }
131:
132:            /**
133:             * Return the name of this holiday in the language of the default locale
134:             * @draft ICU 2.8
135:             * @provisional This API might change or be removed in a future release.
136:             */
137:            public String getDisplayName() {
138:                return getDisplayName(ULocale.getDefault());
139:            }
140:
141:            /**
142:             * Return the name of this holiday in the language of the specified locale
143:             * The <code>name</code> parameter passed to this object's constructor is used
144:             * as a key to look up the holiday's localized name in a ResourceBundle object
145:             * named HolidayBundle.
146:             *
147:             * @param locale   A locale specifying the language in which the name is desired.
148:             *
149:             * @see ResourceBundle
150:             * @draft ICU 2.8
151:             * @provisional This API might change or be removed in a future release.
152:             */
153:            public String getDisplayName(Locale locale) {
154:                return getDisplayName(ULocale.forLocale(locale));
155:            }
156:
157:            /**
158:             * Return the name of this holiday in the language of the specified locale
159:             * The <code>name</code> parameter passed to this object's constructor is used
160:             * as a key to look up the holiday's localized name in a ResourceBundle object
161:             * named HolidayBundle.
162:             *
163:             * @param locale   A locale specifying the language in which the name is desired.
164:             *
165:             * @see ResourceBundle
166:             * @draft ICU 3.2
167:             * @provisional This API might change or be removed in a future release.
168:             */
169:            public String getDisplayName(ULocale locale) {
170:                String name = this .name;
171:
172:                try {
173:                    ResourceBundle bundle = UResourceBundle.getBundleInstance(
174:                            "HolidayBundle", locale);
175:                    name = bundle.getString(name);
176:                } catch (MissingResourceException e) {
177:                    //System.out.println("Using default display name for " + name);
178:                }
179:                return name;
180:            }
181:
182:            /**
183:             * @draft ICU 2.8
184:             * @provisional This API might change or be removed in a future release.
185:             */
186:            public DateRule getRule() {
187:                return rule;
188:            }
189:
190:            /**
191:             * @draft ICU 2.8
192:             * @provisional This API might change or be removed in a future release.
193:             */
194:            public void setRule(DateRule rule) {
195:                this .rule = rule;
196:            }
197:
198:            private String name;
199:            private DateRule rule;
200:
201:            private static Holiday[] noHolidays = {};
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.