ItemUIRegistryImpl implements ItemUIRegistry { protected String formatUndefined(String formatPattern) { String undefinedFormatPattern = formatPattern.replaceAll(IDENTIFY_FORMAT_PATTERN_PATTERN, "%1\\$s"); try { return String.format(undefinedFormatPattern, "-"); } catch (Exception e) { logger.warn( "Exception while formatting undefined value [sourcePattern={}, targetPattern={}, exceptionMessage={}]", formatPattern, undefinedFormatPattern, e.getMessage()); return "Err"; } } @Activate  ItemUIRegistryImpl(@Reference ItemRegistry itemRegistry); @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) void addItemUIProvider(ItemUIProvider itemUIProvider); void removeItemUIProvider(ItemUIProvider itemUIProvider); @Override @Nullable String getCategory(String itemName); @Override @Nullable String getLabel(String itemName); @Override @Nullable Widget getWidget(String itemName); @Override @Nullable Widget getDefaultWidget(@Nullable Class<? extends Item> targetItemType, String itemName); @Override @Nullable String getLabel(Widget w); @Override @Nullable String getCategory(Widget w); @Override @Nullable State getState(Widget w); @Override @Nullable State convertState(Widget w, Item i, State state); @Override @Nullable Widget getWidget(Sitemap sitemap, String id); @Override EList<Widget> getChildren(Sitemap sitemap); @Override EList<Widget> getChildren(LinkableWidget w); @Override @Nullable EObject getParent(Widget w); @Override @Nullable State getItemState(String itemName); @Nullable String getItemCategory(String itemName); @Override Item getItem(String name); @Override Item getItemByPattern(String name); @Override Collection<Item> getItems(); @Override Collection<Item> getItemsOfType(String type); @Override Collection<Item> getItems(String pattern); @Override void addRegistryChangeListener(RegistryChangeListener<Item> listener); @Override void removeRegistryChangeListener(RegistryChangeListener<Item> listener); @Override Collection<Item> getAll(); @Override Stream<Item> stream(); @Override String getWidgetId(Widget widget); @Override @Nullable String getLabelColor(Widget w); @Override @Nullable String getValueColor(Widget w); @Override boolean getVisiblity(Widget w); @Override Collection<Item> getItemsByTag(String... tags); @Override Collection<Item> getItemsByTagAndType(String type, String... tags); @Override Collection<T> getItemsByTag(Class<T> typeFilter, String... tags); @Override Item add(Item element); @Override @Nullable Item update(Item element); @Override @Nullable Item remove(String key); @Override @Nullable Item get(String key); @Override @Nullable Item remove(String itemName, boolean recursive); @Override void addRegistryHook(RegistryHook<Item> hook); @Override void removeRegistryHook(RegistryHook<Item> hook); @Override @Nullable String getUnitForWidget(Widget w); @Override @Nullable State convertStateToLabelUnit(QuantityType<?> state, String label);  }
@Test public void testFormatDefault() { assertEquals("Server [(-)]", uiRegistry.formatUndefined("Server [(%d)]")); assertEquals("Anruf [von - an -]", uiRegistry.formatUndefined("Anruf [von %2$s an %1$s]")); assertEquals("Zeit [-.-.- -]", uiRegistry.formatUndefined("Zeit [%1$td.%1$tm.%1$tY %1$tT]")); assertEquals("Temperatur [- °C]", uiRegistry.formatUndefined("Temperatur [%.1f °C]")); assertEquals("Luftfeuchte [- %]", uiRegistry.formatUndefined("Luftfeuchte [%.1f %%]")); }