Class QRBill


  • public class QRBill
    extends java.lang.Object
    Generates Swiss QR bill payment part.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String KEY_ACCOUNT_IS_CH_LI_IBAN
      Validation message key: IBAN must be from bank in Switzerland or Liechtenstein
      static java.lang.String KEY_ACCOUNT_IS_VALID_IBAN
      Validation message key: IBAN number must have valid format and check digit
      static java.lang.String KEY_ADDRESS_TYPE_CONFLICT
      Validation message key: Fields for both structured and combined elements address type have been filled in
      static java.lang.String KEY_ALT_SCHEME_MAX_EXCEEDED
      Validation message key: The maximum of 2 alternative schemes has been exceeded
      static java.lang.String KEY_AMOUNT_IS_IN_VALID_RANGE
      Validation message key: amount must be between 0.01 and 999999999.99
      static java.lang.String KEY_CURRENCY_IS_CHF_OR_EUR
      Validation message key: currency must be "CHF" or "EUR"
      static java.lang.String KEY_FIELD_CLIPPED
      Validation message key: Field has been clipped to not exceed the maximum length
      static java.lang.String KEY_FIELD_IS_MANDATORY
      Validation message key: Field is mandatory
      static java.lang.String KEY_MANDATORY_FOR_QR_IBAN
      Validation message key: Reference number is mandatory for IBANs with QR-IID
      static java.lang.String KEY_REPLACED_UNSUPPORTED_CHARACTERS
      Validation message key: Unsupported characters have been replaced
      static java.lang.String KEY_SUPPORTED_CODING_TYPE
      Validation message key: Coding type 1 is supported only
      static java.lang.String KEY_SUPPORTED_VERSION
      Validation message key: Version 01.00 is supported only
      static java.lang.String KEY_VALID_COUNTRY_CODE
      Validation message key: Country code must consist of two letters
      static java.lang.String KEY_VALID_DATA_STRUCTURE
      Validation message key: Valid data structure starts with "SPC" and consists of 28 to 30 lines of text
      static java.lang.String KEY_VALID_ISO11649_CREDITOR_REF
      Validation message key: ISO 11649 reference number must have valid format and check digit
      static java.lang.String KEY_VALID_NUMBER
      Validation message key: Valid number required (nnnnn.nn)
      static java.lang.String KEY_VALID_QR_REF_NO
      Validation message key: QR reference number must have valid format and check digit
    • Constructor Summary

      Constructors 
      Constructor Description
      QRBill()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Bill decodeQrCodeText​(java.lang.String text)
      Decodes the text embedded in the QR code and fills it into a Bill data structure.
      static java.lang.String encodeQrCodeText​(Bill bill)
      Encodes the text embedded in the QR code from the specified bill data.
      static byte[] generate​(Bill bill)
      Generates a QR bill payment part.
      static byte[] generate​(Bill bill, Canvas canvas)
      Generates a QR bill payment part using the specified canvas.
      static ValidationResult validate​(Bill bill)
      Validates and cleans the bill data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • KEY_CURRENCY_IS_CHF_OR_EUR

        public static final java.lang.String KEY_CURRENCY_IS_CHF_OR_EUR
        Validation message key: currency must be "CHF" or "EUR"
        See Also:
        Constant Field Values
      • KEY_AMOUNT_IS_IN_VALID_RANGE

        public static final java.lang.String KEY_AMOUNT_IS_IN_VALID_RANGE
        Validation message key: amount must be between 0.01 and 999999999.99
        See Also:
        Constant Field Values
      • KEY_ACCOUNT_IS_CH_LI_IBAN

        public static final java.lang.String KEY_ACCOUNT_IS_CH_LI_IBAN
        Validation message key: IBAN must be from bank in Switzerland or Liechtenstein
        See Also:
        Constant Field Values
      • KEY_ACCOUNT_IS_VALID_IBAN

        public static final java.lang.String KEY_ACCOUNT_IS_VALID_IBAN
        Validation message key: IBAN number must have valid format and check digit
        See Also:
        Constant Field Values
      • KEY_VALID_ISO11649_CREDITOR_REF

        public static final java.lang.String KEY_VALID_ISO11649_CREDITOR_REF
        Validation message key: ISO 11649 reference number must have valid format and check digit
        See Also:
        Constant Field Values
      • KEY_VALID_QR_REF_NO

        public static final java.lang.String KEY_VALID_QR_REF_NO
        Validation message key: QR reference number must have valid format and check digit
        See Also:
        Constant Field Values
      • KEY_MANDATORY_FOR_QR_IBAN

        public static final java.lang.String KEY_MANDATORY_FOR_QR_IBAN
        Validation message key: Reference number is mandatory for IBANs with QR-IID
        See Also:
        Constant Field Values
      • KEY_FIELD_IS_MANDATORY

        public static final java.lang.String KEY_FIELD_IS_MANDATORY
        Validation message key: Field is mandatory
        See Also:
        Constant Field Values
      • KEY_ADDRESS_TYPE_CONFLICT

        public static final java.lang.String KEY_ADDRESS_TYPE_CONFLICT
        Validation message key: Fields for both structured and combined elements address type have been filled in
        See Also:
        Constant Field Values
      • KEY_VALID_COUNTRY_CODE

        public static final java.lang.String KEY_VALID_COUNTRY_CODE
        Validation message key: Country code must consist of two letters
        See Also:
        Constant Field Values
      • KEY_FIELD_CLIPPED

        public static final java.lang.String KEY_FIELD_CLIPPED
        Validation message key: Field has been clipped to not exceed the maximum length
        See Also:
        Constant Field Values
      • KEY_REPLACED_UNSUPPORTED_CHARACTERS

        public static final java.lang.String KEY_REPLACED_UNSUPPORTED_CHARACTERS
        Validation message key: Unsupported characters have been replaced
        See Also:
        Constant Field Values
      • KEY_VALID_DATA_STRUCTURE

        public static final java.lang.String KEY_VALID_DATA_STRUCTURE
        Validation message key: Valid data structure starts with "SPC" and consists of 28 to 30 lines of text
        See Also:
        Constant Field Values
      • KEY_SUPPORTED_VERSION

        public static final java.lang.String KEY_SUPPORTED_VERSION
        Validation message key: Version 01.00 is supported only
        See Also:
        Constant Field Values
      • KEY_SUPPORTED_CODING_TYPE

        public static final java.lang.String KEY_SUPPORTED_CODING_TYPE
        Validation message key: Coding type 1 is supported only
        See Also:
        Constant Field Values
      • KEY_VALID_NUMBER

        public static final java.lang.String KEY_VALID_NUMBER
        Validation message key: Valid number required (nnnnn.nn)
        See Also:
        Constant Field Values
      • KEY_ALT_SCHEME_MAX_EXCEEDED

        public static final java.lang.String KEY_ALT_SCHEME_MAX_EXCEEDED
        Validation message key: The maximum of 2 alternative schemes has been exceeded
        See Also:
        Constant Field Values
    • Constructor Detail

      • QRBill

        public QRBill()
    • Method Detail

      • validate

        public static ValidationResult validate​(Bill bill)
        Validates and cleans the bill data.

        The validation result contains the error and warning messages (if any) and the cleaned bill data.

        For details about the validation result, see Bill data validation

        Parameters:
        bill - bill data
        Returns:
        validation result
      • generate

        public static byte[] generate​(Bill bill)
        Generates a QR bill payment part.

        If the bill data does not validate, a QRBillValidationError is thrown, which contains the validation result. For details about the validation result, see Bill data validation

        Parameters:
        bill - the bill data
        Returns:
        the generated QR bill (as a byte array)
        Throws:
        QRBillValidationError - thrown if the bill data does not validate
      • generate

        public static byte[] generate​(Bill bill,
                                      Canvas canvas)
        Generates a QR bill payment part using the specified canvas.

        If the bill data does not validate, a QRBillValidationError is thrown, which contains the validation result. For details about the validation result, see Bill data validation

        The canvas will be initialized with Canvas#setupPage and it will be closed before returning the generated QR bill

        Parameters:
        bill - the bill data
        canvas - the canvas to draw to
        Returns:
        the generated QR bill (as a byte array)
        Throws:
        QRBillValidationError - thrown if the bill data does not validate
      • encodeQrCodeText

        public static java.lang.String encodeQrCodeText​(Bill bill)
        Encodes the text embedded in the QR code from the specified bill data.

        The specified bill data is first validated and cleaned.

        If the bill data does not validate, a QRBillValidationError is thrown, which contains the validation result. For details about the validation result, see Bill data validation

        Parameters:
        bill - the bill data to encode
        Returns:
        the QR code text
        Throws:
        QRBillValidationError - thrown if the bill data does not validate
      • decodeQrCodeText

        public static Bill decodeQrCodeText​(java.lang.String text)
        Decodes the text embedded in the QR code and fills it into a Bill data structure.

        A subset of the validations related to embedded QR code text is run. It the validation fails, a QRBillValidationError is thrown, which contains the validation result. See the error messages marked with a dagger in Bill data validation.

        Parameters:
        text - the text to decode
        Returns:
        the decoded bill data
        Throws:
        QRBillValidationError - thrown if the bill data does not validate