History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg2/java/util/PropertyResourceBundle.java (1 of 18352 files). Show all

Unified · Split

java/pkg2/java/util/PropertyResourceBundle.java+121−0
@@ -0,0 +1,121 @@
1+/*
2+ * @(#)PropertyResourceBundle.java 1.7 97/01/29
3+ *
4+ * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
5+ * (C) Copyright IBM Corp. 1996 - All Rights Reserved
6+ *
7+ * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
8+ *
9+ * The original version of this source code and documentation is copyrighted
10+ * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
11+ * materials are provided under terms of a License Agreement between Taligent
12+ * and Sun. This technology is protected by multiple US and International
13+ * patents. This notice and attribution to Taligent may not be removed.
14+ * Taligent is a registered trademark of Taligent, Inc.
15+ *
16+ * Permission to use, copy, modify, and distribute this software
17+ * and its documentation for NON-COMMERCIAL purposes and without
18+ * fee is hereby granted provided that this copyright notice
19+ * appears in all copies. Please refer to the file "copyright.html"
20+ * for further important copyright and licensing information.
21+ *
22+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
23+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
24+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
26+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
27+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
28+ *
29+ */
30+package java.util;
31+
32+import java.util.Properties;
33+import java.io.InputStream;
34+import java.io.IOException;
35+
36+/**
37+ * <code>PropertyResourceBundle</code> is an abstract subclass of
38+ * <code>ResourceBundle</code> that manages resources for a locale
39+ * using a set of static strings from a property file. See
40+ * <code>ResourceBundle</code> for more information about resource
41+ * bundles in general.
42+ *
43+ * <p>
44+ * The property file contains the keys that you use in your source code
45+ * in calls to <code>ResourceBundle.getString</code> and similar methods,
46+ * and their corresponding values, etc.
47+ * The name of the property file indicates the resource bundle's family
48+ * and locale.
49+ *
50+ * <p>
51+ * In the following example, the keys are of the form "s1"... The actual
52+ * keys are entirely up to your choice, so long as they are the same as
53+ * the keys you use in your program to retrieve the objects from the bundle.
54+ * Keys are case-sensitive.
55+ * <blockquote>
56+ * <pre>
57+ * s1=3
58+ * s2=MeinDisk
59+ * s3=3 Mar 96
60+ * s4=Der disk '{1}' a {0} a {2}.
61+ * s5=0
62+ * s6=keine Datein
63+ * s7=1
64+ * s8=ein Datei
65+ * s9=2
66+ * s10={0}|3 Datein
67+ * s11=Der Format worf ein Exception: {0}
68+ * s12=ERROR
69+ * s14=Resulte
70+ * s13=Dialogue
71+ * s15=Pattern
72+ * s16=1,3
73+ * </pre>
74+ * </blockquote>
75+ *
76+ * @see ResourceBundle
77+ * @see ListResourceBundle
78+ */
79+public class PropertyResourceBundle extends ResourceBundle {
80+ /**
81+ * Creates a property resource
82+ * @param file property file to read from.
83+ */
84+ public PropertyResourceBundle (InputStream stream) throws IOException {
85+ lookup.load(stream);
86+ }
87+
88+ /**
89+ * Override of ResourceBundle, same semantics
90+ */
91+ public Object handleGetObject(String key) {
92+ Object obj = lookup.get(key);
93+ return obj; // once serialization is in place, you can do non-strings
94+ }
95+
96+ /**
97+ * Implementation of ResourceBundle.getKeys.
98+ */
99+ public Enumeration getKeys() {
100+ Enumeration result = null;
101+ if (parent != null) {
102+ Hashtable temp = new Hashtable();
103+ for (Enumeration parentKeys = parent.getKeys() ;
104+ parentKeys.hasMoreElements() ; /* nothing */) {
105+ temp.put(parentKeys.nextElement(), this);
106+ }
107+ for (Enumeration thisKeys = lookup.keys();
108+ thisKeys.hasMoreElements() ; /* nothing */) {
109+ temp.put(thisKeys.nextElement(), this);
110+ }
111+ result = temp.keys();
112+ } else {
113+ result = lookup.keys();
114+ }
115+ return result;
116+ }
117+
118+ // ==================privates====================
119+
120+ private Properties lookup = new Properties();
121+}