Changeset 4101
- Timestamp:
- Jan 28, 2008, 11:02:08 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/core/net/sf/basedb/plugins/AbstractFlatFileImporter.java
r4095 r4101 500 500 { 501 501 FlatFileParser ffp = getInitializedFlatFileParser(); 502 ffp.setInputStream(in, getCharset());503 502 ffp.setDefaultNumberFormat(getNumberFormat()); 504 503 try 505 504 { 505 in = wrapInputStream(in); 506 ffp.setInputStream(in, getCharset()); 506 507 ffp.nextSection(); 507 508 FlatFileParser.LineType result = ffp.parseHeaders(); … … 527 528 FlatFileParser ffp = getInitializedFlatFileParser(); 528 529 FlatFileParser.Data dataline = null; 529 ffp.setInputStream(in, getCharset());530 530 ffp.setDefaultNumberFormat(getNumberFormat()); 531 531 boolean useNullIfException = "null".equals(job != null ? job.getValue("numberFormatError") : ""); … … 534 534 try 535 535 { 536 in = wrapInputStream(in); 537 ffp.setInputStream(in, getCharset()); 536 538 skippedLines = 0; 537 539 begin(ffp); … … 685 687 // ------------------------------------------- 686 688 687 private int getProgress(FlatFileParser ffp) 688 { 689 return (int) (100 * ffp.getParsedBytes() / fileSize); 689 /** 690 Get the progress of import as a percentage value. The default implementation 691 calls {@link #getNumBytes(FlatFileParser)} and divides it by the file size. 692 @param ffp The file parser that is used to parsed the file 693 @return A value between 0 and 100 694 @since 2.6 695 */ 696 protected int getProgress(FlatFileParser ffp) 697 { 698 return (int) (100 * getNumBytes(ffp) / fileSize); 699 } 700 701 702 /** 703 Get the number of bytes read from the file. The value should indicate the 704 how far into the file parsing has proceeded. The default 705 implementation calls {@link FlatFileParser#getParsedBytes()}. If a subclass has 706 wrapped the input stream the number of parsed byts may not correspond to the 707 number of bytes read from the file. 708 For example, if the file is a compressed file the number of parsed bytes will 709 be higher than the number of bytes read from the file. 710 @param ffp The file parser that is used to parsed the file 711 @return The number of bytes read from the original file 712 @see #wrapInputStream(InputStream) 713 @see #getProgress(FlatFileParser) 714 @since 2.6 715 */ 716 protected long getNumBytes(FlatFileParser ffp) 717 { 718 return ffp.getParsedBytes(); 690 719 } 691 720 … … 705 734 { 706 735 return true; 736 } 737 738 /** 739 This method is called before the parser starts reading from the 740 input stream. A subclass may override this method to wrap the inputstream 741 with a filtering stream, for example, a gzip input stream. The default 742 implementation of this method returns the original stream unmodified. If a subclass 743 overrides this methods it may also need to override one of the 744 {@link #getNumBytes(FlatFileParser)} or {@link #getProgress(FlatFileParser)} 745 methods. 746 @param in The input stream to wrap 747 @return The same or a different input stream 748 @since 2.6 749 @see #getNumBytes(FlatFileParser) 750 */ 751 protected InputStream wrapInputStream(InputStream in) 752 throws IOException 753 { 754 return in; 707 755 } 708 756
Note: See TracChangeset
for help on using the changeset viewer.