Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.resources
Class ResourceManagementServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.resources.ResourceManagementServiceImpl
All Implemented Interfaces:
EventListener, ResourceManagementService, org.osgi.framework.ServiceListener

public class ResourceManagementServiceImpl
extends Object
implements ResourceManagementService, org.osgi.framework.ServiceListener

A default implementation of the ResourceManagementService.

Author:
Damian Minkov, Yana Stamcheva, Lubomir Marinov, Adam Netocny

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.resources.ResourceManagementService
DEFAULT_LOCALE_CONFIG
 
Constructor Summary
ResourceManagementServiceImpl()
          Initializes already registered default resource packs.
 
Method Summary
 Iterator<Locale> getAvailableLocales()
          All the locales in the language pack.
 int getColor(String key)
          Returns the int representation of the color corresponding to the given key.
 String getColorString(String key)
          Returns the string representation of the color corresponding to the given key.
 char getI18nMnemonic(String key)
          Returns an internationalized string corresponding to the given key.
 char getI18nMnemonic(String key, Locale locale)
          Returns an internationalized string corresponding to the given key.
 String getI18NString(String key)
          Returns an internationalized string corresponding to the given key.
 String getI18NString(String key, Locale locale)
          Returns an internationalized string corresponding to the given key.
 String getI18NString(String key, String[] params)
          Returns an internationalized string corresponding to the given key.
 String getI18NString(String key, String[] params, Locale locale)
          Returns an internationalized string corresponding to the given key.
 ImageIcon getImage(String imageID)
          Loads an image from a given image identifier.
 byte[] getImageInBytes(String imageID)
          Loads an image from a given image identifier.
 InputStream getImageInputStream(String streamKey)
          Returns the InputStream of the image corresponding to the given key.
 InputStream getImageInputStreamForPath(String path)
          Returns the InputStream of the image corresponding to the given path.
 String getImagePath(String key)
          Returns the image path corresponding to the given key.
 URL getImageURL(String urlKey)
          Returns the URL of the image corresponding to the given key.
 URL getImageURLForPath(String path)
          Returns the URL of the image corresponding to the given path.
 InputStream getSettingsInputStream(String streamKey)
          Returns a stream from a given identifier.
 InputStream getSettingsInputStream(String streamKey, Class<?> resourceClass)
          Returns a stream from a given identifier, obtained through the class loader of the given resourceClass.
 int getSettingsInt(String key)
          Returns the int value of the corresponding configuration key.
 String getSettingsString(String key)
          Returns the int value of the corresponding configuration key.
 URL getSettingsURL(String urlKey)
          Returns an URL from a given identifier.
 String getSoundPath(String soundKey)
          Returns the path of the sound corresponding to the given property key.
 URL getSoundURL(String urlKey)
          Returns the URL of the sound corresponding to the given property key.
 URL getSoundURLForPath(String path)
          Returns the URL of the sound corresponding to the given path.
 File prepareSkinBundleFromZip(File zipFile)
          Builds a new skin bundle from the zip file content.
 void serviceChanged(org.osgi.framework.ServiceEvent event)
          Handles all ServiceEvents corresponding to ResourcePack being registered or unregistered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceManagementServiceImpl

ResourceManagementServiceImpl()
Initializes already registered default resource packs.

Method Detail

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent event)
Handles all ServiceEvents corresponding to ResourcePack being registered or unregistered. Also handles UIService reference.

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
event - the ServiceEvent that notified us

getColor

public int getColor(String key)
Returns the int representation of the color corresponding to the given key.

Specified by:
getColor in interface ResourceManagementService
Parameters:
key - The key of the color in the colors properties file.
Returns:
the int representation of the color corresponding to the given key.

getColorString

public String getColorString(String key)
Returns the string representation of the color corresponding to the given key.

Specified by:
getColorString in interface ResourceManagementService
Parameters:
key - The key of the color in the colors properties file.
Returns:
the string representation of the color corresponding to the given key.

getImageInputStreamForPath

public InputStream getImageInputStreamForPath(String path)
Returns the InputStream of the image corresponding to the given path.

Specified by:
getImageInputStreamForPath in interface ResourceManagementService
Parameters:
path - The path to the image file.
Returns:
the InputStream of the image corresponding to the given path.

getImageInputStream

public InputStream getImageInputStream(String streamKey)
Returns the InputStream of the image corresponding to the given key.

Specified by:
getImageInputStream in interface ResourceManagementService
Parameters:
streamKey - The identifier of the image in the resource properties file.
Returns:
the InputStream of the image corresponding to the given key.

getImageURL

public URL getImageURL(String urlKey)
Returns the URL of the image corresponding to the given key.

Specified by:
getImageURL in interface ResourceManagementService
Parameters:
urlKey - The identifier of the image in the resource properties file.
Returns:
the URL of the image corresponding to the given key

getImagePath

public String getImagePath(String key)
Returns the image path corresponding to the given key.

Specified by:
getImagePath in interface ResourceManagementService
Parameters:
key - The identifier of the image in the resource properties file.
Returns:
the image path corresponding to the given key.

getImageURLForPath

public URL getImageURLForPath(String path)
Returns the URL of the image corresponding to the given path.

Specified by:
getImageURLForPath in interface ResourceManagementService
Parameters:
path - The path to the given image file.
Returns:
the URL of the image corresponding to the given path.

