Source Code Cross Referenced for DateFormatSymbols.java in  » Apache-Harmony-Java-SE » java-package » java » text » 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 » Apache Harmony Java SE » java package » java.text 
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 java.text;
019:
020:        import java.io.Serializable;
021:        import java.util.Arrays;
022:        import java.util.Locale;
023:
024:        /**
025:         * DateFormatSymbols holds the Strings used in the formating and parsing of
026:         * dates and times.
027:         */
028:        public class DateFormatSymbols implements  Serializable, Cloneable {
029:
030:            private static final long serialVersionUID = -5987973545549424702L;
031:
032:            private String localPatternChars;
033:
034:            String[] ampms, eras, months, shortMonths, shortWeekdays, weekdays;
035:
036:            String[][] zoneStrings;
037:
038:            /**
039:             * Constructs a new DateFormatSymbols containing the symbols for the default
040:             * Locale.
041:             */
042:            public DateFormatSymbols() {
043:                this (Locale.getDefault());
044:            }
045:
046:            /**
047:             * Constructs a new DateFormatSymbols containing the symbols for the
048:             * specified Locale.
049:             * 
050:             * @param locale
051:             *            the Locale
052:             */
053:            public DateFormatSymbols(Locale locale) {
054:                com.ibm.icu.text.DateFormatSymbols icuSymbols = new com.ibm.icu.text.DateFormatSymbols(
055:                        locale);
056:
057:                localPatternChars = icuSymbols.getLocalPatternChars();
058:                ampms = icuSymbols.getAmPmStrings();
059:                eras = icuSymbols.getEras();
060:                months = icuSymbols.getMonths();
061:                shortMonths = icuSymbols.getShortMonths();
062:                shortWeekdays = icuSymbols.getShortWeekdays();
063:                weekdays = icuSymbols.getWeekdays();
064:                zoneStrings = icuSymbols.getZoneStrings();
065:            }
066:
067:            /**
068:             * Answers a new DateFormatSymbols with the same symbols as this
069:             * DateFormatSymbols.
070:             * 
071:             * @return a shallow copy of this DateFormatSymbols
072:             * 
073:             * @see java.lang.Cloneable
074:             */
075:            @Override
076:            public Object clone() {
077:                try {
078:                    DateFormatSymbols symbols = (DateFormatSymbols) super 
079:                            .clone();
080:                    symbols.ampms = ampms.clone();
081:                    symbols.eras = eras.clone();
082:                    symbols.months = months.clone();
083:                    symbols.shortMonths = shortMonths.clone();
084:                    symbols.shortWeekdays = shortWeekdays.clone();
085:                    symbols.weekdays = weekdays.clone();
086:                    symbols.zoneStrings = new String[zoneStrings.length][];
087:                    for (int i = 0; i < zoneStrings.length; i++) {
088:                        symbols.zoneStrings[i] = zoneStrings[i].clone();
089:                    }
090:                    return symbols;
091:                } catch (CloneNotSupportedException e) {
092:                    return null;
093:                }
094:            }
095:
096:            /**
097:             * Compares the specified object to this DateFormatSymbols and answer if
098:             * they are equal. The object must be an instance of DateFormatSymbols with
099:             * the same symbols.
100:             * 
101:             * @param object
102:             *            the object to compare with this object
103:             * @return true if the specified object is equal to this DateFormatSymbols,
104:             *         false otherwise
105:             * 
106:             * @see #hashCode
107:             */
108:            @Override
109:            public boolean equals(Object object) {
110:                if (this  == object) {
111:                    return true;
112:                }
113:                if (!(object instanceof  DateFormatSymbols)) {
114:                    return false;
115:                }
116:                DateFormatSymbols obj = (DateFormatSymbols) object;
117:                if (!localPatternChars.equals(obj.localPatternChars)) {
118:                    return false;
119:                }
120:                if (!Arrays.equals(ampms, obj.ampms)) {
121:                    return false;
122:                }
123:                if (!Arrays.equals(eras, obj.eras)) {
124:                    return false;
125:                }
126:                if (!Arrays.equals(months, obj.months)) {
127:                    return false;
128:                }
129:                if (!Arrays.equals(shortMonths, obj.shortMonths)) {
130:                    return false;
131:                }
132:                if (!Arrays.equals(shortWeekdays, obj.shortWeekdays)) {
133:                    return false;
134:                }
135:                if (!Arrays.equals(weekdays, obj.weekdays)) {
136:                    return false;
137:                }
138:                if (zoneStrings.length != obj.zoneStrings.length) {
139:                    return false;
140:                }
141:                for (String[] element : zoneStrings) {
142:                    if (element.length != element.length) {
143:                        return false;
144:                    }
145:                    for (int j = 0; j < element.length; j++) {
146:                        if (element[j] != element[j]
147:                                && !(element[j].equals(element[j]))) {
148:                            return false;
149:                        }
150:                    }
151:                }
152:                return true;
153:            }
154:
155:            /**
156:             * Answers the array of Strings which represent AM and PM. Use the Calendar
157:             * constants Calendar.AM and Calendar.PM to index into the array.
158:             * 
159:             * @return an array of String
160:             */
161:            public String[] getAmPmStrings() {
162:                return ampms.clone();
163:            }
164:
165:            /**
166:             * Answers the array of Strings which represent BC and AD. Use the Calendar
167:             * constants GregorianCalendar.BC and GregorianCalendar.AD to index into the
168:             * array.
169:             * 
170:             * @return an array of String
171:             */
172:            public String[] getEras() {
173:                return eras.clone();
174:            }
175:
176:            /**
177:             * Answers the pattern characters used by SimpleDateFormat to specify date
178:             * and time fields.
179:             * 
180:             * @return a String containing the pattern characters
181:             */
182:            public String getLocalPatternChars() {
183:                return localPatternChars;
184:            }
185:
186:            /**
187:             * Answers the array of Strings containing the full names of the months. Use
188:             * the Calendar constants Calendar.JANUARY, etc. to index into the array.
189:             * 
190:             * @return an array of String
191:             */
192:            public String[] getMonths() {
193:                return months.clone();
194:            }
195:
196:            /**
197:             * Answers the array of Strings containing the abbreviated names of the
198:             * months. Use the Calendar constants Calendar.JANUARY, etc. to index into
199:             * the array.
200:             * 
201:             * @return an array of String
202:             */
203:            public String[] getShortMonths() {
204:                return shortMonths.clone();
205:            }
206:
207:            /**
208:             * Answers the array of Strings containing the abbreviated names of the days
209:             * of the week. Use the Calendar constants Calendar.SUNDAY, etc. to index
210:             * into the array.
211:             * 
212:             * @return an array of String
213:             */
214:            public String[] getShortWeekdays() {
215:                return shortWeekdays.clone();
216:            }
217:
218:            /**
219:             * Answers the array of Strings containing the full names of the days of the
220:             * week. Use the Calendar constants Calendar.SUNDAY, etc. to index into the
221:             * array.
222:             * 
223:             * @return an array of String
224:             */
225:            public String[] getWeekdays() {
226:                return weekdays.clone();
227:            }
228:
229:            /**
230:             * Answers the two-dimensional array of Strings containing the names of the
231:             * timezones. Each element in the array is an array of five Strings, the
232:             * first is a TimeZone ID, and second and third are the full and abbreviated
233:             * timezone names for standard time, and the fourth and fifth are the full
234:             * and abbreviated names for daylight time.
235:             * 
236:             * @return a two-dimensional array of String
237:             */
238:            public String[][] getZoneStrings() {
239:                String[][] clone = new String[zoneStrings.length][];
240:                for (int i = zoneStrings.length; --i >= 0;) {
241:                    clone[i] = zoneStrings[i].clone();
242:                }
243:                return clone;
244:            }
245:
246:            /**
247:             * Answers an integer hash code for the receiver. Objects which are equal
248:             * answer the same value for this method.
249:             * 
250:             * @return the receiver's hash
251:             * 
252:             * @see #equals
253:             */
254:            @Override
255:            public int hashCode() {
256:                int hashCode;
257:                hashCode = localPatternChars.hashCode();
258:                for (String element : ampms) {
259:                    hashCode += element.hashCode();
260:                }
261:                for (String element : eras) {
262:                    hashCode += element.hashCode();
263:                }
264:                for (String element : months) {
265:                    hashCode += element.hashCode();
266:                }
267:                for (String element : shortMonths) {
268:                    hashCode += element.hashCode();
269:                }
270:                for (String element : shortWeekdays) {
271:                    hashCode += element.hashCode();
272:                }
273:                for (String element : weekdays) {
274:                    hashCode += element.hashCode();
275:                }
276:                for (String[] element : zoneStrings) {
277:                    for (int j = 0; j < element.length; j++) {
278:                        if (element[j] != null) {
279:                            hashCode += element[j].hashCode();
280:                        }
281:                    }
282:                }
283:                return hashCode;
284:            }
285:
286:            /**
287:             * Sets the array of Strings which represent AM and PM. Use the Calendar
288:             * constants Calendar.AM and Calendar.PM to index into the array.
289:             * 
290:             * @param data
291:             *            the array of Strings
292:             */
293:            public void setAmPmStrings(String[] data) {
294:                ampms = data.clone();
295:            }
296:
297:            /**
298:             * Sets the array of Strings which represent BC and AD. Use the Calendar
299:             * constants GregorianCalendar.BC and GregorianCalendar.AD to index into the
300:             * array.
301:             * 
302:             * @param data
303:             *            the array of Strings
304:             */
305:            public void setEras(String[] data) {
306:                eras = data.clone();
307:            }
308:
309:            /**
310:             * Sets the pattern characters used by SimpleDateFormat to specify date and
311:             * time fields.
312:             * 
313:             * @param data
314:             *            the String containing the pattern characters
315:             * 
316:             * @exception NullPointerException
317:             *                when the data is null
318:             */
319:            public void setLocalPatternChars(String data) {
320:                if (data == null) {
321:                    throw new NullPointerException();
322:                }
323:                localPatternChars = data;
324:            }
325:
326:            /**
327:             * Sets the array of Strings containing the full names of the months. Use
328:             * the Calendar constants Calendar.JANUARY, etc. to index into the array.
329:             * 
330:             * @param data
331:             *            the array of Strings
332:             */
333:            public void setMonths(String[] data) {
334:                months = data.clone();
335:            }
336:
337:            /**
338:             * Sets the array of Strings containing the abbreviated names of the months.
339:             * Use the Calendar constants Calendar.JANUARY, etc. to index into the
340:             * array.
341:             * 
342:             * @param data
343:             *            the array of Strings
344:             */
345:            public void setShortMonths(String[] data) {
346:                shortMonths = data.clone();
347:            }
348:
349:            /**
350:             * Sets the array of Strings containing the abbreviated names of the days of
351:             * the week. Use the Calendar constants Calendar.SUNDAY, etc. to index into
352:             * the array.
353:             * 
354:             * @param data
355:             *            the array of Strings
356:             */
357:            public void setShortWeekdays(String[] data) {
358:                shortWeekdays = data.clone();
359:            }
360:
361:            /**
362:             * Sets the array of Strings containing the full names of the days of the
363:             * week. Use the Calendar constants Calendar.SUNDAY, etc. to index into the
364:             * array.
365:             * 
366:             * @param data
367:             *            the array of Strings
368:             */
369:            public void setWeekdays(String[] data) {
370:                weekdays = data.clone();
371:            }
372:
373:            /**
374:             * Sets the two-dimensional array of Strings containing the names of the
375:             * timezones. Each element in the array is an array of five Strings, the
376:             * first is a TimeZone ID, and second and third are the full and abbreviated
377:             * timezone names for standard time, and the fourth and fifth are the full
378:             * and abbreviated names for daylight time.
379:             * 
380:             * @param data
381:             *            the two-dimensional array of Strings
382:             */
383:            public void setZoneStrings(String[][] data) {
384:                zoneStrings = data.clone();
385:            }
386:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.