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