jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java
author lancea
Wed, 09 Sep 2009 20:15:22 -0400
changeset 3843 b582759a6e99
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6737212: Fixed javadoc warning messages in RowSet classes Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
import java.lang.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * This class is used to help in localization of resources,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * especially the exception strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @author Amit Handa
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public class JdbcRowSetResourceBundle implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     * This <code>String</code> variable stores the location
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * of the resource bundle location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static String fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * This variable will hold the <code>PropertyResourceBundle</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * of the text to be internationalized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    transient PropertyResourceBundle propResBundle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * The constructor initializes to this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static JdbcRowSetResourceBundle jpResBundle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * The varible which will represent the properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * the suffix or extension of the resource bundle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private static final String PROPERTIES = "properties";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * The varibale to represent underscore
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private static final String UNDERSCORE = "_";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * The variable which will represent dot
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private static final String DOT = ".";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * The variable which will represent the slash.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private static final String SLASH = "/";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * The variable where the default resource bundle will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * be placed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private static final String PATH = "com/sun/rowset/RowSetResourceBundle";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * The constructor which initializes the resource bundle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Note this is a private constructor and follows Singleton
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Design Pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @throws IOException if unable to load the ResourceBundle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * according to locale or the default one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private JdbcRowSetResourceBundle () throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        // Try to load the resource bundle according
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        // to the locale. Else if no bundle found according
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        // to the locale load the default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        // In default case the default locale resource bundle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        // should always be loaded else it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        // will be difficult to throw appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        // exception string messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        Locale locale = Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        // Load appropriate bundle according to locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
         propResBundle = (PropertyResourceBundle) ResourceBundle.getBundle(PATH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                           locale, Thread.currentThread().getContextClassLoader());
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * This method is used to get a handle to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * initialized instance of this class. Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * at any time there is only one instance of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * class initialized which will be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @throws IOException if unable to find the RowSetResourceBundle.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public static JdbcRowSetResourceBundle getJdbcRowSetResourceBundle()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
         if(jpResBundle == null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
             synchronized(JdbcRowSetResourceBundle.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                if(jpResBundle == null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    jpResBundle = new JdbcRowSetResourceBundle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                } //end if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
             } //end synchronized block
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
         } //end if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
         return jpResBundle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * This method returns an enumerated handle of the keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * which correspond to values translated to various locales.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *
3843
b582759a6e99 6737212: Fixed javadoc warning messages in RowSet classes
lancea
parents: 2
diff changeset
   136
     * @return an enumeration of keys which have messages tranlated to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * corresponding locales.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
}