public class SwiftParser extends Object
Modifier and Type | Field and Description |
---|---|
static 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(InputStream is)
Constructor with an input stream for parsing a message
|
SwiftParser(Reader r)
Constructor with a reader for parsing a message
|
SwiftParser(String message)
Constructor with a String for parsing a message
|
Modifier and Type | Method and Description |
---|---|
protected SwiftBlock4 |
block4Consume(SwiftBlock4 b,
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(String buffer,
String unparsedText)
Process the input as a tag.
|
protected void |
findBlockStart()
read on the reader until a block start character or EOF is reached.
|
List |
getErrors()
Get a copy of the errors found.
|
protected char |
identifyBlock(String s)
Identify the block to be consumed.
|
SwiftMessage |
message()
Parse a SWIFT message into a data structure
|
SwiftMessage |
parse(String message)
Sets the parameter string as this parser data and returns the parsed object.
|
protected String |
readUntilBlockEnds()
Reads the buffer until end of block is reached.
|
void |
setData(String data)
sets the input data to the received string.
|
void |
setReader(Reader r)
sets the input reader.
NOTE: this resets the internal buffer |
protected SwiftTagListBlock |
tagListBlockConsume(SwiftTagListBlock b,
String s)
consumes a tag list block (i.e: block 3, block 5 or user defined block)
|
protected int |
textTagEndBlock4(String s,
int start,
boolean isTextBlock)
finds the end of a text tag (i.e: ":TAG:VALUE").
|
public static final String EOL
System.getProperty("line.separator", "\n")
public SwiftParser()
public SwiftParser(InputStream is)
is
- stream to readpublic SwiftParser(Reader r)
r
- the Reader with the swift message to readpublic SwiftParser(String message)
message
- the String with the swift message to readprotected SwiftBlock4 block4Consume(SwiftBlock4 b, String s) throws IOException
b
- the block to set up tags intos
- the block data to processIOException
protected SwiftBlock consumeBlock() throws IOException
blockHint
- null
if none was found (i.e: end of input)IOException
- if an error occurred during readprotected Tag consumeTag(String buffer, String unparsedText) throws 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.IOException
protected void findBlockStart() throws IOException
IOException
- if thrown during readpublic List getErrors()
protected char identifyBlock(String s)
s
- the block identifierpublic SwiftMessage message() throws IOException
IOException
public SwiftMessage parse(String message) throws IOException
message
- the String with the swift message to parseIOException
protected String readUntilBlockEnds() throws 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.
IOException
public void setData(String data)
data
- the data to use as inputpublic void setReader(Reader r)
r
- the reader to useprotected SwiftTagListBlock tagListBlockConsume(SwiftTagListBlock b, String s) throws IOException
b
- the block to set up tags intos
- the block data to processIOException
protected int textTagEndBlock4(String s, int start, boolean isTextBlock)
s
- the FIN input textstart
- the position to start analysis at