java.lang.Object
bayern.steinbrecher.javaUtility.SepaUtility
public final class SepaUtility
extends java.lang.Object
Contains methods for checking some Sepa Direct Debit attributes.
- Since:
- 0.1
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBIC_REGEXThe regex representing all valid BICs.static java.lang.StringIBAN_REGEXRegex describing a possible valid IBAN (the checksum of the IBAN is not checked by this regex).static intMAX_CHAR_IBANThe maximum length of an IBAN.static intMAX_CHAR_MESSAGE_IDThe maximum length of the message id.static intMAX_CHAR_NAME_FIELDThe maximum length of the name of the party creating the SEPA Direct Debit.static intMAX_CHAR_PMTINFIDThe maximum length of payment information id (PmtInfId).static java.lang.StringMESSAGE_ID_REGEXThe regex for checking whether a message id is valid.static intUNIQUE_DAYS_MESSAGEIDHolds the count of days the MessageId has to be unique.static intUNIQUE_MONTH_PMTINFIDHolds the count of month the PmtInfId has to be unique. -
Method Summary
Modifier and Type Method Description static java.lang.StringgetSepaDate(java.time.LocalDate date)Returns aStringrepresentation of the givenLocalDatewhich is valid for SEPA Direct Debits.static java.lang.StringgetSepaDate(java.time.LocalDateTime dateTime)Returns aStringrepresentation of the givenLocalDateTimewhich is valid for SEPA Direct Debits.static booleanisValidBic(java.lang.String bic)Checks whether the given BIC is valid.static booleanisValidCreditorId(java.lang.String creditorId)Checks whether the given creditor id is valid.static booleanisValidIban(java.lang.String iban)Checks whether the IBAN of the given member has a valid checksum.static booleanisValidMessageId(java.lang.String messageId)Checks whether the given message id would be valid for being used in a Sepa Direct Debit.static java.util.Optional<java.lang.String>validateSepaXML(java.lang.String xml)Checks whether the givenStringcontains valid SEPA DD content.
-
Field Details
-
UNIQUE_DAYS_MESSAGEID
public static final int UNIQUE_DAYS_MESSAGEIDHolds the count of days the MessageId has to be unique.- See Also:
- Constant Field Values
-
MAX_CHAR_MESSAGE_ID
public static final int MAX_CHAR_MESSAGE_IDThe maximum length of the message id.- See Also:
- Constant Field Values
-
UNIQUE_MONTH_PMTINFID
public static final int UNIQUE_MONTH_PMTINFIDHolds the count of month the PmtInfId has to be unique.- See Also:
- Constant Field Values
-
MAX_CHAR_PMTINFID
public static final int MAX_CHAR_PMTINFIDThe maximum length of payment information id (PmtInfId).- See Also:
- Constant Field Values
-
MAX_CHAR_IBAN
public static final int MAX_CHAR_IBANThe maximum length of an IBAN.- See Also:
- Constant Field Values
-
MAX_CHAR_NAME_FIELD
public static final int MAX_CHAR_NAME_FIELDThe maximum length of the name of the party creating the SEPA Direct Debit.- See Also:
- Constant Field Values
-
IBAN_REGEX
public static final java.lang.String IBAN_REGEXRegex describing a possible valid IBAN (the checksum of the IBAN is not checked by this regex).- See Also:
- Constant Field Values
-
BIC_REGEX
public static final java.lang.String BIC_REGEXThe regex representing all valid BICs.- See Also:
- Constant Field Values
-
MESSAGE_ID_REGEX
public static final java.lang.String MESSAGE_ID_REGEXThe regex for checking whether a message id is valid. Which characters are supported by Sepa is taken from http://www.sepaforcorporates.com/sepa-implementation/valid-xml-characters-sepa-payments/- See Also:
- Constant Field Values
-
-
Method Details
-
isValidIban
public static boolean isValidIban(java.lang.String iban)Checks whether the IBAN of the given member has a valid checksum.- Parameters:
iban- The IBAN to check.- Returns:
trueonly if IBAN has a valid checksum.- See Also:
IBAN_PATTERN
-
isValidBic
public static boolean isValidBic(java.lang.String bic)Checks whether the given BIC is valid. Currently only the length and the allowed characters are checked.- Parameters:
bic- The BIC to check.- Returns:
falseonly if the BIC is invalid.- See Also:
BIC_PATTERN
-
isValidCreditorId
public static boolean isValidCreditorId(java.lang.String creditorId)Checks whether the given creditor id is valid.- Parameters:
creditorId- The creditor id to check.- Returns:
trueonly if the given creditor id is valid.
-
isValidMessageId
public static boolean isValidMessageId(java.lang.String messageId)Checks whether the given message id would be valid for being used in a Sepa Direct Debit.- Parameters:
messageId- The message id to check.- Returns:
trueonly if the message id is valid.
-
getSepaDate
public static java.lang.String getSepaDate(java.time.LocalDateTime dateTime)Returns aStringrepresentation of the givenLocalDateTimewhich is valid for SEPA Direct Debits.- Parameters:
dateTime- The date to convert.- Returns:
- The valid representation of the given
LocalDateTime.
-
getSepaDate
public static java.lang.String getSepaDate(java.time.LocalDate date)Returns aStringrepresentation of the givenLocalDatewhich is valid for SEPA Direct Debits.- Parameters:
date- The date to convert.- Returns:
- The valid representation of the given
LocalDate.
-
validateSepaXML
public static java.util.Optional<java.lang.String> validateSepaXML(java.lang.String xml) throws org.xml.sax.SAXException, java.io.IOExceptionChecks whether the givenStringcontains valid SEPA DD content.- Parameters:
xml- The XML content to check.- Returns:
- An
Optionalcontaining the error output if theXMLis erroneous. IfOptional.empty()is returned the XML does not contain errors but it may still contain warnings. If so these are logged. - Throws:
org.xml.sax.SAXException- If any parse error occurs.java.io.IOException- If any I/O error occurs.- See Also:
XMLUtility.isValidXML(java.lang.String, java.net.URL)
-