/* * (non-Javadoc) * * @see * org.openhab.binding.vdr.VDRBindingProvider#getBindingItemName(java.lang * .String, org.openhab.binding.vdr.internal.VDRCommandType) */ public String getBindingItemName(String vdrId, VDRCommandType vdrCommand) { String itemName = null; for (BindingConfig config : this.bindingConfigs.values()) { VDRBindingConfig vdrConfig = (VDRBindingConfig) config; if (vdrConfig.vDRId.equals(vdrId) && vdrConfig.command.equals(vdrCommand.getVDRCommand())) { itemName = vdrConfig.item.getName(); break; } } return itemName; }
/** * Checks if the bindingConfig contains a valid binding type and returns an appropriate instance. * * @param item * @param bindingConfig * @throws BindingConfigParseException if bindingConfig is no valid binding type */ protected VDRBindingConfig parseBindingConfig( Item item, String bindingConfigs, VDRBindingConfig parent) throws BindingConfigParseException { String bindingConfig = StringUtils.substringBefore(bindingConfigs, ","); String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ","); String[] configParts = bindingConfig.split(":"); if (configParts.length != 2) { throw new BindingConfigParseException( "VDR binding configuration must consist of two parts [config=" + configParts + "]"); } String vdrId = StringUtils.trim(configParts[0]); String command = StringUtils.trim(configParts[1]); if (command != null) { if (VDRCommandType.validateBinding(command, item.getClass())) { VDRBindingConfig vdrBindingConfig = new VDRBindingConfig(vdrId, command, item, parent); if (StringUtils.isNotBlank(bindingConfigTail)) { parseBindingConfig(item, bindingConfigTail, vdrBindingConfig); } return vdrBindingConfig; } else { String validItemType = VDRCommandType.getValidItemTypes(command); if (StringUtils.isEmpty(validItemType)) { throw new BindingConfigParseException("'" + bindingConfig + "' is no valid binding type"); } else { throw new BindingConfigParseException( "'" + bindingConfig + "' is not bound to a valid item type. Valid item type(s): " + validItemType); } } } else { throw new BindingConfigParseException("'" + bindingConfig + "' is no valid binding type"); } }