001: /*
002: * Fast Infoset ver. 0.1 software ("Software")
003: *
004: * Copyright, 2004-2005 Sun Microsystems, Inc. All Rights Reserved.
005: *
006: * Software is licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License. You may
008: * obtain a copy of the License at:
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015: * License for the specific language governing permissions and limitations.
016: *
017: * Sun supports and benefits from the global community of open source
018: * developers, and thanks the community for its important contributions and
019: * open standards-based technology, which Sun has adopted into many of its
020: * products.
021: *
022: * Please note that portions of Software may be provided with notices and
023: * open source licenses from such communities and third parties that govern the
024: * use of those portions, and any licenses granted hereunder do not alter any
025: * rights and obligations you may have under such open source licenses,
026: * however, the disclaimer of warranty and limitation of liability provisions
027: * in this License will apply to all Software in this distribution.
028: *
029: * You acknowledge that the Software is not designed, licensed or intended
030: * for use in the design, construction, operation or maintenance of any nuclear
031: * facility.
032: *
033: * Apache License
034: * Version 2.0, January 2004
035: * http://www.apache.org/licenses/
036: *
037: */
038: package com.sun.xml.fastinfoset;
039:
040: import java.util.Locale;
041: import java.util.ResourceBundle;
042:
043: /** Resource bundle implementation for localized messages.
044: */
045: public class CommonResourceBundle extends AbstractResourceBundle {
046:
047: public static final String BASE_NAME = "com.sun.xml.fastinfoset.resources.ResourceBundle";
048: private static CommonResourceBundle instance = null;
049: private static Locale locale = null;
050: private ResourceBundle bundle = null;
051:
052: protected CommonResourceBundle() {
053: // Load the resource bundle of default locale
054: bundle = ResourceBundle.getBundle(BASE_NAME);
055: }
056:
057: protected CommonResourceBundle(Locale locale) {
058: // Load the resource bundle of specified locale
059: bundle = ResourceBundle.getBundle(BASE_NAME, locale);
060: }
061:
062: public static CommonResourceBundle getInstance() {
063: if (instance == null) {
064: synchronized (CommonResourceBundle.class) {
065: instance = new CommonResourceBundle();
066: //**need to know where to get the locale
067: //String localeString = CommonProperties.getInstance()
068: // .getProperty("omar.common.locale");
069: String localeString = null;
070: locale = parseLocale(localeString);
071: }
072: }
073:
074: return instance;
075: }
076:
077: public static CommonResourceBundle getInstance(Locale locale) {
078: if (instance == null) {
079: synchronized (CommonResourceBundle.class) {
080: instance = new CommonResourceBundle(locale);
081: }
082: } else {
083: synchronized (CommonResourceBundle.class) {
084: if (CommonResourceBundle.locale != locale) {
085: instance = new CommonResourceBundle(locale);
086: }
087: }
088: }
089: return instance;
090: }
091:
092: public ResourceBundle getBundle() {
093: return bundle;
094: }
095:
096: public ResourceBundle getBundle(Locale locale) {
097: return ResourceBundle.getBundle(BASE_NAME, locale);
098: }
099:
100: }
|