Changeset 4056
- Timestamp:
- Dec 12, 2007, 9:35:46 AM (16 years ago)
- Location:
- branches/2.5-stable/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.5-stable/src/core/net/sf/basedb/util/parser/FlatFileParser.java
r4020 r4056 47 47 import net.sf.basedb.core.BaseException; 48 48 import net.sf.basedb.core.Config; 49 import net.sf.basedb.util.InputStreamTracker; 49 50 50 51 /** … … 176 177 177 178 /** 179 For keeping track of the number of bytes parsed. 180 */ 181 private InputStreamTracker tracker; 182 183 /** 178 184 The regular expression for matching a header line. 179 185 */ … … 522 528 { 523 529 Charset cs = Charset.forName(charsetName == null ? Config.getCharset() : charsetName); 524 this.reader = new BufferedReader(new InputStreamReader(in, cs)); 530 this.tracker = new InputStreamTracker(in); 531 this.reader = new BufferedReader(new InputStreamReader(tracker, cs)); 525 532 } 526 533 … … 1116 1123 correspond to the number of parsed bytes depending on the character 1117 1124 set of the file. 1125 @see #getParsedBytes() 1118 1126 */ 1119 1127 public long getParsedCharacters() 1120 1128 { 1121 1129 return parsedCharacters; 1130 } 1131 1132 /** 1133 Get the number of parsed bytes so far. This value may or may not 1134 correspond to the number of parsed characters depending on the character 1135 set of the file. 1136 @since 2.5.1 1137 @see #getParsedCharacters() 1138 */ 1139 public long getParsedBytes() 1140 { 1141 return tracker == null ? 0 : tracker.getNumRead(); 1122 1142 } 1123 1143 -
branches/2.5-stable/src/plugins/core/net/sf/basedb/plugins/AbstractFlatFileImporter.java
r3889 r4056 536 536 if (section != null && section.type() == FlatFileParser.LineType.SECTION) 537 537 { 538 if (progress != null) progress.display(getProgress(ffp .getParsedCharacters()), "Parsing section "+section.name()+"...");538 if (progress != null) progress.display(getProgress(ffp), "Parsing section "+section.name()+"..."); 539 539 try 540 540 { … … 565 565 else 566 566 { 567 if (progress != null) progress.display(getProgress(ffp .getParsedCharacters()), "Parsing headers...");567 if (progress != null) progress.display(getProgress(ffp), "Parsing headers..."); 568 568 } 569 569 FlatFileParser.LineType result = ffp.parseHeaders(); … … 603 603 " on line " + (line == null ? "-1" : line.lineNo() + ": " + StringUtil.trimString(line.line(), 20)), t); 604 604 } 605 if (progress != null) progress.display(getProgress(ffp .getParsedCharacters()), "Parsing data...");605 if (progress != null) progress.display(getProgress(ffp), "Parsing data..."); 606 606 int progressLine = 0; 607 607 … … 634 634 if (progress != null) 635 635 { 636 progress.display(getProgress(ffp .getParsedCharacters()), "Parsing data... (" + ffp.getParsedLines() + " lines so far)");636 progress.display(getProgress(ffp), "Parsing data... (" + ffp.getParsedLines() + " lines so far)"); 637 637 } 638 638 } … … 662 662 // ------------------------------------------- 663 663 664 private int getProgress( long parsedCharacters)665 { 666 return (int) (100 * parsedCharacters/ fileSize);664 private int getProgress(FlatFileParser ffp) 665 { 666 return (int) (100 * ffp.getParsedBytes() / fileSize); 667 667 } 668 668
Note: See TracChangeset
for help on using the changeset viewer.