public abstract class AbstractResourcesService
extends java.lang.Object
implements org.jitsi.service.resources.ResourceManagementService, org.osgi.framework.ServiceListener
ResourcePack
that are registered and exposes them later for use by
subclasses. It implements default behaviour for most methods.Constructor and Description |
---|
AbstractResourcesService(org.osgi.framework.BundleContext bundleContext)
Creates an instance of AbstractResourcesService.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
doGetI18String(java.lang.String key,
java.util.Locale locale)
Returns the string for given key for specified locale.
|
java.util.Iterator<java.util.Locale> |
getAvailableLocales()
All the locales in the language pack.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getColorResources()
Resources for currently loaded ColorPack.
|
protected <T extends ResourcePack> |
getDefaultResourcePack(java.lang.Class<T> clazz,
java.lang.String typeName)
Searches for the ResourcePack corresponding to the given
className and .
|
char |
getI18nMnemonic(java.lang.String key)
Returns the character after the first '&' in the internationalized
string corresponding to key
|
char |
getI18nMnemonic(java.lang.String key,
java.util.Locale locale)
Returns the character after the first '&' in the internationalized
string corresponding to key
|
java.lang.String |
getI18NString(java.lang.String key)
Returns an internationalized string corresponding to the given key.
|
java.lang.String |
getI18NString(java.lang.String key,
java.util.Locale locale)
Returns an internationalized string corresponding to the given key.
|
java.lang.String |
getI18NString(java.lang.String key,
java.lang.String[] params)
Returns an internationalized string corresponding to the given key.
|
java.lang.String |
getI18NString(java.lang.String key,
java.lang.String[] params,
java.util.Locale locale)
Returns an internationalized string corresponding to the given key.
|
javax.swing.ImageIcon |
getImage(java.lang.String imageID)
Loads an image from a given image identifier.
|
byte[] |
getImageInBytes(java.lang.String imageID)
Loads an image from a given image identifier.
|
protected ImagePack |
getImagePack()
Currently loaded image pack.
|
java.lang.String |
getImagePath(java.lang.String key)
Returns the image path corresponding to the given key.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getResources(ResourcePack resourcePack)
Returns the Map of (key, value) pairs contained in the given
resource pack.
|
java.io.InputStream |
getSettingsInputStream(java.lang.String streamKey)
Returns a stream from a given identifier.
|
java.io.InputStream |
getSettingsInputStream(java.lang.String streamKey,
java.lang.Class<?> resourceClass)
Returns a stream from a given identifier, obtained through the class
loader of the given resourceClass.
|
int |
getSettingsInt(java.lang.String key)
Returns the int value of the corresponding configuration key.
|
java.lang.String |
getSettingsString(java.lang.String key)
Returns the string value of the corresponding configuration key.
|
java.net.URL |
getSettingsURL(java.lang.String urlKey)
Returns an URL from a given identifier.
|
protected SkinPack |
getSkinPack()
Currently loaded SkinPack.
|
protected ResourcePack |
getSoundPack()
Currently loaded sound pack.
|
java.lang.String |
getSoundPath(java.lang.String soundKey)
Returns the path of the sound corresponding to the given
property key.
|
protected abstract void |
onSkinPackChanged()
Method is invoked when the SkinPack is loaded or unloaded.
|
void |
serviceChanged(org.osgi.framework.ServiceEvent event)
Handles all ServiceEvents corresponding to ResourcePack
being registered or unregistered.
|
public AbstractResourcesService(org.osgi.framework.BundleContext bundleContext)
bundleContext
- the OSGi bundle contextpublic void serviceChanged(org.osgi.framework.ServiceEvent event)
serviceChanged
in interface org.osgi.framework.ServiceListener
event
- the ServiceEvent that notified usprotected abstract void onSkinPackChanged()
protected <T extends ResourcePack> T getDefaultResourcePack(java.lang.Class<T> clazz, java.lang.String typeName)
className
- The name of the resource class.typeName
- The name of the type we're looking for.
For example: RESOURCE_NAME_DEFAULT_VALUEprotected java.util.Map<java.lang.String,java.lang.String> getResources(ResourcePack resourcePack)
resourcePack
- The ResourcePack from which we're obtaining
the resources.public java.util.Iterator<java.util.Locale> getAvailableLocales()
getAvailableLocales
in interface org.jitsi.service.resources.ResourceManagementService
protected java.lang.String doGetI18String(java.lang.String key, java.util.Locale locale)
key
- the key name for the stringlocale
- the Locale of the stringpublic java.lang.String getI18NString(java.lang.String key)
getI18NString
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the string in the resources properties file.public java.lang.String getI18NString(java.lang.String key, java.lang.String[] params)
getI18NString
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the string.params
- the parameters to pass to the localized stringpublic java.lang.String getI18NString(java.lang.String key, java.util.Locale locale)
getI18NString
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the string in the resources properties file.locale
- The locale.public java.lang.String getI18NString(java.lang.String key, java.lang.String[] params, java.util.Locale locale)
getI18NString
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the string in the resources properties
file.params
- the parameters to pass to the localized stringlocale
- The locale.public char getI18nMnemonic(java.lang.String key)
getI18nMnemonic
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the string in the resources properties file.public char getI18nMnemonic(java.lang.String key, java.util.Locale locale)
getI18nMnemonic
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the string in the resources properties file.locale
- The locale that we'd like to receive the result in.public java.lang.String getSettingsString(java.lang.String key)
getSettingsString
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the string in the resources properties file.public int getSettingsInt(java.lang.String key)
getSettingsInt
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the string in the resources properties file.public java.net.URL getSettingsURL(java.lang.String urlKey)
getSettingsURL
in interface org.jitsi.service.resources.ResourceManagementService
urlKey
- The identifier of the url.public java.io.InputStream getSettingsInputStream(java.lang.String streamKey)
getSettingsInputStream
in interface org.jitsi.service.resources.ResourceManagementService
streamKey
- The identifier of the stream.public java.io.InputStream getSettingsInputStream(java.lang.String streamKey, java.lang.Class<?> resourceClass)
getSettingsInputStream
in interface org.jitsi.service.resources.ResourceManagementService
streamKey
- The identifier of the stream.resourceClass
- the resource class through which the resource would
be obtainedpublic java.lang.String getImagePath(java.lang.String key)
getImagePath
in interface org.jitsi.service.resources.ResourceManagementService
key
- The identifier of the image in the resource properties file.public byte[] getImageInBytes(java.lang.String imageID)
getImageInBytes
in interface org.jitsi.service.resources.ResourceManagementService
imageID
- The identifier of the image.public javax.swing.ImageIcon getImage(java.lang.String imageID)
getImage
in interface org.jitsi.service.resources.ResourceManagementService
imageID
- The identifier of the image.public java.lang.String getSoundPath(java.lang.String soundKey)
getSoundPath
in interface org.jitsi.service.resources.ResourceManagementService
soundKey
- the key, for the sound pathprotected java.util.Map<java.lang.String,java.lang.String> getColorResources()
protected SkinPack getSkinPack()
protected ImagePack getImagePack()
protected ResourcePack getSoundPack()
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.