## org.eclipse.emf.common.util
Class DelegatingResourceLocator

    java.lang.Object
      org.eclipse.emf.common.util.DelegatingResourceLocator

All Implemented Interfaces:
  ResourceLocator

Direct Known Subclasses:
  ChildCreationExtenderManager, EMFPlugin

    public abstract class DelegatingResourceLocator

extends java.lang.Object
implements ResourceLocator

An abstract resource locator implementation comprising a `primary locator` and a series `delegate locators`.

Field Summary
`protected java.net.URL` `baseURL` The cached base URL.
`protected java.util.Map<java.lang.String,java.lang.Object>` `images` A cache of the image descriptions.
`protected java.util.ResourceBundle` `resourceBundle` The resource bundle containing translated strings.
`protected boolean` `shouldTranslate` Whether to translate strings by default.
`protected java.util.Map<java.lang.String,java.lang.String>` `strings` A cache of the translated strings.
`protected java.util.ResourceBundle` `untranslatedResourceBundle` The resource bundle containing untranslated strings.
`protected java.util.Map<java.lang.String,java.lang.String>` `untranslatedStrings` A cache of the untranslated strings.

Constructor Summary
`DelegatingResourceLocator()` Creates an instance.

Method Summary
`protected java.lang.Object` `delegatedGetImage(java.lang.String key)` Does the work of fetching the image associated with the key, when the image resource is not available locally.
`protected java.lang.String` `delegatedGetString(java.lang.String key, boolean translate)` Does the work of fetching the string associated with the key, when the string resource is not available locally.
`protected java.lang.Object` `doGetImage(java.lang.String key)` Does the work of fetching the image associated with the key.
`protected java.lang.String` `doGetString(java.lang.String key, boolean translate)` Does the work of fetching the string associated with the key.
`protected static java.lang.String` `extensionFor(java.lang.String key)` Computes the file extension to be used with the key to specify an image resource.
`java.net.URL` `getBaseURL()` Returns the URL from which all resources are based.
`protected abstract ResourceLocator[]` `getDelegateResourceLocators()` Returns the delegate resource locators.
`java.lang.Object` `getImage(java.lang.String key)` Returns the description that can be used to create the image resource associated with the key.
`protected abstract ResourceLocator` `getPrimaryResourceLocator()` Returns the primary resource locator.
`java.lang.String` `getString(java.lang.String key)` Returns the string resource associated with the key.
`java.lang.String` `getString(java.lang.String key, boolean translate)` Returns the string resource associated with the key.
`java.lang.String` `getString(java.lang.String key, java.lang.Object[] substitutions)` Returns a string resource associated with the key, and performs substitutions.
`java.lang.String` `getString(java.lang.String key, java.lang.Object[] substitutions, boolean translate)` Returns a string resource associated with the key, and performs substitutions.
`void` `setShouldTranslate(boolean shouldTranslate)` Sets whether strings should be translated by default.
`boolean` `shouldTranslate()` Indicates whether strings should be translated by default.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### baseURL

    protected java.net.URL baseURL

  The cached base URL.

### untranslatedResourceBundle

    protected java.util.ResourceBundle untranslatedResourceBundle

  The resource bundle containing untranslated strings.

### resourceBundle

    protected java.util.ResourceBundle resourceBundle

  The resource bundle containing translated strings.

### strings

    protected java.util.Map<java.lang.String,java.lang.String> strings

  A cache of the translated strings.

### untranslatedStrings

    protected java.util.Map<java.lang.String,java.lang.String> untranslatedStrings

  A cache of the untranslated strings.

### images

    protected java.util.Map<java.lang.String,java.lang.Object> images

  A cache of the image descriptions.

### shouldTranslate

    protected boolean shouldTranslate

  Whether to translate strings by default.

Constructor Detail

### DelegatingResourceLocator

    public DelegatingResourceLocator()

  Creates an instance.

Method Detail

### getPrimaryResourceLocator

    protected abstract ResourceLocator getPrimaryResourceLocator()

  Returns the primary resource locator.

  Returns:
    the primary resource locator.

### getDelegateResourceLocators

    protected abstract ResourceLocator[] getDelegateResourceLocators()

  Returns the delegate resource locators.

  Returns:
    the delegate resource locators.

### getBaseURL

    public java.net.URL getBaseURL()

  Description copied from interface: `ResourceLocator`
  Returns the URL from which all resources are based.

  Specified by:
    `getBaseURL` in interface `ResourceLocator`
  Returns:
    the URL from which all resources are based.

