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
public abstract class OFXBankStatementHandler extends DefaultHandler
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
-
-
Field Summary
Fields Modifier and Type Field Description static int
DATE_FORMAT_LENGTH
static TimeZone
GMT_TIME_ZONE
protected int
HEADER_SIZE
protected String
m_bankAccountNo
protected MBankStatementLoader
m_controller
protected String
m_currency
protected Timestamp
m_dateLastRun
protected StringBuffer
m_errorDescription
protected StringBuffer
m_errorMessage
protected org.compiere.impexp.OFXBankStatementHandler.StatementLine
m_line
protected SAXParser
m_parser
protected BufferedReader
m_reader
protected String
m_routingNo
protected Timestamp
m_statementDate
protected boolean
m_success
protected boolean
m_test
static int
TIME_FORMAT_LENGTH
static String
XML_ACCTID_TAG
XML ACCTID Tagstatic String
XML_ACCTKEY_TAG
Checksumstatic String
XML_ACCTTYPE_TAG
Type of accountstatic String
XML_ACCTTYPE2_TAG
Type of accountstatic String
XML_AVAILBAL_TAG
XML AVAILBAL Tagstatic String
XML_BALAMT_TAG
XML BALAMT Tagstatic String
XML_BANKACCTFROM_TAG
Account-from aggregatestatic String
XML_BANKID_TAG
Bank identifierstatic String
XML_BANKTRANLIST_TAG
XML BANKTRANLIST Tagstatic String
XML_BRANCHID_TAG
Branch identifierstatic String
XML_CHECKNUM_TAG
XML CHECKNUM Tagstatic String
XML_CHKNUM_TAG
XML CHKNUM Tag (MS-Money OFC)static String
XML_CURDEF_TAG
XML CURDEF Tagstatic String
XML_DTASOF_TAG
XML DTASOF Tagstatic String
XML_DTAVAIL_TAG
Effective datestatic String
XML_DTEND_TAG
XML DTEND Tagstatic String
XML_DTPOSTED_TAG
Transaction datestatic String
XML_DTPROFUP_TAG
Date and rime last update to profile informationstatic String
XML_DTSERVER_TAG
Date and time of the server responsestatic String
XML_DTSTART_TAG
XML DTSTART Tagstatic String
XML_FITID_TAG
XML FITID Tagstatic String
XML_LANGUAGE_TAG
Languagestatic String
XML_LEDGERBAL_TAG
XML LEDGERBAL Tagstatic String
XML_MEMO_TAG
Transaction Memostatic String
XML_MKTGINFO_TAG
XML MKTGINFO Tagstatic String
XML_NAME_TAG
XML NAME Tagstatic String
XML_OFX_TAG
XML OFX Tagstatic String
XML_PAYEE_TAG
TXML PAYEE Tagstatic String
XML_PAYEEID_TAG
XML PAYEEID Tagstatic String
XML_REFNUM_TAG
XML REFNUM Tagstatic String
XML_SIGNONMSGSRSV1_TAG
XML SIGNONMSGSRSV1 Tagstatic String
XML_SIGNONMSGSRSV2_TAG
XML SIGNONMSGSRSV2 Tagstatic String
XML_SONRS_TAG
Record-response aggregatestatic String
XML_STATUS_TAG
Status aggregatestatic String
XML_STMTRS_TAG
Statement-response aggregatestatic String
XML_STMTTRN_TAG
XML STMTTRN Tagstatic String
XML_TRNAMT_TAG
XML TRNAMT Tagstatic String
XML_TRNTYPE_TAG
XML TRNTYPE Tagstatic String
XML_TSKEYEXPIRE_TAG
Date and time that USERKEY expiresstatic String
XML_USERKEY_TAG
Use USERKEY instead of USERID and USEPASS
-
Constructor Summary
Constructors Constructor Description OFXBankStatementHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
attachInput(InputStream is)
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.String
getBankAccountNo()
Method getBankAccountNoBigDecimal
getChargeAmt()
Method getChargeAmtString
getChargeName()
Method getChargeNameString
getCheckNo()
Method getCheckNoString
getCurrency()
Method getCurrencyTimestamp
getDateLastRun()
Method getDateLastRunString
getIBAN()
Method getIBANBigDecimal
getInterestAmt()
Method getInterestAmountboolean
getIsReversal()
Method getIsReversalString
getLastErrorDescription()
Method getLastErrorDescriptionString
getLastErrorMessage()
Method getLastErrorMessageString
getMemo()
Method getMemoString
getPayeeAccountNo()
Method getPayeeAccountNoString
getPayeeName()
Method getPayeeNameString
getReference()
Method getReferenceString
getRoutingNo()
Method getRoutingNoTimestamp
getStatementDate()
Method getStatementDateTimestamp
getStatementLineDate()
Method getStatementLineDateString
getStatementReference()
Method getStatementReferenceBigDecimal
getStmtAmt()
Method getStmtAmtBigDecimal
getTrxAmt()
Method getTrxAmtString
getTrxID()
Method getTrxIDString
getTrxType()
Method getTrxTypeTimestamp
getValutaDate()
Method getValutaDateboolean
importSuccessfull()
Check wether the import was succesfullprotected boolean
init(MBankStatementLoader controller)
Initialize the loader * @param controller Reference to the BankStatementLoaderControllerboolean
isValid()
Verify the validity of the OFX databoolean
loadLines()
Read statementlines from InputStream.protected Date
parseDate(String value)
Parses a date according to OFX.protected TimeZone
parseTimeZone(String tzoffset)
Parse the timezone offset of the form [HOURS_OFF_GMT:TZ_ID]void
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
-
-
-
-
Field Detail
-
m_controller
protected MBankStatementLoader m_controller
-
m_errorMessage
protected StringBuffer m_errorMessage
-
m_errorDescription
protected StringBuffer m_errorDescription
-
m_reader
protected BufferedReader m_reader
-
m_parser
protected SAXParser m_parser
-
m_success
protected boolean m_success
-
m_line
protected org.compiere.impexp.OFXBankStatementHandler.StatementLine m_line
-
m_routingNo
protected String m_routingNo
-
m_bankAccountNo
protected String m_bankAccountNo
-
m_currency
protected String m_currency
-
HEADER_SIZE
protected int HEADER_SIZE
-
m_test
protected boolean m_test
-
m_dateLastRun
protected Timestamp m_dateLastRun
-
m_statementDate
protected Timestamp m_statementDate
-
XML_OFX_TAG
public static final String XML_OFX_TAG
XML OFX Tag- See Also:
- Constant Field Values
-
XML_SIGNONMSGSRSV2_TAG
public static final String XML_SIGNONMSGSRSV2_TAG
XML SIGNONMSGSRSV2 Tag- See Also:
- Constant Field Values
-
XML_SIGNONMSGSRSV1_TAG
public static final String XML_SIGNONMSGSRSV1_TAG
XML SIGNONMSGSRSV1 Tag- See Also:
- Constant Field Values
-
XML_SONRS_TAG
public static final String XML_SONRS_TAG
Record-response aggregate- See Also:
- Constant Field Values
-
XML_DTSERVER_TAG
public static final String XML_DTSERVER_TAG
Date and time of the server response- See Also:
- Constant Field Values
-
XML_USERKEY_TAG
public static final String XML_USERKEY_TAG
Use USERKEY instead of USERID and USEPASS- See Also:
- Constant Field Values
-
XML_TSKEYEXPIRE_TAG
public static final String XML_TSKEYEXPIRE_TAG
Date and time that USERKEY expires- See Also:
- Constant Field Values
-
XML_LANGUAGE_TAG
public static final String XML_LANGUAGE_TAG
Language- See Also:
- Constant Field Values
-
XML_DTPROFUP_TAG
public static final String XML_DTPROFUP_TAG
Date and rime last update to profile information- See Also:
- Constant Field Values
-
XML_STATUS_TAG
public static final String XML_STATUS_TAG
Status aggregate- See Also:
- Constant Field Values
-
XML_STMTRS_TAG
public static final String XML_STMTRS_TAG
Statement-response aggregate- See Also:
- Constant Field Values
-
XML_CURDEF_TAG
public static final String XML_CURDEF_TAG
XML CURDEF Tag- See Also:
- Constant Field Values
-
XML_BANKACCTFROM_TAG
public static final String XML_BANKACCTFROM_TAG
Account-from aggregate- See Also:
- Constant Field Values
-
XML_BANKID_TAG
public static final String XML_BANKID_TAG
Bank identifier- See Also:
- Constant Field Values
-
XML_BRANCHID_TAG
public static final String XML_BRANCHID_TAG
Branch identifier- See Also:
- Constant Field Values
-
XML_ACCTID_TAG
public static final String XML_ACCTID_TAG
XML ACCTID Tag- See Also:
- Constant Field Values
-
XML_ACCTTYPE_TAG
public static final String XML_ACCTTYPE_TAG
Type of account- See Also:
- Constant Field Values
-
XML_ACCTTYPE2_TAG
public static final String XML_ACCTTYPE2_TAG
Type of account- See Also:
- Constant Field Values
-
XML_ACCTKEY_TAG
public static final String XML_ACCTKEY_TAG
Checksum- See Also:
- Constant Field Values
-
XML_BANKTRANLIST_TAG
public static final String XML_BANKTRANLIST_TAG
XML BANKTRANLIST Tag- See Also:
- Constant Field Values
-
XML_DTSTART_TAG
public static final String XML_DTSTART_TAG
XML DTSTART Tag- See Also:
- Constant Field Values
-
XML_DTEND_TAG
public static final String XML_DTEND_TAG
XML DTEND Tag- See Also:
- Constant Field Values
-
XML_STMTTRN_TAG
public static final String XML_STMTTRN_TAG
XML STMTTRN Tag- See Also:
- Constant Field Values
-
XML_TRNTYPE_TAG
public static final String XML_TRNTYPE_TAG
XML TRNTYPE Tag- See Also:
- Constant Field Values
-
XML_TRNAMT_TAG
public static final String XML_TRNAMT_TAG
XML TRNAMT Tag- See Also:
- Constant Field Values
-
XML_DTPOSTED_TAG
public static final String XML_DTPOSTED_TAG
Transaction date- See Also:
- Constant Field Values
-
XML_DTAVAIL_TAG
public static final String XML_DTAVAIL_TAG
Effective date- See Also:
- Constant Field Values
-
XML_FITID_TAG
public static final String XML_FITID_TAG
XML FITID Tag- See Also:
- Constant Field Values
-
XML_CHECKNUM_TAG
public static final String XML_CHECKNUM_TAG
XML CHECKNUM Tag- See Also:
- Constant Field Values
-
XML_CHKNUM_TAG
public static final String XML_CHKNUM_TAG
XML CHKNUM Tag (MS-Money OFC)- See Also:
- Constant Field Values
-
XML_REFNUM_TAG
public static final String XML_REFNUM_TAG
XML REFNUM Tag- See Also:
- Constant Field Values
-
XML_MEMO_TAG
public static final String XML_MEMO_TAG
Transaction Memo- See Also:
- Constant Field Values
-
XML_NAME_TAG
public static final String XML_NAME_TAG
XML NAME Tag- See Also:
- Constant Field Values
-
XML_PAYEEID_TAG
public static final String XML_PAYEEID_TAG
XML PAYEEID Tag- See Also:
- Constant Field Values
-
XML_PAYEE_TAG
public static final String XML_PAYEE_TAG
TXML PAYEE Tag- See Also:
- Constant Field Values
-
XML_LEDGERBAL_TAG
public static final String XML_LEDGERBAL_TAG
XML LEDGERBAL Tag- See Also:
- Constant Field Values
-
XML_BALAMT_TAG
public static final String XML_BALAMT_TAG
XML BALAMT Tag- See Also:
- Constant Field Values
-
XML_DTASOF_TAG
public static final String XML_DTASOF_TAG
XML DTASOF Tag- See Also:
- Constant Field Values
-
XML_AVAILBAL_TAG
public static final String XML_AVAILBAL_TAG
XML AVAILBAL Tag- See Also:
- Constant Field Values
-
XML_MKTGINFO_TAG
public static final String XML_MKTGINFO_TAG
XML MKTGINFO Tag- See Also:
- Constant Field Values
-
GMT_TIME_ZONE
public static final TimeZone GMT_TIME_ZONE
-
DATE_FORMAT_LENGTH
public static final int DATE_FORMAT_LENGTH
-
TIME_FORMAT_LENGTH
public static final int TIME_FORMAT_LENGTH
-
-
Method Detail
-
init
protected boolean init(MBankStatementLoader controller)
Initialize the loader * @param controller Reference to the BankStatementLoaderController- Returns:
- Initialized succesfully
-
attachInput
protected boolean attachInput(InputStream is)
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 wether the import was succesfull- Returns:
- true if all statement lines have been imported succesfully
-
loadLines
public boolean loadLines()
Read statementlines from InputStream.- Returns:
- load success This method will be invoked from ImportController.
-
getDateLastRun
public Timestamp getDateLastRun()
Method getDateLastRun- Returns:
- Timestamp
-
getRoutingNo
public String getRoutingNo()
Method getRoutingNo- Returns:
- String
-
getBankAccountNo
public String getBankAccountNo()
Method getBankAccountNo- Returns:
- String
-
getIBAN
public String getIBAN()
Method getIBAN- Returns:
- String
-
getStatementReference
public String getStatementReference()
Method getStatementReference- Returns:
- String
-
getStatementDate
public Timestamp getStatementDate()
Method getStatementDate- Returns:
- Timestamp
-
getReference
public String getReference()
Method getReference- Returns:
- String
-
getStatementLineDate
public Timestamp getStatementLineDate()
Method getStatementLineDate- Returns:
- Timestamp
-
getValutaDate
public Timestamp getValutaDate()
Method getValutaDate- Returns:
- Timestamp
-
getTrxType
public String getTrxType()
Method getTrxType- Returns:
- String
-
getIsReversal
public boolean getIsReversal()
Method getIsReversal- Returns:
- boolean
-
getCurrency
public String getCurrency()
Method getCurrency- Returns:
- String
-
getStmtAmt
public BigDecimal getStmtAmt()
Method getStmtAmt- Returns:
- BigDecimal
-
getTrxAmt
public BigDecimal getTrxAmt()
Method getTrxAmt- Returns:
- Transaction Amount
-
getInterestAmt
public BigDecimal getInterestAmt()
Method getInterestAmount- Returns:
- Interest Amount
-
getMemo
public String getMemo()
Method getMemo- Returns:
- String
-
getChargeName
public String getChargeName()
Method getChargeName- Returns:
- String
-
getChargeAmt
public BigDecimal getChargeAmt()
Method getChargeAmt- Returns:
- BigDecimal
-
getTrxID
public String getTrxID()
Method getTrxID- Returns:
- String
-
getPayeeAccountNo
public String getPayeeAccountNo()
Method getPayeeAccountNo- Returns:
- String
-
getPayeeName
public String getPayeeName()
Method getPayeeName- Returns:
- String
-
getCheckNo
public String getCheckNo()
Method getCheckNo- Returns:
- String
-
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:
ContentHandler.startElement(String, String, String, Attributes)
-
characters
public void characters(char[] ch, int start, int length) throws SAXException
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:
ContentHandler.characters(char[], int, int)
-
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
Check for valid XML structure. (all tags are properly ended). The statements are passed to ImportController when the statement end () is detected.- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Parameters:
uri
- StringlocalName
- StringqName
- String- Throws:
SAXException
- See Also:
ContentHandler.endElement(String, String, String)
-
parseTimeZone
protected TimeZone parseTimeZone(String tzoffset)
Parse the timezone offset of the form [HOURS_OFF_GMT:TZ_ID]- Parameters:
tzoffset
- The offset pattern.- Returns:
- The timezone.
-
parseDate
protected Date parseDate(String value)
Parses a date according to OFX.- Parameters:
value
- The value of the date.- Returns:
- The date value.
-
getLastErrorMessage
public String getLastErrorMessage()
Method getLastErrorMessage- Returns:
- String
-
getLastErrorDescription
public String getLastErrorDescription()
Method getLastErrorDescription- Returns:
- String
-
-