Package org.compiere.impexp
Class OFXBankStatementHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.compiere.impexp.OFXBankStatementHandler
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
- Direct Known Subclasses:
OFXFileBankStatementLoader
Parser for OFX bank statements.
This class is a parser for OFX bankstatements. OFX versions from 102 to 202
and MS-Money OFC message sets are supported.
Only fully XML compliant OFX data is supported. Files that are not XML
compliant, e.g. OFX versions older then 200, will be preprocessed by
the OFX1ToXML class before parsing.
This class should be extended by a class that obtains the data to be parsed
for example from a file, or using HTTP.
- Version:
- $Id: OFXBankStatementHandler.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
- Author:
- Eldir Tomassen
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final TimeZone
protected int
protected String
protected MBankStatementLoader
protected String
protected Timestamp
protected StringBuffer
protected StringBuffer
protected OFXBankStatementHandler.StatementLine
protected SAXParser
protected BufferedReader
protected String
protected Timestamp
protected boolean
protected boolean
protected StringBuffer
static final int
static final String
XML ACCTID Tagstatic final String
Checksumstatic final String
Type of accountstatic final String
Type of accountstatic final String
XML AVAILBAL Tagstatic final String
XML BALAMT Tagstatic final String
Account-from aggregatestatic final String
Bank identifierstatic final String
XML BANKTRANLIST Tagstatic final String
Branch identifierstatic final String
XML CHECKNUM Tagstatic final String
XML CHKNUM Tag (MS-Money OFC)static final String
XML CURDEF Tagstatic final String
XML DTASOF Tagstatic final String
Effective datestatic final String
XML DTEND Tagstatic final String
Transaction datestatic final String
Date and rime last update to profile informationstatic final String
Date and time of the server responsestatic final String
XML DTSTART Tagstatic final String
XML FITID Tagstatic final String
Languagestatic final String
XML LEDGERBAL Tagstatic final String
Transaction Memostatic final String
XML MKTGINFO Tagstatic final String
XML NAME Tagstatic final String
XML OFX Tagstatic final String
TXML PAYEE Tagstatic final String
XML PAYEEID Tagstatic final String
XML REFNUM Tagstatic final String
XML SIGNONMSGSRSV1 Tagstatic final String
XML SIGNONMSGSRSV2 Tagstatic final String
Record-response aggregatestatic final String
Status aggregatestatic final String
Statement-response aggregatestatic final String
XML STMTTRN Tagstatic final String
XML TRNAMT Tagstatic final String
XML TRNTYPE Tagstatic final String
Date and time that USERKEY expiresstatic final String
Use USERKEY instead of USERID and USEPASS -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Attach OFX input source, detect whether we are dealing with OFX1 (SGML) or OFX2 (XML).void
characters
(char[] ch, int start, int length) Characters read from XML are assigned to a variable, based on the current m_context.void
endElement
(String uri, String localName, String qName) Check for valid XML structure.getIBAN()
boolean
getMemo()
getTrxID()
boolean
Check whether the import was successfulprotected boolean
init
(MBankStatementLoader controller) Initialize the loaderboolean
isValid()
Verify the validity of the OFX databoolean
Read statementlines from InputStream.
This method will be invoked from ImportController.protected Date
Parses a date according to OFX.protected TimeZone
parseTimeZone
(String tzoffset) source: https://github.com/stoicflame/ofx4j/blob/a604e4f6ffefea61403434cf853bbd1b20740386/src/main/java/com/webcohesion/ofx4j/io/DefaultStringConversion.javavoid
startElement
(String uri, String localName, String qName, Attributes attributes) New XML element detected.Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
m_controller
-
m_errorMessage
-
m_errorDescription
-
m_reader
-
m_parser
-
m_success
protected boolean m_success -
m_line
-
m_routingNo
-
m_bankAccountNo
-
m_currency
-
HEADER_SIZE
protected int HEADER_SIZE -
m_test
protected boolean m_test -
m_dateLastRun
-
m_statementDate
-
m_valueBuffer
-
XML_OFX_TAG
XML OFX Tag- See Also:
-
XML_SIGNONMSGSRSV2_TAG
XML SIGNONMSGSRSV2 Tag- See Also:
-
XML_SIGNONMSGSRSV1_TAG
XML SIGNONMSGSRSV1 Tag- See Also:
-
XML_SONRS_TAG
Record-response aggregate- See Also:
-
XML_DTSERVER_TAG
Date and time of the server response- See Also:
-
XML_USERKEY_TAG
Use USERKEY instead of USERID and USEPASS- See Also:
-
XML_TSKEYEXPIRE_TAG
Date and time that USERKEY expires- See Also:
-
XML_LANGUAGE_TAG
Language- See Also:
-
XML_DTPROFUP_TAG
Date and rime last update to profile information- See Also:
-
XML_STATUS_TAG
Status aggregate- See Also:
-
XML_STMTRS_TAG
Statement-response aggregate- See Also:
-
XML_CURDEF_TAG
XML CURDEF Tag- See Also:
-
XML_BANKACCTFROM_TAG
Account-from aggregate- See Also:
-
XML_BANKID_TAG
Bank identifier- See Also:
-
XML_BRANCHID_TAG
Branch identifier- See Also:
-
XML_ACCTID_TAG
XML ACCTID Tag- See Also:
-
XML_ACCTTYPE_TAG
Type of account- See Also:
-
XML_ACCTTYPE2_TAG
Type of account- See Also:
-
XML_ACCTKEY_TAG
Checksum- See Also:
-
XML_BANKTRANLIST_TAG
XML BANKTRANLIST Tag- See Also:
-
XML_DTSTART_TAG
XML DTSTART Tag- See Also:
-
XML_DTEND_TAG
XML DTEND Tag- See Also:
-
XML_STMTTRN_TAG
XML STMTTRN Tag- See Also:
-
XML_TRNTYPE_TAG
XML TRNTYPE Tag- See Also:
-
XML_TRNAMT_TAG
XML TRNAMT Tag- See Also:
-
XML_DTPOSTED_TAG
Transaction date- See Also:
-
XML_DTAVAIL_TAG
Effective date- See Also:
-
XML_FITID_TAG
XML FITID Tag- See Also:
-
XML_CHECKNUM_TAG
XML CHECKNUM Tag- See Also:
-
XML_CHKNUM_TAG
XML CHKNUM Tag (MS-Money OFC)- See Also:
-
XML_REFNUM_TAG
XML REFNUM Tag- See Also:
-
XML_MEMO_TAG
Transaction Memo- See Also:
-
XML_NAME_TAG
XML NAME Tag- See Also:
-
XML_PAYEEID_TAG
XML PAYEEID Tag- See Also:
-
XML_PAYEE_TAG
TXML PAYEE Tag- See Also:
-
XML_LEDGERBAL_TAG
XML LEDGERBAL Tag- See Also:
-
XML_BALAMT_TAG
XML BALAMT Tag- See Also:
-
XML_DTASOF_TAG
XML DTASOF Tag- See Also:
-
XML_AVAILBAL_TAG
XML AVAILBAL Tag- See Also:
-
XML_MKTGINFO_TAG
XML MKTGINFO Tag- See Also:
-
GMT_TIME_ZONE
-
DATE_FORMAT_LENGTH
public static final int DATE_FORMAT_LENGTH -
TIME_FORMAT_LENGTH
public static final int TIME_FORMAT_LENGTH
-
-
Constructor Details
-
OFXBankStatementHandler
public OFXBankStatementHandler()
-
-
Method Details
-
init
Initialize the loader- Parameters:
controller
- Reference to the BankStatementLoaderController- Returns:
- Initialized successfully
-
attachInput
Attach OFX input source, detect whether we are dealing with OFX1 (SGML) or OFX2 (XML). In case of OFX1, process the data to create valid XML.- Parameters:
is
- Reference to the BankStatementLoaderController- Returns:
- true if input is valid OFX data
-
isValid
public boolean isValid()Verify the validity of the OFX data- Returns:
- true if input is valid OFX data
-
importSuccessfull
public boolean importSuccessfull()Check whether the import was successful- Returns:
- true if all statement lines have been imported successfully
-
loadLines
public boolean loadLines()Read statementlines from InputStream.
This method will be invoked from ImportController.- Returns:
- load success
-
getDateLastRun
- Returns:
- last run date
-
getRoutingNo
- Returns:
- routing number
-
getBankAccountNo
- Returns:
- line bank account number
-
getIBAN
- Returns:
- IBAN
-
getStatementReference
- Returns:
- line statement reference
-
getStatementDate
- Returns:
- statement date
-
getReference
- Returns:
- line reference
-
getStatementLineDate
- Returns:
- line statement date
-
getValutaDate
- Returns:
- line valuta date
-
getTrxType
- Returns:
- line trx type
-
getIsReversal
public boolean getIsReversal()- Returns:
- true if line is reversal
-
getCurrency
- Returns:
- line currency
-
getStmtAmt
- Returns:
- line statement amount
-
getTrxAmt
- Returns:
- Line Transaction Amount
-
getInterestAmt
- Returns:
- Interest Amount
-
getMemo
- Returns:
- line memo
-
getChargeName
- Returns:
- line charge name
-
getChargeAmt
- Returns:
- line charge amount
-
getTrxID
- Returns:
- line transaction id
-
getPayeeAccountNo
- Returns:
- line payee account number
-
getPayeeName
- Returns:
- line payee name
-
getCheckNo
- Returns:
- line check number
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException New XML element detected. The XML nesting structure is saved on the m_context stack.- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Parameters:
uri
- StringlocalName
- StringqName
- Stringattributes
- Attributes- Throws:
SAXException
- See Also:
-
characters
Characters read from XML are assigned to a variable, based on the current m_context. No checks are being done, it is assumed that the context is correct.- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Parameters:
ch
- char[]start
- intlength
- int- Throws:
SAXException
- See Also:
-
endElement
Check for valid XML structure. (all tags are properly ended). The statements are passed to ImportController when the statement end (</STMTTRN>) is detected.- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Parameters:
uri
- StringlocalName
- StringqName
- String- Throws:
SAXException
- See Also:
-
parseTimeZone
source: https://github.com/stoicflame/ofx4j/blob/a604e4f6ffefea61403434cf853bbd1b20740386/src/main/java/com/webcohesion/ofx4j/io/DefaultStringConversion.javaParse the timezone offset of the form [HOURS_OFF_GMT:TZ_ID]
- Parameters:
tzoffset
- The offset pattern.- Returns:
- The timezone.
-
parseDate
Parses a date according to OFX.- Parameters:
value
- The value of the date.- Returns:
- The date value.
-
getLastErrorMessage
- Returns:
- last error message
-
getLastErrorDescription
- Returns:
- last error description
-