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


001:        /*
002:         * 
003:         * @(#)ListResourceBundle.java	1.23 06/10/10
004:         * 
005:         * Portions Copyright  2000-2006 Sun Microsystems, Inc. All Rights
006:         * Reserved.  Use is subject to license terms.
007:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
008:         * 
009:         * This program is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU General Public License version
011:         * 2 only, as published by the Free Software Foundation.
012:         * 
013:         * This program is distributed in the hope that it will be useful, but
014:         * WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016:         * General Public License version 2 for more details (a copy is
017:         * included at /legal/license.txt).
018:         * 
019:         * You should have received a copy of the GNU General Public License
020:         * version 2 along with this work; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
022:         * 02110-1301 USA
023:         * 
024:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
025:         * Clara, CA 95054 or visit www.sun.com if you need additional
026:         * information or have any questions.
027:         */
028:
029:        /*
030:         * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
031:         * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
032:         *
033:         * The original version of this source code and documentation
034:         * is copyrighted and owned by Taligent, Inc., a wholly-owned
035:         * subsidiary of IBM. These materials are provided under terms
036:         * of a License Agreement between Taligent and Sun. This technology
037:         * is protected by multiple US and International patents.
038:         *
039:         * This notice and attribution to Taligent may not be removed.
040:         * Taligent is a registered trademark of Taligent, Inc.
041:         *
042:         */
043:
044:        package java.util;
045:
046:        /**
047:         * <code>ListResourceBundle</code> is an abstract subclass of
048:         * <code>ResourceBundle</code> that manages resources for a locale
049:         * in a convenient and easy to use list. See <code>ResourceBundle</code> for
050:         * more information about resource bundles in general.
051:         *
052:         * <P>
053:         * Subclasses must override <code>getContents</code> and provide an array,
054:         * where each item in the array is a pair of objects.
055:         * The first element of each pair is the key, which must be a
056:         * <code>String</code>, and the second element is the value associated with
057:         * that key.
058:         *
059:         * <p>
060:         * The following <a name="sample">example</a> shows two members of a resource
061:         * bundle family with the base name "MyResources".
062:         * "MyResources" is the default member of the bundle family, and
063:         * "MyResources_fr" is the French member.
064:         * These members are based on <code>ListResourceBundle</code>
065:         * (a related <a href="PropertyResourceBundle.html#sample">example</a> shows
066:         * how you can add a bundle to this family that's based on a properties file).
067:         * The keys in this example are of the form "s1" etc. The actual
068:         * keys are entirely up to your choice, so long as they are the same as
069:         * the keys you use in your program to retrieve the objects from the bundle.
070:         * Keys are case-sensitive.
071:         * <blockquote>
072:         * <pre>
073:         * 
074:         * public class MyResources extends ListResourceBundle {
075:         *     public Object[][] getContents() {
076:         *         return contents;
077:         *     }
078:         *     static final Object[][] contents = {
079:         *     // LOCALIZE THIS
080:         *         {"s1", "The disk \"{1}\" contains {0}."},  // MessageFormat pattern
081:         *         {"s2", "1"},                               // location of {0} in pattern
082:         *         {"s3", "My Disk"},                         // sample disk name
083:         *         {"s4", "no files"},                        // first ChoiceFormat choice
084:         *         {"s5", "one file"},                        // second ChoiceFormat choice
085:         *         {"s6", "{0,number} files"},                // third ChoiceFormat choice
086:         *         {"s7", "3 Mar 96"},                        // sample date
087:         *         {"s8", new Dimension(1,5)}                 // real object, not just string
088:         *     // END OF MATERIAL TO LOCALIZE
089:         *     };
090:         * }
091:         *
092:         * public class MyResources_fr extends ListResourceBundle {
093:         *     public Object[][] getContents() {
094:         *         return contents;
095:         *     }
096:         *     static final Object[][] contents = {
097:         *     // LOCALIZE THIS
098:         *         {"s1", "Le disque \"{1}\" {0}."},          // MessageFormat pattern
099:         *         {"s2", "1"},                               // location of {0} in pattern
100:         *         {"s3", "Mon disque"},                      // sample disk name
101:         *         {"s4", "ne contient pas de fichiers"},     // first ChoiceFormat choice
102:         *         {"s5", "contient un fichier"},             // second ChoiceFormat choice
103:         *         {"s6", "contient {0,number} fichiers"},    // third ChoiceFormat choice
104:         *         {"s7", "3 mars 1996"},                     // sample date
105:         *         {"s8", new Dimension(1,3)}                 // real object, not just string
106:         *     // END OF MATERIAL TO LOCALIZE
107:         *     };
108:         * }
109:         * </pre>
110:         * </blockquote>
111:         * @see ResourceBundle
112:         * @see PropertyResourceBundle
113:         * @since JDK1.1
114:         */
115:        public abstract class ListResourceBundle extends ResourceBundle {
116:            /**
117:             * Sole constructor.  (For invocation by subclass constructors, typically
118:             * implicit.)
119:             */
120:            public ListResourceBundle() {
121:            }
122:
123:            // Implements java.util.ResourceBundle.handleGetObject; inherits javadoc specification.
124:            public final Object handleGetObject(String key) {
125:                // lazily load the lookup hashtable.
126:                if (lookup == null) {
127:                    loadLookup();
128:                }
129:                if (key == null) {
130:                    throw new NullPointerException();
131:                }
132:                return lookup.get(key); // this class ignores locales
133:            }
134:
135:            /**
136:             * Implementation of ResourceBundle.getKeys.
137:             */
138:            public Enumeration getKeys() {
139:                // lazily load the lookup hashtable.
140:                if (lookup == null) {
141:                    loadLookup();
142:                }
143:
144:                ResourceBundle parent = this .parent;
145:                return new ResourceBundleEnumeration(lookup.keySet(),
146:                        (parent != null) ? parent.getKeys() : null);
147:            }
148:
149:            /**
150:             * See class description.
151:             */
152:            abstract protected Object[][] getContents();
153:
154:            // ==================privates====================
155:
156:            /**
157:             * We lazily load the lookup hashtable.  This function does the
158:             * loading.
159:             */
160:            private synchronized void loadLookup() {
161:                if (lookup != null)
162:                    return;
163:
164:                Object[][] contents = getContents();
165:                HashMap temp = new HashMap(contents.length);
166:                for (int i = 0; i < contents.length; ++i) {
167:                    // key must be non-null String, value must be non-null
168:                    String key = (String) contents[i][0];
169:                    Object value = contents[i][1];
170:                    if (key == null || value == null) {
171:                        throw new NullPointerException();
172:                    }
173:                    temp.put(key, value);
174:                }
175:                lookup = temp;
176:            }
177:
178:            private Map lookup = null;
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.