src/java.sql.rowset/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java
author stuefe
Thu, 28 Feb 2019 14:22:03 +0100
changeset 54011 21ea4076a275
parent 47216 71c04702a3d5
permissions -rw-r--r--
8219650: [Testbug] Fix potential crashes in new test hotspot gtest "test_print_hex_dump" Reviewed-by: clanger, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 11129
diff changeset
     2
 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3843
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3843
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3843
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3843
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3843
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.rowset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * This class is used to help in localization of resources,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * especially the exception strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @author Amit Handa
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class JdbcRowSetResourceBundle implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     * This <code>String</code> variable stores the location
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     * of the resource bundle location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     */
7182
f3e89472692d 6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents: 6530
diff changeset
    44
    private static String fileName;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * This variable will hold the <code>PropertyResourceBundle</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * of the text to be internationalized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     */
7182
f3e89472692d 6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents: 6530
diff changeset
    50
    private transient PropertyResourceBundle propResBundle;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * The constructor initializes to this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     */
7182
f3e89472692d 6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents: 6530
diff changeset
    56
    private static volatile JdbcRowSetResourceBundle jpResBundle;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
7182
f3e89472692d 6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents: 6530
diff changeset
    59
     * The variable which will represent the properties
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * the suffix or extension of the resource bundle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static final String PROPERTIES = "properties";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /**
7182
f3e89472692d 6982530: javadoc update to SyncFactory & JdbcResource bundle for synchronization issues
lancea
parents: 6530
diff changeset
    65
     * The variable to represent underscore
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static final String UNDERSCORE = "_";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * The variable which will represent dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private static final String DOT = ".";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * The variable which will represent the slash.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static final String SLASH = "/";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * The variable where the default resource bundle will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * be placed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private static final String PATH = "com/sun/rowset/RowSetResourceBundle";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * The constructor which initializes the resource bundle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Note this is a private constructor and follows Singleton
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Design Pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @throws IOException if unable to load the ResourceBundle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * according to locale or the default one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private JdbcRowSetResourceBundle () throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        // Try to load the resource bundle according
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        // to the locale. Else if no bundle found according
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        // to the locale load the default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        // In default case the default locale resource bundle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        // should always be loaded else it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        // will be difficult to throw appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        // exception string messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        Locale locale = Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        // Load appropriate bundle according to locale
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   105
        propResBundle = (PropertyResourceBundle) ResourceBundle.getBundle(PATH,
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   106
                           locale, JdbcRowSetResourceBundle.class.getModule());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * This method is used to get a handle to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * initialized instance of this class. Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * at any time there is only one instance of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * class initialized which will be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @throws IOException if unable to find the RowSetResourceBundle.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public static JdbcRowSetResourceBundle getJdbcRowSetResourceBundle()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
         if(jpResBundle == null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
             synchronized(JdbcRowSetResourceBundle.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                if(jpResBundle == null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                    jpResBundle = new JdbcRowSetResourceBundle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                } //end if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
             } //end synchronized block
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
         } //end if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
         return jpResBundle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * This method returns an enumerated handle of the keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * which correspond to values translated to various locales.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
3843
b582759a6e99 6737212: Fixed javadoc warning messages in RowSet classes
lancea
parents: 2
diff changeset
   135
     * @return an enumeration of keys which have messages tranlated to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * corresponding locales.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 7182
diff changeset
   138
    @SuppressWarnings("rawtypes")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public Enumeration getKeys() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
       return propResBundle.getKeys();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * This method takes the key as an argument and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * returns the corresponding value reading it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * from the Resource Bundle loaded earlier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
3843
b582759a6e99 6737212: Fixed javadoc warning messages in RowSet classes
lancea
parents: 2
diff changeset
   149
     * @return value in locale specific language
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * according to the key passed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public Object handleGetObject(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
       return propResBundle.handleGetObject(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
6530
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   156
    static final long serialVersionUID = 436199386225359954L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
}