- int transactionCount = 0;
- int transactionId = 0;
- LedgerTransaction transaction = null;
- LINES:
- while ((line = buf.readLine()) != null) {
- if (isCancelled()) break;
- if (!line.isEmpty() && (line.charAt(0) == ' ')) continue;
- Matcher m;
- L(String.format("State is %d", state));
- switch (state) {
- case ParserState.EXPECTING_JOURNAL:
- if (line.equals("<h2>General Journal</h2>")) {
- state = ParserState.EXPECTING_TRANSACTION;
- L("→ expecting transaction");
- }
- break;
- case ParserState.EXPECTING_TRANSACTION:
- m = transactionStartPattern.matcher(line);
- if (m.find()) {
- transactionId = Integer.valueOf(m.group(1));
- state = ParserState.EXPECTING_TRANSACTION_DESCRIPTION;
- L(String.format("found transaction %d → expecting " +
- "description", transactionId));
- progress.setProgress(++transactionCount);
- if (progress.getTotal() == Progress.INDETERMINATE)
- progress.setTotal(transactionId);
- publishProgress(progress);
- }
- m = endPattern.matcher(line);
- if (m.find()) {
- L("--- transaction list complete ---");
- success = true;
- break LINES;
- }
- break;
- case ParserState.EXPECTING_TRANSACTION_DESCRIPTION:
- m = transactionDescriptionPattern.matcher(line);
- if (m.find()) {
- if (transactionId == 0)
- throw new TransactionParserException(
- "Transaction Id is 0 while expecting " +
- "description");
+ int processedTransactionCount = 0;
+ int transactionId = 0;
+ int matchedTransactionsCount = 0;
+ LedgerTransaction transaction = null;
+ LINES:
+ while ((line = buf.readLine()) != null) {
+ if (isCancelled()) break;
+ Matcher m;
+ //L(String.format("State is %d", state));
+ switch (state) {
+ case ParserState.EXPECTING_JOURNAL:
+ if (!line.isEmpty() && (line.charAt(0) == ' ')) continue;
+ if (line.equals("<h2>General Journal</h2>")) {
+ state = ParserState.EXPECTING_TRANSACTION;
+ L("→ expecting transaction");
+ }
+ break;
+ case ParserState.EXPECTING_TRANSACTION:
+ if (!line.isEmpty() && (line.charAt(0) == ' ')) continue;
+ m = transactionStartPattern.matcher(line);
+ if (m.find()) {
+ transactionId = Integer.valueOf(m.group(1));
+ state = ParserState.EXPECTING_TRANSACTION_DESCRIPTION;
+ L(String.format(
+ "found transaction %d → expecting " + "description",
+ transactionId));
+ progress.setProgress(++processedTransactionCount);
+ if (maxTransactionId < transactionId)
+ maxTransactionId = transactionId;
+ if ((progress.getTotal() == Progress.INDETERMINATE) ||
+ (progress.getTotal() < transactionId))
+ progress.setTotal(transactionId);
+ publishProgress(progress);
+ }
+ m = endPattern.matcher(line);
+ if (m.find()) {
+ L("--- transaction list complete ---");
+ success = true;
+ break LINES;
+ }
+ break;
+ case ParserState.EXPECTING_TRANSACTION_DESCRIPTION:
+ if (!line.isEmpty() && (line.charAt(0) == ' ')) continue;
+ m = transactionDescriptionPattern.matcher(line);
+ if (m.find()) {
+ if (transactionId == 0)
+ throw new TransactionParserException(
+ "Transaction Id is 0 while expecting " +
+ "description");