Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/LineReader.java @ 628:6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 22 May 2013 15:52:31 +0200 |
| parents | 507602cb4fb3 |
| children | e79cf9a8130b |
comparison
equal
deleted
inserted
replaced
| 627:5153eb73b18d | 628:6526d8adbc0f |
|---|---|
| 24 import java.io.InputStreamReader; | 24 import java.io.InputStreamReader; |
| 25 import java.io.Reader; | 25 import java.io.Reader; |
| 26 import java.nio.charset.Charset; | 26 import java.nio.charset.Charset; |
| 27 import java.util.Collection; | 27 import java.util.Collection; |
| 28 | 28 |
| 29 import org.tmatesoft.hg.repo.HgInvalidFileException; | 29 import org.tmatesoft.hg.core.HgIOException; |
| 30 import org.tmatesoft.hg.util.LogFacility; | 30 import org.tmatesoft.hg.util.LogFacility; |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Handy class to read line-based configuration files | 33 * Handy class to read line-based configuration files |
| 34 * | 34 * |
| 93 public LineReader ignoreLineComments(String lineStart) { | 93 public LineReader ignoreLineComments(String lineStart) { |
| 94 ignoreThatStarts = lineStart; | 94 ignoreThatStarts = lineStart; |
| 95 return this; | 95 return this; |
| 96 } | 96 } |
| 97 | 97 |
| 98 public <T> void read(LineConsumer<T> consumer, T paramObj) throws HgInvalidFileException { | 98 public <T> void read(LineConsumer<T> consumer, T paramObj) throws HgIOException { |
| 99 BufferedReader statusFileReader = null; | 99 BufferedReader statusFileReader = null; |
| 100 try { | 100 try { |
| 101 // consumer.begin(file, paramObj); | 101 // consumer.begin(file, paramObj); |
| 102 Reader fileReader; | 102 Reader fileReader; |
| 103 if (encoding == null) { | 103 if (encoding == null) { |
| 118 if (!skipEmpty || line.length() > 0) { | 118 if (!skipEmpty || line.length() > 0) { |
| 119 ok = consumer.consume(line, paramObj); | 119 ok = consumer.consume(line, paramObj); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 } catch (IOException ex) { | 122 } catch (IOException ex) { |
| 123 throw new HgInvalidFileException(ex.getMessage(), ex, file); | 123 throw new HgIOException(ex.getMessage(), ex, file); |
| 124 } finally { | 124 } finally { |
| 125 new FileUtils(log).closeQuietly(statusFileReader); | 125 new FileUtils(log).closeQuietly(statusFileReader); |
| 126 // try { | 126 // try { |
| 127 // consumer.end(file, paramObj); | 127 // consumer.end(file, paramObj); |
| 128 // } catch (IOException ex) { | 128 // } catch (IOException ex) { |
