0N/A/*
2362N/A * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
0N/A * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
0N/A *
0N/A * The original version of this source code and documentation
0N/A * is copyrighted and owned by Taligent, Inc., a wholly-owned
0N/A * subsidiary of IBM. These materials are provided under terms
0N/A * of a License Agreement between Taligent and Sun. This technology
0N/A * is protected by multiple US and International patents.
0N/A *
0N/A * This notice and attribution to Taligent may not be removed.
0N/A * Taligent is a registered trademark of Taligent, Inc.
0N/A */
0N/A
0N/Apackage java.util;
0N/A
0N/Aimport java.io.InputStream;
0N/Aimport java.io.Reader;
0N/Aimport java.io.IOException;
0N/Aimport sun.util.ResourceBundleEnumeration;
0N/A
0N/A/**
0N/A * <code>PropertyResourceBundle</code> is a concrete subclass of
0N/A * <code>ResourceBundle</code> that manages resources for a locale
0N/A * using a set of static strings from a property file. See
0N/A * {@link ResourceBundle ResourceBundle} for more information about resource
0N/A * bundles.
0N/A *
0N/A * <p>
0N/A * Unlike other types of resource bundle, you don't subclass
0N/A * <code>PropertyResourceBundle</code>. Instead, you supply properties
0N/A * files containing the resource data. <code>ResourceBundle.getBundle</code>
0N/A * will automatically look for the appropriate properties file and create a
0N/A * <code>PropertyResourceBundle</code> that refers to it. See
0N/A * {@link ResourceBundle#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) ResourceBundle.getBundle}
0N/A * for a complete description of the search and instantiation strategy.
0N/A *
0N/A * <p>
0N/A * The following <a name="sample">example</a> shows a member of a resource
0N/A * bundle family with the base name "MyResources".
0N/A * The text defines the bundle "MyResources_de",
0N/A * the German member of the bundle family.
0N/A * This member is based on <code>PropertyResourceBundle</code>, and the text
0N/A * therefore is the content of the file "MyResources_de.properties"
0N/A * (a related <a href="ListResourceBundle.html#sample">example</a> shows
0N/A * how you can add bundles to this family that are implemented as subclasses
0N/A * of <code>ListResourceBundle</code>).
0N/A * The keys in this example are of the form "s1" etc. The actual
0N/A * keys are entirely up to your choice, so long as they are the same as
0N/A * the keys you use in your program to retrieve the objects from the bundle.
0N/A * Keys are case-sensitive.
0N/A * <blockquote>
0N/A * <pre>
0N/A * # MessageFormat pattern
0N/A * s1=Die Platte \"{1}\" enth&auml;lt {0}.
0N/A *
0N/A * # location of {0} in pattern
0N/A * s2=1
0N/A *
0N/A * # sample disk name
0N/A * s3=Meine Platte
0N/A *
0N/A * # first ChoiceFormat choice
0N/A * s4=keine Dateien
0N/A *
0N/A * # second ChoiceFormat choice
0N/A * s5=eine Datei
0N/A *
0N/A * # third ChoiceFormat choice
0N/A * s6={0,number} Dateien
0N/A *
0N/A * # sample date
0N/A * s7=3. M&auml;rz 1996
0N/A * </pre>
0N/A * </blockquote>
0N/A *
0N/A * <p>
0N/A * <strong>Note:</strong> PropertyResourceBundle can be constructed either
0N/A * from an InputStream or a Reader, which represents a property file.
0N/A * Constructing a PropertyResourceBundle instance from an InputStream requires
0N/A * that the input stream be encoded in ISO-8859-1. In that case, characters
4008N/A * that cannot be represented in ISO-8859-1 encoding must be represented by Unicode Escapes
4008N/A * as defined in section 3.3 of
4008N/A * <cite>The Java&trade; Language Specification</cite>
0N/A * whereas the other constructor which takes a Reader does not have that limitation.
0N/A *
0N/A * @see ResourceBundle
0N/A * @see ListResourceBundle
0N/A * @see Properties
0N/A * @since JDK1.1
0N/A */
0N/Apublic class PropertyResourceBundle extends ResourceBundle {
0N/A /**
0N/A * Creates a property resource bundle from an {@link java.io.InputStream
0N/A * InputStream}. The property file read with this constructor
0N/A * must be encoded in ISO-8859-1.
0N/A *
0N/A * @param stream an InputStream that represents a property file
0N/A * to read from.
0N/A * @throws IOException if an I/O error occurs
0N/A * @throws NullPointerException if <code>stream</code> is null
0N/A */
0N/A public PropertyResourceBundle (InputStream stream) throws IOException {
0N/A Properties properties = new Properties();
0N/A properties.load(stream);
0N/A lookup = new HashMap(properties);
0N/A }
0N/A
0N/A /**
0N/A * Creates a property resource bundle from a {@link java.io.Reader
0N/A * Reader}. Unlike the constructor
0N/A * {@link #PropertyResourceBundle(java.io.InputStream) PropertyResourceBundle(InputStream)},
0N/A * there is no limitation as to the encoding of the input property file.
0N/A *
0N/A * @param reader a Reader that represents a property file to
0N/A * read from.
0N/A * @throws IOException if an I/O error occurs
0N/A * @throws NullPointerException if <code>reader</code> is null
0N/A * @since 1.6
0N/A */
0N/A public PropertyResourceBundle (Reader reader) throws IOException {
0N/A Properties properties = new Properties();
0N/A properties.load(reader);
0N/A lookup = new HashMap(properties);
0N/A }
0N/A
0N/A // Implements java.util.ResourceBundle.handleGetObject; inherits javadoc specification.
0N/A public Object handleGetObject(String key) {
0N/A if (key == null) {
0N/A throw new NullPointerException();
0N/A }
0N/A return lookup.get(key);
0N/A }
0N/A
0N/A /**
0N/A * Returns an <code>Enumeration</code> of the keys contained in
0N/A * this <code>ResourceBundle</code> and its parent bundles.
0N/A *
0N/A * @return an <code>Enumeration</code> of the keys contained in
0N/A * this <code>ResourceBundle</code> and its parent bundles.
0N/A * @see #keySet()
0N/A */
0N/A public Enumeration<String> getKeys() {
0N/A ResourceBundle parent = this.parent;
0N/A return new ResourceBundleEnumeration(lookup.keySet(),
0N/A (parent != null) ? parent.getKeys() : null);
0N/A }
0N/A
0N/A /**
0N/A * Returns a <code>Set</code> of the keys contained
0N/A * <em>only</em> in this <code>ResourceBundle</code>.
0N/A *
0N/A * @return a <code>Set</code> of the keys contained only in this
0N/A * <code>ResourceBundle</code>
0N/A * @since 1.6
0N/A * @see #keySet()
0N/A */
0N/A protected Set<String> handleKeySet() {
0N/A return lookup.keySet();
0N/A }
0N/A
0N/A // ==================privates====================
0N/A
0N/A private Map<String,Object> lookup;
0N/A}