Class DelegatingResourceLocator

java.lang.Object
org.eclipse.emf.common.util.DelegatingResourceLocator
All Implemented Interfaces:
ResourceLocator
Direct Known Subclasses:
EMFPlugin

public abstract class DelegatingResourceLocator extends Object implements ResourceLocator
An abstract resource locator implementation comprising a primary locator and a series delegate locators.
  • Field Details

    • baseURL

      protected URL baseURL
      The cached base URL.
    • untranslatedResourceBundle

      protected ResourceBundle untranslatedResourceBundle
      The resource bundle containing untranslated strings.
    • resourceBundle

      protected ResourceBundle resourceBundle
      The resource bundle containing translated strings.
    • strings

      protected Map<String,String> strings
      A cache of the translated strings.
    • untranslatedStrings

      protected Map<String,String> untranslatedStrings
      A cache of the untranslated strings.
    • images

      protected Map<String,Object> images
      A cache of the image descriptions.
    • shouldTranslate

      protected boolean shouldTranslate
      Whether to translate strings by default.
    • bundleLocalization

      protected String bundleLocalization
      The default localization properties file.
      Since:
      2.14
  • Constructor Details

    • DelegatingResourceLocator

      public DelegatingResourceLocator()
      Creates an instance.
  • Method Details

    • 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 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.
    • getBundleLocalization

      protected String getBundleLocalization(URL manifestURL) throws IOException
      Throws:
      IOException
      Since:
      2.14
    • getImage

      public Object getImage(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 Object doGetImage(String key) throws 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:
      IOException - if an image doesn't exist.
    • extensionFor

      protected static String extensionFor(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 Object delegatedGetImage(String key) throws 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:
      MissingResourceException - if the image resource doesn't exist anywhere.
      See Also:
    • 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 String getString(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 String getString(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 String doGetString(String key, boolean translate) throws 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:
      MissingResourceException - if a string doesn't exist.
    • delegatedGetString

      protected String delegatedGetString(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:
      MissingResourceException - if the string resource doesn't exist anywhere.
      See Also:
    • getString

      public String getString(String key, 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:
    • getString

      public String getString(String key, 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: