From bcefab613f2cc088c0ff09d8d20e67ef2af86fe8 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Tue, 30 Sep 2014 22:40:08 +0300 Subject: Fixes warnings. --- .../resources/AbstractResourcesService.java | 128 +++++++++++---------- 1 file changed, 68 insertions(+), 60 deletions(-) (limited to 'src/net/java/sip/communicator/service') diff --git a/src/net/java/sip/communicator/service/resources/AbstractResourcesService.java b/src/net/java/sip/communicator/service/resources/AbstractResourcesService.java index 0fe9028..0b38fdc 100644 --- a/src/net/java/sip/communicator/service/resources/AbstractResourcesService.java +++ b/src/net/java/sip/communicator/service/resources/AbstractResourcesService.java @@ -6,17 +6,19 @@ */ package net.java.sip.communicator.service.resources; -import net.java.sip.communicator.util.*; -import org.jitsi.service.configuration.*; -import org.jitsi.service.resources.*; -import org.osgi.framework.*; - -import javax.swing.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; +import javax.swing.*; + +import net.java.sip.communicator.util.*; + +import org.jitsi.service.configuration.*; +import org.jitsi.service.resources.*; +import org.osgi.framework.*; + /** * The abstract class for ResourceManagementService. It listens for * {@link ResourcePack} that are registered and exposes them later for use by @@ -109,16 +111,18 @@ public abstract class AbstractResourcesService this.bundleContext = bundleContext; bundleContext.addServiceListener(this); - colorPack = - getDefaultResourcePack(ColorPack.class.getName(), - ColorPack.RESOURCE_NAME_DEFAULT_VALUE); + colorPack + = getDefaultResourcePack( + ColorPack.class, + ColorPack.RESOURCE_NAME_DEFAULT_VALUE); if (colorPack != null) colorResources = getResources(colorPack); - imagePack = (ImagePack) getDefaultResourcePack( - ImagePack.class.getName(), - ImagePack.RESOURCE_NAME_DEFAULT_VALUE); + imagePack + = getDefaultResourcePack( + ImagePack.class, + ImagePack.RESOURCE_NAME_DEFAULT_VALUE); if (imagePack != null) imageResources = getResources(imagePack); @@ -132,9 +136,10 @@ public abstract class AbstractResourcesService Locale.setDefault( ResourceManagementServiceUtils.getLocale(defaultLocale)); - languagePack = (LanguagePack) getDefaultResourcePack( - LanguagePack.class.getName(), - LanguagePack.RESOURCE_NAME_DEFAULT_VALUE); + languagePack + = getDefaultResourcePack( + LanguagePack.class, + LanguagePack.RESOURCE_NAME_DEFAULT_VALUE); if (languagePack != null) { @@ -142,22 +147,26 @@ public abstract class AbstractResourcesService languageResources = languagePack.getResources(languageLocale); } - settingsPack = - getDefaultResourcePack(SettingsPack.class.getName(), - SettingsPack.RESOURCE_NAME_DEFAULT_VALUE); + settingsPack + = getDefaultResourcePack( + SettingsPack.class, + SettingsPack.RESOURCE_NAME_DEFAULT_VALUE); if (settingsPack != null) settingsResources = getResources(settingsPack); - soundPack = - getDefaultResourcePack(SoundPack.class.getName(), - SoundPack.RESOURCE_NAME_DEFAULT_VALUE); + soundPack + = getDefaultResourcePack( + SoundPack.class, + SoundPack.RESOURCE_NAME_DEFAULT_VALUE); if (soundPack != null) soundResources = getResources(soundPack); - skinPack = (SkinPack) getDefaultResourcePack( - SkinPack.class.getName(), SkinPack.RESOURCE_NAME_DEFAULT_VALUE); + skinPack + = getDefaultResourcePack( + SkinPack.class, + SkinPack.RESOURCE_NAME_DEFAULT_VALUE); if (skinPack != null) { @@ -247,48 +256,48 @@ public abstract class AbstractResourcesService if(resourcePack instanceof ColorPack && colorPack.equals(resourcePack)) { - colorPack = - getDefaultResourcePack(ColorPack.class.getName(), - ColorPack.RESOURCE_NAME_DEFAULT_VALUE); - + colorPack + = getDefaultResourcePack( + ColorPack.class, + ColorPack.RESOURCE_NAME_DEFAULT_VALUE); if (colorPack != null) colorResources = getResources(colorPack); } else if(resourcePack instanceof ImagePack && imagePack.equals(resourcePack)) { - imagePack = (ImagePack) getDefaultResourcePack( - ImagePack.class.getName(), - ImagePack.RESOURCE_NAME_DEFAULT_VALUE); - + imagePack + = getDefaultResourcePack( + ImagePack.class, + ImagePack.RESOURCE_NAME_DEFAULT_VALUE); if (imagePack != null) imageResources = getResources(imagePack); } else if(resourcePack instanceof LanguagePack && languagePack.equals(resourcePack)) { - languagePack = - (LanguagePack) getDefaultResourcePack( - LanguagePack.class.getName(), - LanguagePack.RESOURCE_NAME_DEFAULT_VALUE); + languagePack + = getDefaultResourcePack( + LanguagePack.class, + LanguagePack.RESOURCE_NAME_DEFAULT_VALUE); } else if(resourcePack instanceof SettingsPack && settingsPack.equals(resourcePack)) { - settingsPack = - getDefaultResourcePack(SettingsPack.class.getName(), - SettingsPack.RESOURCE_NAME_DEFAULT_VALUE); - + settingsPack + = getDefaultResourcePack( + SettingsPack.class, + SettingsPack.RESOURCE_NAME_DEFAULT_VALUE); if (settingsPack != null) settingsResources = getResources(settingsPack); } else if(resourcePack instanceof SoundPack && soundPack.equals(resourcePack)) { - soundPack = - getDefaultResourcePack(SoundPack.class.getName(), - SoundPack.RESOURCE_NAME_DEFAULT_VALUE); - + soundPack + = getDefaultResourcePack( + SoundPack.class, + SoundPack.RESOURCE_NAME_DEFAULT_VALUE); if (soundPack != null) soundResources = getResources(soundPack); } @@ -310,10 +319,10 @@ public abstract class AbstractResourcesService settingsResources = getResources(settingsPack); } - skinPack = (SkinPack) getDefaultResourcePack( - SkinPack.class.getName(), - SkinPack.RESOURCE_NAME_DEFAULT_VALUE); - + skinPack + = getDefaultResourcePack( + SkinPack.class, + SkinPack.RESOURCE_NAME_DEFAULT_VALUE); if (skinPack != null) { imageResources.putAll(skinPack.getImageResources()); @@ -341,28 +350,27 @@ public abstract class AbstractResourcesService * @return the ResourcePack corresponding to the given * className and . */ - protected ResourcePack getDefaultResourcePack(String className, - String typeName) + protected T getDefaultResourcePack( + Class clazz, + String typeName) { - ServiceReference[] serRefs = null; - - String osgiFilter = - "(" + ResourcePack.RESOURCE_NAME + "=" + typeName + ")"; + Collection> serRefs; + String osgiFilter + = "(" + ResourcePack.RESOURCE_NAME + "=" + typeName + ")"; try { - serRefs = bundleContext.getServiceReferences( - className, - osgiFilter); + serRefs = bundleContext.getServiceReferences(clazz, osgiFilter); } - catch (InvalidSyntaxException exc) + catch (InvalidSyntaxException ex) { - logger.error("Could not obtain resource packs reference.", exc); + serRefs = null; + logger.error("Could not obtain resource packs reference.", ex); } - if ((serRefs != null) && (serRefs.length > 0)) + if ((serRefs != null) && !serRefs.isEmpty()) { - return (ResourcePack) bundleContext.getService(serRefs[0]); + return bundleContext.getService(serRefs.iterator().next()); } return null; } -- cgit v1.1