private SappAddressDecimal parseSappAddressStatus(String bindingStringAddress) throws BindingConfigParseException { String pnmasId; SappAddressType addressType; int address; String subAddress; int minScale; int maxScale; String[] bindingAddress = bindingStringAddress.split(":"); if (bindingAddress.length != 4 && bindingAddress.length != 6) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // pnmasId pnmasId = bindingAddress[0]; if (pnmasId.length() == 0) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // addressType addressType = SappAddressType.fromString(bindingAddress[1].toUpperCase()); if (!validAddresses.keySet().contains(addressType)) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // address try { address = Integer.parseInt(bindingAddress[2]); if (address < validAddresses.get(addressType).getLoRange() || address > validAddresses.get(addressType).getHiRange()) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } } catch (NumberFormatException e) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // subaddress subAddress = bindingAddress[3].toUpperCase(); if (!ArrayUtils.contains(validSubAddresses, subAddress)) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } if (bindingAddress.length == 6) { try { minScale = Integer.parseInt(bindingAddress[4]); maxScale = Integer.parseInt(bindingAddress[5]); } catch (NumberFormatException e) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } return new SappAddressDecimal(pnmasId, addressType, address, subAddress, minScale, maxScale); } else { return new SappAddressDecimal(pnmasId, addressType, address, subAddress); } }
private SappAddressOpenClosedStatus parseSappAddressStatus(String bindingStringAddress) throws BindingConfigParseException { String pnmasId; SappAddressType addressType; int address; String subAddress; int openValue = 1; String[] bindingAddress = bindingStringAddress.split(":"); if (bindingAddress.length != 4 && bindingAddress.length != 5) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // pnmasId pnmasId = bindingAddress[0]; if (pnmasId.length() == 0) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // addressType addressType = SappAddressType.fromString(bindingAddress[1].toUpperCase()); if (!validAddresses.keySet().contains(addressType)) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // address try { address = Integer.parseInt(bindingAddress[2]); if (address < validAddresses.get(addressType).getLoRange() || address > validAddresses.get(addressType).getHiRange()) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } } catch (NumberFormatException e) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // subaddress subAddress = bindingAddress[3].toUpperCase(); if (!ArrayUtils.contains(validSubAddresses, subAddress)) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } // openvalue if (bindingAddress.length == 5) { try { openValue = Integer.parseInt(bindingAddress[4]); } catch (NumberFormatException e) { throw new BindingConfigParseException(errorMessage(bindingStringAddress)); } } return new SappAddressOpenClosedStatus(pnmasId, addressType, address, subAddress, openValue); }