Class QRBill
- java.lang.Object
-
- net.codecrete.qrbill.generator.QRBill
-
public class QRBill extends java.lang.ObjectGenerates Swiss QR bill payment part.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringKEY_ACCOUNT_IS_CH_LI_IBANValidation message key: IBAN must be from bank in Switzerland or Liechtensteinstatic java.lang.StringKEY_ACCOUNT_IS_VALID_IBANValidation message key: IBAN number must have valid format and check digitstatic java.lang.StringKEY_ADDRESS_TYPE_CONFLICTValidation message key: Fields for both structured and combined elements address type have been filled instatic java.lang.StringKEY_ALT_SCHEME_MAX_EXCEEDEDValidation message key: The maximum of 2 alternative schemes has been exceededstatic java.lang.StringKEY_AMOUNT_IS_IN_VALID_RANGEValidation message key: amount must be between 0.01 and 999999999.99static java.lang.StringKEY_CURRENCY_IS_CHF_OR_EURValidation message key: currency must be "CHF" or "EUR"static java.lang.StringKEY_FIELD_CLIPPEDValidation message key: Field has been clipped to not exceed the maximum lengthstatic java.lang.StringKEY_FIELD_IS_MANDATORYValidation message key: Field is mandatorystatic java.lang.StringKEY_MANDATORY_FOR_QR_IBANValidation message key: Reference number is mandatory for IBANs with QR-IIDstatic java.lang.StringKEY_REPLACED_UNSUPPORTED_CHARACTERSValidation message key: Unsupported characters have been replacedstatic java.lang.StringKEY_SUPPORTED_CODING_TYPEValidation message key: Coding type 1 is supported onlystatic java.lang.StringKEY_SUPPORTED_VERSIONValidation message key: Version 01.00 is supported onlystatic java.lang.StringKEY_VALID_COUNTRY_CODEValidation message key: Country code must consist of two lettersstatic java.lang.StringKEY_VALID_DATA_STRUCTUREValidation message key: Valid data structure starts with "SPC" and consists of 28 to 30 lines of textstatic java.lang.StringKEY_VALID_ISO11649_CREDITOR_REFValidation message key: ISO 11649 reference number must have valid format and check digitstatic java.lang.StringKEY_VALID_NUMBERValidation message key: Valid number required (nnnnn.nn)static java.lang.StringKEY_VALID_QR_REF_NOValidation 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 BilldecodeQrCodeText(java.lang.String text)Decodes the text embedded in the QR code and fills it into aBilldata structure.static java.lang.StringencodeQrCodeText(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 ValidationResultvalidate(Bill bill)Validates and cleans the bill data.
-
-
-
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
-
-
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
QRBillValidationErroris 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
QRBillValidationErroris thrown, which contains the validation result. For details about the validation result, see Bill data validationThe canvas will be initialized with
Canvas#setupPageand it will be closed before returning the generated QR bill- Parameters:
bill- the bill datacanvas- 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
QRBillValidationErroris 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 aBilldata structure.A subset of the validations related to embedded QR code text is run. It the validation fails, a
QRBillValidationErroris 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
-
-