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.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 reader 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()
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 void |
findBlockStart()
read on the reader until a block start character or EOF is reached.
|
java.util.List |
getErrors()
Get a copy of the errors found.
|
protected char |
identifyBlock(java.lang.String s)
Identify the block to be consumed.
|
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.
|
protected java.lang.String |
readUntilBlockEnds()
Reads the buffer until end of block is reached.
|
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 |
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 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
protected SwiftBlock consumeBlock() throws java.io.IOException
blockHint
- null
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 void findBlockStart() throws java.io.IOException
java.io.IOException
- if thrown during readpublic java.util.List getErrors()