Package fr.marcwrobel.jbanking.swift
Class SwiftPattern
- java.lang.Object
-
- fr.marcwrobel.jbanking.swift.SwiftPattern
-
- All Implemented Interfaces:
Serializable
public final class SwiftPattern extends Object implements Serializable
A partial compiled representation of a SWIFT expression (a kind of regular expression) as used in many SWIFT documents (for instance the IBAN registry document).This class internally uses a
Patternby transforming the SWIFT expression to a traditional regular expression. As a result the SwiftPattern API is similar to thePattern API.The SwiftPattern class partially supports the SWIFT expression by using the following constructions :
Character representations n digits (numeric characters 0 to 9 only) a upper case letters (alphabetic characters A-Z only) c upper and lower case alphanumeric characters (A-Z, a-z and 0-9) e blank space Length indications nn! fixed length nn maximum length Here are some examples of SWIFT expressions that are supported by this SwiftPattern :
4!n(corresponding regex [0-9]{4}) : four consecutive digits4!a3c(corresponding regex [A-Za-z0-9]{4}[A-Z]{1,3}) : four consecutive upper or lower case alphanumeric characters followed by one to three upper case letters2e4!a(corresponding regex [ ]{1,2}) : one or two consecutive spaces followed by four consecutive upper case letters
4!n) is 1000. these limitations are far above anything that can be seen in SWIFT documents and should be sufficient.Instances of this class are immutable and are safe for use by multiple concurrent threads.
- Since:
- 1.0
- Author:
- Marc Wrobel
- See Also:
Pattern, Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SwiftPatterncompile(String expression)Compiles the given SWIFT expression into a SwiftPattern.booleanequals(Object o)PatterngetEquivalentJavaPattern()Returns thejava Patternbuild using the SWIFT expression.StringgetExpression()Returns the SWIFT expression from which this pattern was compiled.inthashCode()Matchermatcher(CharSequence input)Creates a matcher that will match the given input against this pattern.StringtoString()
-
-
-
Method Detail
-
compile
public static SwiftPattern compile(String expression)
Compiles the given SWIFT expression into a SwiftPattern.- Parameters:
expression- The expression to be compiled- Returns:
- a SwiftPattern representing the given expression
- Throws:
SwiftPatternSyntaxException- If the expression's syntax is invalid.
-
matcher
public Matcher matcher(CharSequence input)
Creates a matcher that will match the given input against this pattern.- Parameters:
input- The character sequence to be matched- Returns:
- A new matcher for this pattern.
-
getExpression
public String getExpression()
Returns the SWIFT expression from which this pattern was compiled.- Returns:
- a non-null string.
-
getEquivalentJavaPattern
public Pattern getEquivalentJavaPattern()
Returns thejava Patternbuild using the SWIFT expression.- Returns:
- a non-null pattern.
-
-