test_class.declarator: provider
test_class.modifier: private
test_class.original_string: private IconProvider provider;
test_class.type: IconProvider
test_class.var_name: provider
test_class.declarator: i18nProviderMock
test_class.modifier: private @Mock
test_class.original_string: private @Mock TranslationProvider i18nProviderMock;
test_class.type: TranslationProvider
test_class.var_name: i18nProviderMock
test_class.file: bundles/org.openhab.core.ui.icon/src/test/java/org/openhab/core/ui/icon/AbstractResourceIconProviderTest.java
test_class.identifier: AbstractResourceIconProviderTest
test_case.body: @Test
      public void testScanningForState() throws IOException {
          try (InputStream is = provider.getIcon("x", "classic", "34", Format.PNG)) {
              assertNotNull(is);
          }
  
          try (InputStream is = provider.getIcon("x", "classic", "25", Format.PNG)) {
              assertNull(is);
          }
      }
test_case.class_method_signature: AbstractResourceIconProviderTest.testScanningForState()
test_case.full_signature: @Test public void testScanningForState()
test_case.identifier: testScanningForState
test_case.invocations: getIcon assertNotNull getIcon assertNull
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testScanningForState()
focal_class.declarator: logger = LoggerFactory.getLogger(AbstractResourceIconProvider.class)
focal_class.modifier: private final
focal_class.original_string: private final Logger logger = LoggerFactory.getLogger(AbstractResourceIconProvider.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: i18nProvider
focal_class.modifier: protected final
focal_class.original_string: protected final TranslationProvider i18nProvider;
focal_class.type: TranslationProvider
focal_class.var_name: i18nProvider
focal_class.file: bundles/org.openhab.core.ui.icon/src/main/java/org/openhab/core/ui/icon/AbstractResourceIconProvider.java
focal_class.identifier: AbstractResourceIconProvider
focal_class.interfaces: implements IconProvider
focal_class.class_method_signature: AbstractResourceIconProvider.AbstractResourceIconProvider(final TranslationProvider i18nProvider)
focal_class.full_signature: public  AbstractResourceIconProvider(final TranslationProvider i18nProvider)
focal_class.identifier: AbstractResourceIconProvider
focal_class.modifiers: public
focal_class.parameters: (final TranslationProvider i18nProvider)
focal_class.signature:  AbstractResourceIconProvider(final TranslationProvider i18nProvider)
focal_class.class_method_signature: AbstractResourceIconProvider.getIconSets()
focal_class.full_signature: @Override public Set<IconSet> getIconSets()
focal_class.identifier: getIconSets
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Set<IconSet>
focal_class.signature: Set<IconSet> getIconSets()
focal_class.class_method_signature: AbstractResourceIconProvider.hasIcon(String category, String iconSetId, Format format)
focal_class.full_signature: @Override public @Nullable Integer hasIcon(String category, String iconSetId, Format format)
focal_class.identifier: hasIcon
focal_class.modifiers: @Override public @Nullable
focal_class.parameters: (String category, String iconSetId, Format format)
focal_class.return: Integer
focal_class.signature: Integer hasIcon(String category, String iconSetId, Format format)
focal_class.class_method_signature: AbstractResourceIconProvider.getIcon(String category, String iconSetId, @Nullable String state, Format format)
focal_class.full_signature: @Override public @Nullable InputStream getIcon(String category, String iconSetId, @Nullable String state, Format format)
focal_class.identifier: getIcon
focal_class.modifiers: @Override public @Nullable
focal_class.parameters: (String category, String iconSetId, @Nullable String state, Format format)
focal_class.return: InputStream
focal_class.signature: InputStream getIcon(String category, String iconSetId, @Nullable String state, Format format)
focal_class.class_method_signature: AbstractResourceIconProvider.getPriority()
focal_class.full_signature: protected abstract Integer getPriority()
focal_class.identifier: getPriority
focal_class.modifiers: protected abstract
focal_class.parameters: ()
focal_class.return: Integer
focal_class.signature: Integer getPriority()
focal_class.class_method_signature: AbstractResourceIconProvider.getResource(String iconSetId, String resourceName)
focal_class.full_signature: protected abstract @Nullable InputStream getResource(String iconSetId, String resourceName)
focal_class.identifier: getResource
focal_class.modifiers: protected abstract @Nullable
focal_class.parameters: (String iconSetId, String resourceName)
focal_class.return: InputStream
focal_class.signature: InputStream getResource(String iconSetId, String resourceName)
focal_class.class_method_signature: AbstractResourceIconProvider.hasResource(String iconSetId, String resourceName)
focal_class.full_signature: protected abstract boolean hasResource(String iconSetId, String resourceName)
focal_class.identifier: hasResource
focal_class.modifiers: protected abstract
focal_class.parameters: (String iconSetId, String resourceName)
focal_class.return: boolean
focal_class.signature: boolean hasResource(String iconSetId, String resourceName)
focal_method.body: @Override
      public @Nullable InputStream getIcon(String category, String iconSetId, @Nullable String state, Format format) {
          String resourceWithoutState = category.toLowerCase() + "." + format.toString().toLowerCase();
          if (state == null) {
              return getResource(iconSetId, resourceWithoutState);
          }
  
          String iconState;
          if (state.contains(" ")) {
              try {
                  String firstPart = state.substring(0, state.indexOf(" "));
                  Double.valueOf(firstPart);
                  iconState = firstPart;
              } catch (NumberFormatException e) {
                  // firstPart is not a number, pass on the full state
                  iconState = state;
              }
          } else {
              iconState = state;
          }
  
          String resourceWithState = category.toLowerCase() + "-" + iconState.toLowerCase() + "."
                  + format.toString().toLowerCase();
          if (hasResource(iconSetId, resourceWithState)) {
              return getResource(iconSetId, resourceWithState);
          } else {
              // let's treat all percentage-based categories
              try {
                  Double stateAsDouble = Double.valueOf(iconState);
                  if (stateAsDouble >= 0 && stateAsDouble <= 100) {
                      for (int i = stateAsDouble.intValue(); i >= 0; i--) {
                          String resourceWithNumberState = category.toLowerCase() + "-" + i + "."
                                  + format.toString().toLowerCase();
                          if (hasResource(iconSetId, resourceWithNumberState)) {
                              return getResource(iconSetId, resourceWithNumberState);
                          }
                      }
                  }
              } catch (NumberFormatException e) {
                  // does not seem to be a number, so ignore it
              }
              logger.debug("Use icon {} as {} is not found", resourceWithoutState, resourceWithState);
              return getResource(iconSetId, resourceWithoutState);
          }
      }
focal_method.class_method_signature: AbstractResourceIconProvider.getIcon(String category, String iconSetId, @Nullable String state, Format format)
focal_method.full_signature: @Override public @Nullable InputStream getIcon(String category, String iconSetId, @Nullable String state, Format format)
focal_method.identifier: getIcon
focal_method.invocations: toLowerCase toLowerCase toString getResource contains substring indexOf valueOf toLowerCase toLowerCase toLowerCase toString hasResource getResource valueOf intValue toLowerCase toLowerCase toString hasResource getResource debug getResource
focal_method.modifiers: @Override public @Nullable
focal_method.parameters: (String category, String iconSetId, @Nullable String state, Format format)
focal_method.return: InputStream
focal_method.signature: InputStream getIcon(String category, String iconSetId, @Nullable String state, Format format)