public class SwiftParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EOL
Helper constant with the content of
System.getProperty("line.separator", "\n") |
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 |
---|---|
protected SwiftBlock4 |
block4Consume(SwiftBlock4 b,
java.lang.String s)
Parses a block 4 from an input string.
|
protected SwiftBlock |
consumeBlock()
Deprecated.
use
consumeBlock(UnparsedTextList) instead of this, consumeBlock(null) is acceptable |
protected SwiftBlock |
consumeBlock(UnparsedTextList unparsedReceiver)
Consume the next block of the message on the reader.
|
protected Tag |
consumeTag(java.lang.String buffer,
java.lang.String unparsedText)
Process the input as a tag.
|
protected java.lang.String |
findBlockStart()
read on the reader until a block start character or EOF is reached.
|
SwiftParserConfiguration |
getConfiguration()
Gets the current parse configuration
|
java.util.List |
getErrors()
Get a copy of the errors found.
|
protected char |
identifyBlock(java.lang.String s)
Identify the block to be consumed.
|
boolean |
isLenient()
Deprecated.
use
SwiftParserConfiguration.isLenient() instead |
SwiftMessage |
message()
Parse a SWIFT message into a data structure
|
SwiftMessage |
parse(java.lang.String message)
Sets the parameter string as this parser data and returns the parsed object.
|
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
|
protected java.lang.String |
readUntilBlockEnds()
Reads the buffer until end of block is reached.
|
void |
setConfiguration(SwiftParserConfiguration configuration)
Sets a new parse configuration
|
void |
setData(java.lang.String data)
sets the input data to the received string.
|
void |
setLenient(boolean lenient)
Deprecated.
use
SwiftParserConfiguration.setLenient(boolean) instead |
void |
setReader(java.io.Reader r)
sets the input reader.
NOTE: this resets the internal buffer |
protected SwiftTagListBlock |
tagListBlockConsume(SwiftTagListBlock b,
java.lang.String s)
consumes a tag list block (i.e: block 3, block 5 or user defined block)
|
protected int |
textTagEndBlock4(java.lang.String s,
int start,
boolean isTextBlock)
finds the end of a text tag (i.e: ":TAG:VALUE").
|
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
java.io.IOException
public SwiftMessage parse(java.lang.String message) throws java.io.IOException
message
- the String with the swift message to parsejava.io.IOException
@Deprecated @ProwideDeprecated(phase3=_2018) protected SwiftBlock consumeBlock() throws java.io.IOException
consumeBlock(UnparsedTextList)
instead of this, consumeBlock(null)
is acceptablejava.io.IOException
protected SwiftBlock consumeBlock(UnparsedTextList unparsedReceiver) throws java.io.IOException
unparsedReceiver
- may be null
, the unparsedTextList that will receive the chunks that can not be identified sas part of the messagenull
if none was found (i.e: end of input)java.io.IOException
- if an error occurred during readprotected SwiftTagListBlock tagListBlockConsume(SwiftTagListBlock b, java.lang.String s) throws java.io.IOException
b
- the block to set up tags intos
- the block data to processjava.io.IOException
protected SwiftBlock4 block4Consume(SwiftBlock4 b, java.lang.String s) throws java.io.IOException
b
- the block to set up tags intos
- the block data to processjava.io.IOException
protected int textTagEndBlock4(java.lang.String s, int start, boolean isTextBlock)
s
- the FIN input textstart
- the position to start analysis atprotected Tag consumeTag(java.lang.String buffer, java.lang.String unparsedText) throws java.io.IOException
buffer
- the buffer containing the tagunparsedText
- the unparsed text to assign (use null
if none is wanted).
This single text is fragmented in multiple texts if there are more than one message.java.io.IOException
protected char identifyBlock(java.lang.String s)
s
- the block identifierprotected java.lang.String readUntilBlockEnds() throws java.io.IOException
This method assumes that the starting block character was consumed because that is required in order to identify the start of a block, and call this method which reads until this block ends.
java.io.IOException
protected java.lang.String findBlockStart() throws java.io.IOException
java.io.IOException
- if thrown during readpublic java.util.List getErrors()
@Deprecated @ProwideDeprecated(phase4=_2018) public boolean isLenient()
SwiftParserConfiguration.isLenient()
instead@Deprecated @ProwideDeprecated(phase4=_2018) public void setLenient(boolean lenient)
SwiftParserConfiguration.setLenient(boolean)
insteadpublic SwiftParserConfiguration getConfiguration()
SwiftParserConfiguration
public void setConfiguration(SwiftParserConfiguration configuration)
configuration
- new configurationSwiftParserConfiguration
public static SwiftBlock4 parseBlock4(java.lang.String s) throws java.io.IOException
s
- block content starting with "{4:\r\n" and ending with "\r\n-}"java.io.IOException
public static SwiftBlock3 parseBlock3(java.lang.String s) throws java.io.IOException
s
- block content starting with "{3:" and ending with "}"java.io.IOException
public static SwiftBlock5 parseBlock5(java.lang.String s) throws java.io.IOException
s
- block content starting with "{5:" and ending with "}"java.io.IOException
public static SwiftBlock1 parseBlock1(java.lang.String s) throws java.io.IOException
s
- block content starting with "{1:" and ending with "}"java.io.IOException
public static SwiftBlock2 parseBlock2(java.lang.String s) throws java.io.IOException
Will return either a SwiftBlock2Input
or SwiftBlock2Output
depending
on the parameter block content.
s
- block content starting with "{2:" and ending with "}"java.io.IOException
public static SwiftBlock2Input parseBlock2Input(java.lang.String s) throws java.io.IOException
If you don't know the container message direction, user parseBlock2(String)
instead
s
- block content starting with "{2:I" and ending with "}"java.io.IOException
public static SwiftBlock2Output parseBlock2Output(java.lang.String s) throws java.io.IOException
If you don't know the container message direction, user parseBlock2(String)
instead
s
- block content starting with "{2:O" and ending with "}"java.io.IOException