/** * Validate the check digit of an IBAN code. * * @param code The code to validate * @return <code>true</code> if the check digit is valid, otherwise * <code>false</code> */ @Override public boolean isValid(String code) { if (code == null || code.length() < MIN_CODE_LEN) { return false; } String check = code.substring(2,4); // CHECKSTYLE IGNORE MagicNumber if ("00".equals(check) || "01".equals(check) || "99".equals(check)) { return false; } try { int modulusResult = calculateModulus(code); return (modulusResult == 1); } catch (CheckDigitException ex) { return false; } }
return CHECK_IBAN.isValid(valueAsString);
return CHECK_IBAN.isValid(valueAsString);
/** * Calculate the <i>Check Digit</i> for an IBAN code. * <p> * <b>Note:</b> The check digit is the third and fourth * characters and is set to the value "<code>00</code>". * * @param code The code to calculate the Check Digit for * @return The calculated Check Digit as 2 numeric decimal characters, e.g. "42" * @throws CheckDigitException if an error occurs calculating * the check digit for the specified code */ @Override public String calculate(String code) throws CheckDigitException { if (code == null || code.length() < MIN_CODE_LEN) { throw new CheckDigitException("Invalid Code length=" + (code == null ? 0 : code.length())); } code = code.substring(0, 2) + "00" + code.substring(4); // CHECKSTYLE IGNORE MagicNumber int modulusResult = calculateModulus(code); int charValue = (98 - modulusResult); // CHECKSTYLE IGNORE MagicNumber String checkDigit = Integer.toString(charValue); return (charValue > 9 ? checkDigit : "0" + checkDigit); // CHECKSTYLE IGNORE MagicNumber }
return CHECK_IBAN.isValid(IbanUtil.ibanCompress(valueAsString));
/** * Validate the check digit of an IBAN code. * * @param code The code to validate * @return <code>true</code> if the check digit is valid, otherwise * <code>false</code> */ @Override public boolean isValid(String code) { if (code == null || code.length() < MIN_CODE_LEN) { return false; } String check = code.substring(2,4); // CHECKSTYLE IGNORE MagicNumber if ("00".equals(check) || "01".equals(check) || "99".equals(check)) { return false; } try { int modulusResult = calculateModulus(code); return (modulusResult == 1); } catch (CheckDigitException ex) { return false; } }
return CHECK_IBAN.isValid(IbanUtil.ibanCompress(valueAsString));
/** * Calculate the <i>Check Digit</i> for an IBAN code. * <p> * <b>Note:</b> The check digit is the third and fourth * characters and is set to the value "<code>00</code>". * * @param code The code to calculate the Check Digit for * @return The calculated Check Digit as 2 numeric decimal characters, e.g. "42" * @throws CheckDigitException if an error occurs calculating * the check digit for the specified code */ @Override public String calculate(String code) throws CheckDigitException { if (code == null || code.length() < MIN_CODE_LEN) { throw new CheckDigitException("Invalid Code length=" + (code == null ? 0 : code.length())); } code = code.substring(0, 2) + "00" + code.substring(4); // CHECKSTYLE IGNORE MagicNumber int modulusResult = calculateModulus(code); int charValue = (98 - modulusResult); // CHECKSTYLE IGNORE MagicNumber String checkDigit = Integer.toString(charValue); return (charValue > 9 ? checkDigit : "0" + checkDigit); // CHECKSTYLE IGNORE MagicNumber }