getAvailableLocales

public Iterator<Locale> getAvailableLocales()
All the locales in the language pack.

Specified by:
getAvailableLocales in interface ResourceManagementService
Returns:
all the locales this Language pack contains.

getI18NString

public String getI18NString(String key)
Returns an internationalized string corresponding to the given key.

Specified by:
getI18NString in interface ResourceManagementService
Parameters:
key - The identifier of the string in the resources properties file.
Returns:
An internationalized string corresponding to the given key.

getI18NString

public String getI18NString(String key,
                            Locale locale)
Returns an internationalized string corresponding to the given key.

Specified by:
getI18NString in interface ResourceManagementService
Parameters:
key - The identifier of the string in the resources properties file.
locale - The locale.
Returns:
An internationalized string corresponding to the given key and given locale.

getI18NString

public String getI18NString(String key,
                            String[] params)
Returns an internationalized string corresponding to the given key.

Specified by:
getI18NString in interface ResourceManagementService
Parameters:
key - The identifier of the string.
params - the parameters to pass to the localized string
Returns:
An internationalized string corresponding to the given key.

getI18NString

public String getI18NString(String key,
                            String[] params,
                            Locale locale)
Returns an internationalized string corresponding to the given key.

Specified by:
getI18NString in interface ResourceManagementService
Parameters:
key - The identifier of the string in the resources properties file.
params - the parameters to pass to the localized string
locale - The locale.
Returns:
An internationalized string corresponding to the given key.

getI18nMnemonic

public char getI18nMnemonic(String key)
Returns an internationalized string corresponding to the given key.

Specified by:
getI18nMnemonic in interface ResourceManagementService
Parameters:
key - The identifier of the string in the resources properties file.
Returns:
An internationalized string corresponding to the given key.

getI18nMnemonic

public char getI18nMnemonic(String key,
                            Locale locale)
Returns an internationalized string corresponding to the given key.

Specified by:
getI18nMnemonic in interface ResourceManagementService
Parameters:
key - The identifier of the string in the resources properties file.
locale - The locale that we'd like to receive the result in.
Returns:
An internationalized string corresponding to the given key.

getSettingsString

public String getSettingsString(String key)
Returns the int value of the corresponding configuration key.

Specified by:
getSettingsString in interface ResourceManagementService
Parameters:
key - The identifier of the string in the resources properties file.
Returns:
the int value of the corresponding configuration key.

getSettingsInt

public int getSettingsInt(String key)
Returns the int value of the corresponding configuration key.

Specified by:
getSettingsInt in interface ResourceManagementService
Parameters:
key - The identifier of the string in the resources properties file.
Returns:
the int value of the corresponding configuration key.

getSettingsURL

public URL getSettingsURL(String urlKey)
Returns an URL from a given identifier.

Specified by:
getSettingsURL in interface ResourceManagementService
Parameters:
urlKey - The identifier of the url.
Returns:
The url for the given identifier.

getSettingsInputStream

public InputStream getSettingsInputStream(String streamKey)
Returns a stream from a given identifier.

Specified by:
getSettingsInputStream in interface ResourceManagementService
Parameters:
streamKey - The identifier of the stream.
Returns:
The stream for the given identifier.

getSettingsInputStream

public InputStream getSettingsInputStream(String streamKey,
                                          Class<?> resourceClass)
Returns a stream from a given identifier, obtained through the class loader of the given resourceClass.

Specified by:
getSettingsInputStream in interface ResourceManagementService
Parameters:
streamKey - The identifier of the stream.
resourceClass - the resource class through which the resource would be obtained
Returns:
The stream for the given identifier.

getSoundURL

public URL getSoundURL(String urlKey)
Returns the URL of the sound corresponding to the given property key.

Specified by:
getSoundURL in interface ResourceManagementService
Parameters:
urlKey - The key of the setting.
Returns:
the URL of the sound corresponding to the given property key.

getSoundURLForPath

public URL getSoundURLForPath(String path)
Returns the URL of the sound corresponding to the given path.

Specified by:
getSoundURLForPath in interface ResourceManagementService
Parameters:
path - the path, for which we're looking for a sound URL
Returns:
the URL of the sound corresponding to the given path.

getSoundPath

public String getSoundPath(String soundKey)
Returns the path of the sound corresponding to the given property key.

Specified by:
getSoundPath in interface ResourceManagementService
Parameters:
soundKey - the key, for the sound path
Returns:
the path of the sound corresponding to the given property key.

getImageInBytes

public byte[] getImageInBytes(String imageID)
Loads an image from a given image identifier.

Specified by:
getImageInBytes in interface ResourceManagementService
Parameters:
imageID - The identifier of the image.
Returns:
The image for the given identifier.

getImage

public ImageIcon getImage(String imageID)
Loads an image from a given image identifier.

Specified by:
getImage in interface ResourceManagementService
Parameters:
imageID - The identifier of the image.
Returns:
The image for the given identifier.

prepareSkinBundleFromZip

public File prepareSkinBundleFromZip(File zipFile)
                              throws Exception
Builds a new skin bundle from the zip file content.

Specified by:
prepareSkinBundleFromZip in interface ResourceManagementService
Parameters:
zipFile - Zip file with skin information.
Returns:
File for the bundle.
Throws:
Exception - When something goes wrong.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.