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 Details

  • Constructor Details

    • OFXBankStatementHandler

      public OFXBankStatementHandler()
  • Method Details

    • init

      protected boolean init(MBankStatementLoader controller)
      Initialize the loader
      Parameters:
      controller - Reference to the BankStatementLoaderController
      Returns:
      Initialized successfully
    • 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 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

      public Timestamp getDateLastRun()
      Returns:
      last run date
    • getRoutingNo

      public String getRoutingNo()
      Returns:
      routing number
    • getBankAccountNo

      public String getBankAccountNo()
      Returns:
      line bank account number
    • getIBAN

      public String getIBAN()
      Returns:
      IBAN
    • getStatementReference

      public String getStatementReference()
      Returns:
      line statement reference
    • getStatementDate

      public Timestamp getStatementDate()
      Returns:
      statement date
    • getReference

      public String getReference()
      Returns:
      line reference
    • getStatementLineDate

      public Timestamp getStatementLineDate()
      Returns:
      line statement date
    • getValutaDate

      public Timestamp getValutaDate()
      Returns:
      line valuta date
    • getTrxType

      public String getTrxType()
      Returns:
      line trx type
    • getIsReversal

      public boolean getIsReversal()
      Returns:
      true if line is reversal
    • getCurrency

      public String getCurrency()
      Returns:
      line currency
    • getStmtAmt

      public BigDecimal getStmtAmt()
      Returns:
      line statement amount
    • getTrxAmt

      public BigDecimal getTrxAmt()
      Returns:
      Line Transaction Amount
    • getInterestAmt

      public BigDecimal getInterestAmt()
      Returns:
      Interest Amount
    • getMemo

      public String getMemo()
      Returns:
      line memo
    • getChargeName

      public String getChargeName()
      Returns:
      line charge name
    • getChargeAmt

      public BigDecimal getChargeAmt()
      Returns:
      line charge amount
    • getTrxID

      public String getTrxID()
      Returns:
      line transaction id
    • getPayeeAccountNo

      public String getPayeeAccountNo()
      Returns:
      line payee account number
    • getPayeeName

      public String getPayeeName()
      Returns:
      line payee name
    • getCheckNo

      public String 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 interface ContentHandler
      Overrides:
      startElement in class DefaultHandler
      Parameters:
      uri - String
      localName - String
      qName - String
      attributes - Attributes
      Throws:
      SAXException
      See Also:
    • 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 interface ContentHandler
      Overrides:
      characters in class DefaultHandler
      Parameters:
      ch - char[]
      start - int
      length - int
      Throws:
      SAXException
      See Also:
    • 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 (</STMTTRN>) is detected.
      Specified by:
      endElement in interface ContentHandler
      Overrides:
      endElement in class DefaultHandler
      Parameters:
      uri - String
      localName - String
      qName - String
      Throws:
      SAXException
      See Also:
    • parseTimeZone

      protected TimeZone parseTimeZone(String tzoffset)
      source: https://github.com/stoicflame/ofx4j/blob/a604e4f6ffefea61403434cf853bbd1b20740386/src/main/java/com/webcohesion/ofx4j/io/DefaultStringConversion.java

      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()
      Returns:
      last error message
    • getLastErrorDescription

      public String getLastErrorDescription()
      Returns:
      last error description