Package org.notima.util
Class TaxIdFormatter
java.lang.Object
org.notima.util.TaxIdFormatter
Utility class to parse and print tax id:s in different formats.
At the moment only Swedish tax id's are supported.
- Author:
- Daniel Tamm
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdetermineFormat(String countryCode, String taxId) Determines tax id format by applying a number of regular expressions to the tax id.static booleanhasDigitsOnly(String ref) static StringprintTaxId(String srcFormat, String taxId, String dstFormat) Print tax id in given format.static StringremoveBlanks(String cleanUp) Remove blanks from a string.static StringtoDigitsOnly(String cleanUp) Remove all non digit characters
-
Constructor Details
-
TaxIdFormatter
public TaxIdFormatter()
-
-
Method Details
-
toDigitsOnly
Remove all non digit characters- Parameters:
cleanUp- String to be cleaned.- Returns:
- A cleaned string.
-
hasDigitsOnly
-
removeBlanks
Remove blanks from a string.- Parameters:
cleanUp- String to clean up.- Returns:
- A string without blanks.
-
printTaxId
public static String printTaxId(String srcFormat, String taxId, String dstFormat) throws UnknownTaxIdFormatException, InvalidTaxIdFormatException Print tax id in given format.- Parameters:
srcFormat- The format of the taxId-attribute. If null, the tax id format tries to be determined. Note, this can be lengthy.taxId- The actual tax id.dstFormat- The destination format.- Returns:
- The tax id in the destination format
- Throws:
UnknownTaxIdFormatException- if the dstFormat is not recognized.InvalidTaxIdFormatException- If the tax ID can't be parsed.
-
determineFormat
Determines tax id format by applying a number of regular expressions to the tax id.- Parameters:
countryCode- If country code is supplied, only that country's tax id patterns are tried.taxId- The tax id to determine.- Returns:
- The tax id format. If it can't be matched, TaxIdStructure.FMT_UNKNOWN is returned.
-