org.norther.tammi.core.locale
Class LookupResourceBundle

java.lang.Object
  extended by java.util.ResourceBundle
      extended by org.norther.tammi.core.locale.LookupResourceBundle
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
PluggableResourceBundle

public class LookupResourceBundle
extends ResourceBundle
implements Serializable

An extension of java.util.ResourceBundle implementing a lookup method, which returns null for a missing resource instead of throwing an exception.

Version:
$Id: LookupResourceBundle.java,v 1.9 2009/09/28 15:08:44 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control
 
Field Summary
 
Fields inherited from class java.util.ResourceBundle
parent
 
Constructor Summary
protected LookupResourceBundle()
          Constructs an empty bundle.
  LookupResourceBundle(ResourceBundle bundle)
          Constructs a new bundle with an adapter.
protected LookupResourceBundle(String name)
          Constructs a named bundle.
  LookupResourceBundle(String name, ResourceBundle bundle)
          Constructs a named bundle with an adapter.
 
Method Summary
 String getBaseName()
          Gets the base name of this bundle.
 Enumeration<String> getKeys()
          Implementation of the ResourceBundle.getKeys method.
protected  Enumeration<String> getKeys(Set<String> keys)
          Gets local and parent keys.
protected  ResourceBundle getParent()
          Gets the parent.
protected  Object handleGetObject(String key)
          Implementation of the ResourceBundle.handleGetObject method.
 Object lookup(String key)
          Looks up for a resource.
 Object lookup(String key, Locale locale)
          Looks up for a resource for an exact locale.
 String lookupKey(Object resource)
          Looks up for a resource key.
 Object lookupObject(String key)
          Looks up for an object resource.
 String lookupString(String key)
          Looks up for a string resource.
 String[] lookupStringArray(String key)
          Looks up for a string array resource.
protected  void setBaseName(String name)
          Sets the base name.
 
Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, keySet, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookupResourceBundle

public LookupResourceBundle(ResourceBundle bundle)
Constructs a new bundle with an adapter.

Parameters:
bundle - the adapter.

LookupResourceBundle

public LookupResourceBundle(String name,
                            ResourceBundle bundle)
Constructs a named bundle with an adapter.

Parameters:
name - the base name of this bundle.
bundle - the adapter.

LookupResourceBundle

protected LookupResourceBundle()
Constructs an empty bundle.


LookupResourceBundle

protected LookupResourceBundle(String name)
Constructs a named bundle.

Parameters:
name - the base name of this bundle.
Method Detail

getBaseName

public String getBaseName()
Gets the base name of this bundle.

Returns:
the base name.

lookup

public Object lookup(String key,
                     Locale locale)
Looks up for a resource for an exact locale.

Parameters:
key - the resource key.
locale - the locale.
Returns:
the found resource or null.

lookup

public Object lookup(String key)
Looks up for a resource.

Parameters:
key - the resource key.
Returns:
the found resource or null.

lookupObject

public Object lookupObject(String key)
Looks up for an object resource.

Parameters:
key - the resource key.
Returns:
the found resource or null.

lookupString

public String lookupString(String key)
Looks up for a string resource.

Parameters:
key - the resource key.
Returns:
the found resource or null.

lookupStringArray

public String[] lookupStringArray(String key)
Looks up for a string array resource.

Parameters:
key - the resource key.
Returns:
the found resource or null.

lookupKey

public String lookupKey(Object resource)
Looks up for a resource key.

Parameters:
resource - the resource.
Returns:
the found key or null.

getKeys

public Enumeration<String> getKeys()
Implementation of the ResourceBundle.getKeys method.

Specified by:
getKeys in class ResourceBundle
Returns:
an enumeration of keys.

handleGetObject

protected Object handleGetObject(String key)
Implementation of the ResourceBundle.handleGetObject method.

Specified by:
handleGetObject in class ResourceBundle
Parameters:
key - the key of the object to get.
Returns:
the object value.

getKeys

protected Enumeration<String> getKeys(Set<String> keys)
Gets local and parent keys.

Parameters:
keys - a set of local keys.
Returns:
an enumeration of keys.

getParent

protected ResourceBundle getParent()
Gets the parent.

Returns:
the parent.

setBaseName

protected void setBaseName(String name)
Sets the base name.

Parameters:
name - the base name.


Copyright © 2004 The Norther Organization. All rights reserved.