public class SwiftParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EOL
Deprecated.
|
Constructor and Description |
---|
SwiftParser()
default constructor.
NOTE: If this constructor is called, setReader must be called to use the parser |
SwiftParser(java.io.File messageFile)
Create a parser and feed it with the contents of the given file
|
SwiftParser(java.io.InputStream is)
Constructor with an input stream for parsing a message
|
SwiftParser(java.io.Reader r)
Constructor with a reader for parsing a message
|
SwiftParser(java.lang.String message)
Constructor with a String for parsing a message
|
Modifier and Type | Method and Description |
---|---|
SwiftParserConfiguration |
getConfiguration()
Gets the current parse configuration
|
java.util.List<java.lang.String> |
getErrors()
Get a copy of the errors found during the parsing of the message.
|
SwiftMessage |
message()
Parse a SWIFT message into a data structure.
|
SwiftMessage |
parse(java.lang.String message)
Deprecated.
use
SwiftMessage.parse(String) instead |
static SwiftBlock1 |
parseBlock1(java.lang.String s)
Parses a string containing an MT message block 1 content
|
static SwiftBlock2 |
parseBlock2(java.lang.String s)
Parses a string containing an MT message block 2 content.
|
static SwiftBlock2Input |
parseBlock2Input(java.lang.String s)
Parses a string containing an MT message block 2 input content (outgoing message sent to SWIFT).
|
static SwiftBlock2Output |
parseBlock2Output(java.lang.String s)
Parses a string containing an MT message block 2 output content (incoming message received from SWIFT).
|
static SwiftBlock3 |
parseBlock3(java.lang.String s)
Parses a string containing an MT message block 3 content
|
static SwiftBlock4 |
parseBlock4(java.lang.String s)
Parses a string containing the text block of an MT message
|
static SwiftBlock5 |
parseBlock5(java.lang.String s)
Parses a string containing an MT message block 5 content
|
void |
setConfiguration(SwiftParserConfiguration configuration)
Sets a new parse configuration
|
void |
setData(java.lang.String data)
sets the input data to the received string.
|
void |
setReader(java.io.Reader r)
sets the input reader.
NOTE: this resets the internal buffer |
@Deprecated @ProwideDeprecated(phase2=SRU2020) public static final java.lang.String EOL
System.getProperty("line.separator", "\n")
public SwiftParser(java.io.InputStream is)
is
- stream to readpublic SwiftParser(java.io.Reader r)
r
- the Reader with the swift message to readpublic SwiftParser(java.lang.String message)
message
- the String with the swift message to readpublic SwiftParser()
public SwiftParser(java.io.File messageFile) throws java.io.IOException
messageFile
- existing, readable file to readjava.io.IOException
- if an error occurs during readpublic void setReader(java.io.Reader r)
r
- the reader to usepublic void setData(java.lang.String data)
data
- the data to use as inputpublic SwiftMessage message() throws java.io.IOException
By default this implementation uses the default parser behaviour which is lenient and will do a best effort to read as much from the message content as possible regardless of the content and block boundaries being valid or not. For instance, it will read the headers even if the value length is incorrect, and it will read the text block (block 4) even if it is missing the closing hyphen and bracket.
For more options check setConfiguration(SwiftParserConfiguration)
IMPORTANT: Since the parser is initialize with a Reader, this method is not reentrant. Once a message was parsed, the next call to this method will produce a message with null blocks.
java.io.IOException
- if an error occurs during read@Deprecated @ProwideDeprecated(phase3=SRU2020) public SwiftMessage parse(java.lang.String message) throws java.io.IOException
SwiftMessage.parse(String)
insteadjava.io.IOException
public java.util.List<java.lang.String> getErrors()
You can manipulate this copy without affecting the original list.
public SwiftParserConfiguration getConfiguration()
SwiftParserConfiguration
public void setConfiguration(SwiftParserConfiguration configuration)
configuration
- new configurationSwiftParserConfiguration
public static SwiftBlock4 parseBlock4(java.lang.String s)
s
- block content starting with "{4:\r\n" and ending with "\r\n-}"public static SwiftBlock3 parseBlock3(java.lang.String s)
s
- block content starting with "{3:" and ending with "}"public static SwiftBlock5 parseBlock5(java.lang.String s)
s
- block content starting with "{5:" and ending with "}"public static SwiftBlock1 parseBlock1(java.lang.String s)
s
- block content starting with "{1:" and ending with "}"public static SwiftBlock2 parseBlock2(java.lang.String s)
Will return either a SwiftBlock2Input
or SwiftBlock2Output
depending
on the parameter block content.
s
- block content starting with "{2:" and ending with "}"public static SwiftBlock2Input parseBlock2Input(java.lang.String s)
If you don't know the container message direction, user parseBlock2(String)
instead.
s
- block content starting with "{2:I" and ending with "}"public static SwiftBlock2Output parseBlock2Output(java.lang.String s)
If you don't know the container message direction, user parseBlock2(String)
instead.
s
- block content starting with "{2:O" and ending with "}"