jgnash.imports.qif
Class QifParser
java.lang.Object
jgnash.imports.qif.QifParser
public class QifParser
- extends java.lang.Object
The QIF format seems to be very broken. Various applications and services
export it differently, some have even extended an already broken format to
add even more confusion. To make matters worse, the format has changed over
time with no indication of what "version" the QIF file is.
This parses through the QIF file using brute force, no fancy parser or
tricks. The QIF file is broken enough that it's easier to find problems with
the parser when it's easy to step through the code.
The !Option:AutoSwitch and !Clear:AutoSwitch headers do not appear to be used
correctly, even by the "creator" of the QIF file format. There seems to be
confusion as to it's purpose. The best thing to do is ignore AutoSwitch
completely and make an educated guess about the data.
I'm not very happy with this code, but I'm not sure there is a clean
solution to parsing QIF files
- Version:
- $Id$
- Author:
- Craig Cavanaugh
|
Constructor Summary |
QifParser(java.lang.String dateFormat)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
dateFormat
private java.lang.String dateFormat
debug
private boolean debug
categories
public java.util.ArrayList<QifCategory> categories
classes
private java.util.ArrayList<QifParser.QifClassItem> classes
accountList
public java.util.ArrayList<QifAccount> accountList
securities
private java.util.ArrayList<QifParser.QifSecurity> securities
logger
private java.util.logging.Logger logger
QifParser
public QifParser(java.lang.String dateFormat)
startsWith
private boolean startsWith(java.lang.String source,
java.lang.String prefix)
- Tests if the source string starts with the prefix string. Case is
ignored.
- Parameters:
source - the source String.prefix - the prefix String.
- Returns:
- true, if the source starts with the prefix string.
setDateFormat
void setDateFormat(java.lang.String dateFormat)
parseFullFile
void parseFullFile(java.io.File file)
throws NoAccountException
- Throws:
NoAccountException
parsePartialFile
void parsePartialFile(java.io.File file)
parseFullFile
private void parseFullFile(java.lang.String fileName)
throws NoAccountException
- Throws:
NoAccountException
parsePartialFile
private boolean parsePartialFile(java.lang.String fileName)
parseAccount
private boolean parseAccount(QifReader in)
searchForDuplicate
QifAccount searchForDuplicate(QifAccount acc)
parseAccountTransactions
private boolean parseAccountTransactions(QifReader in,
QifAccount acc)
parseInvestmentAccountTransactions
private boolean parseInvestmentAccountTransactions(QifReader in,
QifAccount acc)
parseSplitTransaction
private QifSplitTransaction parseSplitTransaction(QifReader in)
parseMemorizedTransactions
private void parseMemorizedTransactions(QifReader in)
- just eat the data, it's not useful right now
parseCategoryList
private boolean parseCategoryList(QifReader in)
parseClassList
private boolean parseClassList(QifReader in)
parseSecurity
private boolean parseSecurity(QifReader in)
- So far, I haven't see a security as part of a list, but it is supported
just in case there is another "variation" of the format
parsePrice
private boolean parsePrice(QifReader in)
- Price data in QIF file is not very informative.... ignore it for now
dumpStats
public void dumpStats()