001: /*
002: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: *
025: * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC.
026: */
027:
028: /*
029: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
030: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
031: *
032: * This code is free software; you can redistribute it and/or modify it
033: * under the terms of the GNU General Public License version 2 only, as
034: * published by the Free Software Foundation. Sun designates this
035: * particular file as subject to the "Classpath" exception as provided
036: * by Sun in the LICENSE file that accompanied this code.
037: *
038: * This code is distributed in the hope that it will be useful, but WITHOUT
039: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
040: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
041: * version 2 for more details (a copy is included in the LICENSE file that
042: * accompanied this code).
043: *
044: * You should have received a copy of the GNU General Public License version
045: * 2 along with this work; if not, write to the Free Software Foundation,
046: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
047: *
048: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
049: * CA 95054 USA or visit www.sun.com if you need additional information or
050: * have any questions.
051: *
052: * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC.
053: *
054: */
055: package com.sun.xml.internal.fastinfoset;
056:
057: import java.util.Locale;
058: import java.util.ResourceBundle;
059:
060: /** Resource bundle implementation for localized messages.
061: */
062: public class CommonResourceBundle extends AbstractResourceBundle {
063:
064: public static final String BASE_NAME = "com.sun.xml.internal.fastinfoset.resources.ResourceBundle";
065: private static CommonResourceBundle instance = null;
066: private static Locale locale = null;
067: private ResourceBundle bundle = null;
068:
069: protected CommonResourceBundle() {
070: // Load the resource bundle of default locale
071: bundle = ResourceBundle.getBundle(BASE_NAME);
072: }
073:
074: protected CommonResourceBundle(Locale locale) {
075: // Load the resource bundle of specified locale
076: bundle = ResourceBundle.getBundle(BASE_NAME, locale);
077: }
078:
079: public static CommonResourceBundle getInstance() {
080: if (instance == null) {
081: synchronized (CommonResourceBundle.class) {
082: if (instance == null) {
083: instance = new CommonResourceBundle();
084: //**need to know where to get the locale
085: //String localeString = CommonProperties.getInstance()
086: // .getProperty("omar.common.locale");
087: String localeString = null;
088: locale = parseLocale(localeString);
089: }
090: }
091: }
092:
093: return instance;
094: }
095:
096: public static CommonResourceBundle getInstance(Locale locale) {
097: if (instance == null) {
098: synchronized (CommonResourceBundle.class) {
099: if (instance == null) {
100: instance = new CommonResourceBundle(locale);
101: }
102: }
103: } else {
104: synchronized (CommonResourceBundle.class) {
105: if (CommonResourceBundle.locale != locale) {
106: instance = new CommonResourceBundle(locale);
107: }
108: }
109: }
110: return instance;
111: }
112:
113: public ResourceBundle getBundle() {
114: return bundle;
115: }
116:
117: public ResourceBundle getBundle(Locale locale) {
118: return ResourceBundle.getBundle(BASE_NAME, locale);
119: }
120:
121: }
|