API / geotoolkit / util / stream / LineReader / LineReader
stream.LineReader.LineReader
A wrapper class offering line based reading on top of a regular stream.
This implementation hides the complexity of the underlying stream to offer line based reading instead.
To do so, this reader will (lazily) parse the stream to text and search for \n \r chars.
Doing so, it will build a line based index to allow faster access to specific lines further on.
Constructors
Methods
▸ capture(startRegex, endRegex, index, maxcount, callback): void
Search for the sequence starting by the given regexp and ending by the other regexp.
The search starts at the given line number and ends (at worst) after maxcount lines have been read (if maxcount != -1).
Note that reaching END-OF-STREAM without finding the searched regexp will not be considered as an error.
| Name | Type | Description |
|---|---|---|
startRegex | string | The start regular expression to search for (as a string) |
endRegex | string | The end regular expression to search for (as a string) |
index | number | Starting line index |
maxcount | number | Maximum count of line that can be read. If the capture did not finish in that range, an error will be reported. -1 for no limit |
callback | captureCallback | The function called with the result |
void
▸ find(regex, index, callback): void
Search for the given regexp starting at the given line number.
| Name | Type | Description |
|---|---|---|
regex | string | The regular expression to search for (as a string) |
index | number | Starting line index |
callback | findCallback | The function called with the result |
void
▸ getClassName(): string
string
▸ readLines(index, count, callback): void
Reads the lines starting at the given line index up to the given count.
| Name | Type | Description |
|---|---|---|
index | number | Starting line index |
count | number | Amount of lines to read |
callback | readLinesCallback | The function called with the result |
void
▸ Static getClassName(): string
string