Source Code Cross Referenced for DateFormatSymbols.java in  » 6.0-JDK-Modules » j2me » com » sun » j2me » global » 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 » 6.0 JDK Modules » j2me » com.sun.j2me.global 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:        package com.sun.j2me.global;
027:
028:        import java.io.ByteArrayInputStream;
029:        import java.io.ByteArrayOutputStream;
030:        import java.io.DataInputStream;
031:        import java.io.DataOutputStream;
032:        import java.io.IOException;
033:        import javax.microedition.global.ResourceException;
034:
035:        /**
036:         *  <code>DateFormatSymbols</code> is class for encapsulating localizable
037:         *  date/time formatting data, such as the names of the months, the names of the
038:         *  days of the week, and the time zone data. <code>DateTimeFormat</code> uses
039:         *  <code>DateFormatSymbols</code> to encapsulate this information. <p>
040:         *
041:         *  DateFormatSymbols is typicaly obtained from <code>
042:         *  javax.microedition.ResourceManager</code> 
043:         *  respectively from <code>DevResourceManager.getDateFormatSymbols()</code>
044:         *  from resource file for given locale. <p>
045:         *
046:         *  Typically you shouldn't use <code>DateFormatSymbols</code> directly. Rather,
047:         *  you are encouraged to create a date/time formatter with the 
048:         *  <code>DateTimeFormat</code> class's factory methods: 
049:         *  <code>getInstance(int style, String locale)</code>
050:         *  These methods automatically create a <code>DateFormatSymbols</code> for the
051:         *  formatter so that you don't have to. All fields are public intentionaly.
052:         *
053:         */
054:        public class DateFormatSymbols implements  SerializableResource {
055:
056:            /**
057:             *  Create new DateFormatSymbol uninitialized.
058:             */
059:            public DateFormatSymbols() {
060:            }
061:
062:            /**
063:             * The method clones the resource.
064:             *
065:             * @return copy of the resource or <code>null<code>
066:             * if clonning wasn't possible 
067:             */
068:            public java.lang.Object clone() {
069:                DateFormatSymbols newDfs = null;
070:                try {
071:                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
072:                    write(baos);
073:                    baos.close();
074:                    byte[] buffer = baos.toByteArray();
075:                    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
076:                    newDfs = new DateFormatSymbols();
077:                    newDfs.read(bais);
078:                } catch (IOException ioe) {
079:                    // cannot clone resource
080:                }
081:                return newDfs;
082:            }
083:
084:            /**
085:             *  eras.
086:             */
087:            public String[] eras = new String[2];
088:
089:            /**
090:             *  month names.
091:             */
092:            public String[] months = new String[13];
093:
094:            /**
095:             *  short month names.
096:             */
097:            public String[] shortMonths = new String[13];
098:
099:            /**
100:             *  day in week names.
101:             */
102:            public String[] weekDays = new String[7];
103:
104:            /**
105:             *  short day in week names.
106:             */
107:            public String[] shortWeekDays = new String[7];
108:
109:            /**
110:             *  ampms.
111:             */
112:            public String[] ampms = new String[2];
113:
114:            /**
115:             *  localized patterns 6 possible styles as they are defined in {@link
116:             *  DateTimeFormat}.
117:             */
118:            public String[] patterns = new String[6];
119:
120:            /**
121:             *  locale of this symbols.
122:             */
123:            public String locale = new String();
124:
125:            /**
126:             * Read DateFormatSymbols object from input stream.
127:             *
128:             * @param  in    input stream
129:             * @throws  java.io.IOException error reading resource
130:             * @throws  javax.microedition.global.ResourceException  error creating
131:             * resource
132:             */
133:            public void read(java.io.InputStream in) throws IOException,
134:                    ResourceException {
135:                DataInputStream dis = new DataInputStream(in);
136:                readStrings(eras, dis);
137:                readStrings(months, dis);
138:                readStrings(shortMonths, dis);
139:                readStrings(weekDays, dis);
140:                readStrings(shortWeekDays, dis);
141:                readStrings(ampms, dis);
142:                readStrings(patterns, dis);
143:                locale = dis.readUTF();
144:            }
145:
146:            /**
147:             *  Serialize DateFormatSymbols object into output stream.
148:             *
149:             * @param   out output stream
150:             * @throws  java.io.IOException is thrown if write fails
151:             * @throws  javax.microedition.global.ResourceException  if resource 
152:             *          can't be written
153:             */
154:            public void write(java.io.OutputStream out) throws IOException,
155:                    ResourceException {
156:                DataOutputStream dous = new DataOutputStream(out);
157:                writeStrings(eras, dous);
158:                writeStrings(months, dous);
159:                writeStrings(shortMonths, dous);
160:                writeStrings(weekDays, dous);
161:                writeStrings(shortWeekDays, dous);
162:                writeStrings(ampms, dous);
163:                writeStrings(patterns, dous);
164:                dous.writeUTF(locale);
165:                dous.flush();
166:            }
167:
168:            /**
169:             * Write array helper. Writes string array.
170:             *
171:             * @param array strings to write
172:             * @param dous output stream
173:             * @throws IOException exception when write failed
174:             */
175:            protected void writeStrings(String[] array, DataOutputStream dous)
176:                    throws IOException {
177:                for (int i = 0; i < array.length; i++) {
178:                    dous.writeUTF(array[i]);
179:                }
180:            }
181:
182:            /**
183:             * Read strings helper. Reads string array.
184:             *
185:             * @param array string array to read to
186:             * @param dis  input stream
187:             * @throws IOException exception when read failed
188:             */
189:            protected void readStrings(String[] array, DataInputStream dis)
190:                    throws IOException {
191:                for (int i = 0; i < array.length; i++) {
192:                    array[i] = dis.readUTF();
193:                }
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.