### getImage

    public java.lang.Object getImage(java.lang.String key)

  Description copied from interface: `ResourceLocator`
  Returns the description that can be used to create the image resource associated with the key. The description will typically be in the form of a URL to the image data. Creation of an actual image depends on the GUI environment; within Eclipse, org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry can be used.

  Specified by:
    `getImage` in interface `ResourceLocator`
  Parameters:
    `key` - the key of the image resource.
  Returns:
    the description on the image resource.

### doGetImage

    protected java.lang.Object doGetImage(java.lang.String key)
                                   throws java.io.IOException

  Does the work of fetching the image associated with the key. It ensures that the image exists.

  Parameters:
    `key` - the key of the image to fetch.
  Returns:
    the description of the image associated with the key.
  Throws:
    `java.io.IOException` - if an image doesn't exist.

### extensionFor

    protected static java.lang.String extensionFor(java.lang.String key)

  Computes the file extension to be used with the key to specify an image resource.

  Parameters:
    `key` - the key for the imagine.
  Returns:
    the file extension to be used with the key to specify an image resource.

### delegatedGetImage

    protected java.lang.Object delegatedGetImage(java.lang.String key)
                                          throws java.util.MissingResourceException

  Does the work of fetching the image associated with the key, when the image resource is not available locally.

  Parameters:
    `key` - the key of the image to fetch.
  Throws:
    `java.util.MissingResourceException` - if the image resource doesn't exist anywhere.
  See Also:
    `getDelegateResourceLocators()`

### shouldTranslate

    public boolean shouldTranslate()

  Indicates whether strings should be translated by default.

  Returns:
    `true` if strings should be translated by default; `false` otherwise.

### setShouldTranslate

    public void setShouldTranslate(boolean shouldTranslate)

  Sets whether strings should be translated by default.

  Parameters:
    `shouldTranslate` - whether strings should be translated by default.

### getString

    public java.lang.String getString(java.lang.String key)

  Description copied from interface: `ResourceLocator`
  Returns the string resource associated with the key.

  Specified by:
    `getString` in interface `ResourceLocator`
  Parameters:
    `key` - the key of the string resource.
  Returns:
    the string resource associated with the key.

### getString

    public java.lang.String getString(java.lang.String key,
                                      boolean translate)

  Description copied from interface: `ResourceLocator`
  Returns the string resource associated with the key.

  Specified by:
    `getString` in interface `ResourceLocator`
  Parameters:
    `key` - the key of the string resource.
    `translate` - whether the result is to be translated to the current locale.
  Returns:
    the string resource associated with the key.

### doGetString

    protected java.lang.String doGetString(java.lang.String key,
                                           boolean translate)
                                    throws java.util.MissingResourceException

  Does the work of fetching the string associated with the key. It ensures that the string exists.

  Parameters:
    `key` - the key of the string to fetch.
  Returns:
    the string associated with the key.
  Throws:
    `java.util.MissingResourceException` - if a string doesn't exist.

### delegatedGetString

    protected java.lang.String delegatedGetString(java.lang.String key,
                                                  boolean translate)

  Does the work of fetching the string associated with the key, when the string resource is not available locally.

  Parameters:
    `key` - the key of the string to fetch.
  Throws:
    `java.util.MissingResourceException` - if the string resource doesn't exist anywhere.
  See Also:
    `getDelegateResourceLocators()`

### getString

    public java.lang.String getString(java.lang.String key,
                                      java.lang.Object[] substitutions)

  Description copied from interface: `ResourceLocator`
  Returns a string resource associated with the key, and performs substitutions.

  Specified by:
    `getString` in interface `ResourceLocator`
  Parameters:
    `key` - the key of the string.
    `substitutions` - the message substitutions.
  Returns:
    a string resource associated with the key.
  See Also:
    `ResourceLocator.getString(String)`, `MessageFormat.format(String, Object[])`

### getString

    public java.lang.String getString(java.lang.String key,
                                      java.lang.Object[] substitutions,
                                      boolean translate)

  Description copied from interface: `ResourceLocator`
  Returns a string resource associated with the key, and performs substitutions.

  Specified by:
    `getString` in interface `ResourceLocator`
  Parameters:
    `key` - the key of the string.
    `substitutions` - the message substitutions.
    `translate` - whether the result is to be translated to the current locale.
  Returns:
    a string resource associated with the key.
  See Also:
    `ResourceLocator.getString(String)`, `MessageFormat.format(String, Object[])`

Copyright 2001-2006 IBM Corporation and others. All Rights Reserved.