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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final TimeZoneprotected intprotected Stringprotected MBankStatementLoaderprotected Stringprotected Timestampprotected StringBufferprotected StringBufferprotected OFXBankStatementHandler.StatementLineprotected SAXParserprotected BufferedReaderprotected Stringprotected Timestampprotected booleanprotected booleanprotected StringBufferstatic final intstatic final StringXML ACCTID Tagstatic final StringChecksumstatic final StringType of accountstatic final StringType of accountstatic final StringXML AVAILBAL Tagstatic final StringXML BALAMT Tagstatic final StringAccount-from aggregatestatic final StringBank identifierstatic final StringXML BANKTRANLIST Tagstatic final StringBranch identifierstatic final StringXML CHECKNUM Tagstatic final StringXML CHKNUM Tag (MS-Money OFC)static final StringXML CURDEF Tagstatic final StringXML DTASOF Tagstatic final StringEffective datestatic final StringXML DTEND Tagstatic final StringTransaction datestatic final StringDate and rime last update to profile informationstatic final StringDate and time of the server responsestatic final StringXML DTSTART Tagstatic final StringXML FITID Tagstatic final StringLanguagestatic final StringXML LEDGERBAL Tagstatic final StringTransaction Memostatic final StringXML MKTGINFO Tagstatic final StringXML NAME Tagstatic final StringXML OFX Tagstatic final StringTXML PAYEE Tagstatic final StringXML PAYEEID Tagstatic final StringXML REFNUM Tagstatic final StringXML SIGNONMSGSRSV1 Tagstatic final StringXML SIGNONMSGSRSV2 Tagstatic final StringRecord-response aggregatestatic final StringStatus aggregatestatic final StringStatement-response aggregatestatic final StringXML STMTTRN Tagstatic final StringXML TRNAMT Tagstatic final StringXML TRNTYPE Tagstatic final StringDate and time that USERKEY expiresstatic final StringUse USERKEY instead of USERID and USEPASS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanAttach OFX input source, detect whether we are dealing with OFX1 (SGML) or OFX2 (XML).voidcharacters(char[] ch, int start, int length) Characters read from XML are assigned to a variable, based on the current m_context.voidendElement(String uri, String localName, String qName) Check for valid XML structure.getIBAN()booleangetMemo()getTrxID()booleanCheck whether the import was successfulprotected booleaninit(MBankStatementLoader controller) Initialize the loaderbooleanisValid()Verify the validity of the OFX databooleanRead statementlines from InputStream.
This method will be invoked from ImportController.protected DateParses a date according to OFX.protected TimeZoneparseTimeZone(String tzoffset) source: https://github.com/stoicflame/ofx4j/blob/a604e4f6ffefea61403434cf853bbd1b20740386/src/main/java/com/webcohesion/ofx4j/io/DefaultStringConversion.javavoidstartElement(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, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
startElementin interfaceContentHandler- Overrides:
startElementin 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:
charactersin interfaceContentHandler- Overrides:
charactersin 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:
endElementin interfaceContentHandler- Overrides:
endElementin 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
-