Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Licensed to the Apache Software Foundation (ASF) under one or more
   *  contributor license agreements.  See the NOTICE file distributed with
   *  this work for additional information regarding copyright ownership.
   *  The ASF licenses this file to You under the Apache License, Version 2.0
   *  (the "License"); you may not use this file except in compliance with
   *  the License.  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
  *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
 
 package java.util;
 
STUB: ResourceBundle is an abstract class which is the superclass of classes which provide locale specific resources. A bundle contains a number of named resources, where the names are Strings. A bundle may have a parent bundle, when a resource is not found in a bundle, the parent bundle is searched for the resource.

 
 public abstract class ResourceBundle {

The parent of this ResourceBundle.
 
 	protected ResourceBundle parent;
 
 	private Locale locale;
 
 	static class MissingBundle extends ResourceBundle {
         public Enumeration getKeys() {
 			return null;
 		}
 
         public Object handleGetObject(String name) {
 			return null;
 		}
 	}

Constructs a new instance of this class.
 
 	public ResourceBundle() {
 		/*empty*/
 	}

Finds the named resource bundle for the default locale.

Parameters:
bundleName the name of the resource bundle
Returns:
ResourceBundle
Throws:
java.util.MissingResourceException when the resource bundle cannot be found
 
 	public static final ResourceBundle getBundle(String bundleName)
 		return getBundleImpl(bundleName, Locale.getDefault());
 	}

Finds the named resource bundle for the specified locale.

Parameters:
bundleName the name of the resource bundle
locale the locale
Returns:
ResourceBundle
Throws:
java.util.MissingResourceException when the resource bundle cannot be found
 
 	public static final ResourceBundle getBundle(String bundleName,
 			Locale locale) {
 		return getBundleImpl(bundleNamelocale);
 	}
 
 	private static ResourceBundle getBundleImpl(String bundleNameLocale localethrows MissingResourceException {
 		if (bundleName != null) {
 			if (!locale.equals(Locale.getDefault())) {
 				String localeName = locale.toString();
 				if (localeName.length() > 0) {
                     localeName = "_" + localeName//$NON-NLS-1$
                 }
 			}
			String localeName = Locale.getDefault().toString();
			if (localeName.length() > 0) {
                localeName = "_" + localeName//$NON-NLS-1$
            }
			throw new MissingResourceException(nullbundleName + '_' + locale , ""); //$NON-NLS-1$
		}
        throw new NullPointerException();
	}

Answers the names of the resources contained in this ResourceBundle.

Returns:
an Enumeration of the resource names
	public abstract Enumeration getKeys();

Gets the Locale of this ResourceBundle.

Returns:
the Locale of this ResourceBundle
	public Locale getLocale() {
		return ;
	}

Answers the named resource from this ResourceBundle.

Parameters:
key the name of the resource
Returns:
the resource object
Throws:
java.util.MissingResourceException when the resource is not found
	public final Object getObject(String key) {
		ResourceBundle lasttheParent = this;
		do {
			Object result = theParent.handleGetObject(key);
			if (result != null) {
                return result;
            }
			last = theParent;
			theParent = theParent.parent;
while (theParent != null);
		throw new MissingResourceException(nulllast.getClass().toString(), key);
	}

Answers the named resource from this ResourceBundle.

Parameters:
key the name of the resource
Returns:
the resource string
Throws:
java.util.MissingResourceException when the resource is not found
	public final String getString(String key) {
		return (StringgetObject(key);
	}

Answers the named resource from this ResourceBundle.

Parameters:
key the name of the resource
Returns:
the resource string array
Throws:
java.util.MissingResourceException when the resource is not found
	public final String[] getStringArray(String key) {
		return (String[]) getObject(key);
	}

Answers the named resource from this ResourceBundle, or null if the resource is not found.

Parameters:
key the name of the resource
Returns:
the resource object
	protected abstract Object handleGetObject(String key);

Sets the parent resource bundle of this ResourceBundle. The parent is searched for resources which are not found in this resource bundle.

Parameters:
bundle the parent resource bundle
	protected void setParent(ResourceBundle bundle) {
		 = bundle;
	}
New to GrepCode? Check out our FAQ X