Class Payments

java.lang.Object
net.codecrete.qrbill.generator.Payments

public class Payments extends Object
Field validations related to Swiss Payment standards
  • Method Details

    • isValidText

      public static boolean isValidText(String text, SPSCharacterSet characterSet)
      Indicates if the text consists only of characters allowed in the specified character set.

      This method does not attempt to deal with accents and umlauts built from two code points. It will return false if the text contains such characters.

      Parameters:
      text - text to check, possibly null
      characterSet - character set specifying valid characters
      Returns:
      true if the text is valid, false otherwise
    • isValidIBAN

      public static boolean isValidIBAN(String iban)
      Validates if the string is a valid IBAN number

      The string is checked for valid characters, valid length and for a valid check digit. White space is ignored.

      Parameters:
      iban - IBAN to validate
      Returns:
      true if the IBAN is valid, false otherwise
    • isQRIBAN

      public static boolean isQRIBAN(String iban)
      Indicates if the string is a valid QR-IBAN.

      QR-IBANs are IBANs with an institution ID in the range 30000 to 31999 and a country code for Switzerland or Liechtenstein. Thus, they must have the format "CH..30...", "CH..31...", "LI..30..." or "LI..31...".

      Parameters:
      iban - account number to check
      Returns:
      true for valid QR-IBANs, false otherwise
    • formatIBAN

      public static String formatIBAN(String iban)
      Formats an IBAN or creditor reference by inserting spaces.

      Spaces are inserted to form groups of 4 letters/digits. If a group of less than 4 letters/digits is needed, it appears at the end.

      Parameters:
      iban - IBAN or creditor reference without spaces
      Returns:
      formatted IBAN or creditor reference
    • isValidISO11649Reference

      public static boolean isValidISO11649Reference(String reference)
      Validates if the string is a valid ISO 11649 reference number.

      The string is checked for valid characters, valid length and a valid check digit. White space is ignored.

      Parameters:
      reference - ISO 11649 creditor reference to validate
      Returns:
      true if the creditor reference is valid, false otherwise
    • createISO11649Reference

      public static String createISO11649Reference(String rawReference)
      Creates a ISO11649 creditor reference from a raw string by prefixing the string with "RF" and the modulo 97 checksum.

      Whitespace is removed from the reference

      Parameters:
      rawReference - The raw string
      Returns:
      ISO11649 creditor reference
      Throws:
      IllegalArgumentException - if rawReference contains invalid characters
    • isValidQRReference

      public static boolean isValidQRReference(String reference)
      Validates if the string is a valid QR reference.

      A valid QR reference is a valid ISR reference.

      The string is checked for valid characters, valid length and a valid check digit. White space is ignored.

      Parameters:
      reference - QR reference number to validate
      Returns:
      true if the reference number is valid, false otherwise
    • createQRReference

      public static String createQRReference(String rawReference)
      Creates a QR reference from a raw string by appending the checksum digit and prepending zeros to make it the correct length.

      Whitespace is removed from the reference

      Parameters:
      rawReference - The raw string (digits and whitespace only)
      Returns:
      QR reference
      Throws:
      IllegalArgumentException - if rawReference contains invalid characters
    • formatQRReferenceNumber

      public static String formatQRReferenceNumber(String refNo)
      Formats a QR reference number by inserting spaces.

      Spaces are inserted to create groups of 5 digits. If a group of less than 5 digits is needed, it appears at the start of the formatted reference number.

      Parameters:
      refNo - reference number without white space
      Returns:
      formatted reference number