Last updated

API / geotoolkit / util / stream / LineReader / LineReader

Class: 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.

Table of contents

Constructors
Methods

Contents

Constructors

new LineReader(options)

new LineReader(options)

Parameters

Name Type
optionsOptions
Methods

capture

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.

Parameters

Name Type Description
startRegexstringThe start regular expression to search for (as a string)
endRegexstringThe end regular expression to search for (as a string)
indexnumberStarting line index
maxcountnumberMaximum 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
callbackcaptureCallbackThe function called with the result

Returns

void


find

find(regex, index, callback): void

Search for the given regexp starting at the given line number.

Parameters

Name Type Description
regexstringThe regular expression to search for (as a string)
indexnumberStarting line index
callbackfindCallbackThe function called with the result

Returns

void


getClassName

getClassName(): string

Returns

string


readLines

readLines(index, count, callback): void

Reads the lines starting at the given line index up to the given count.

Parameters

Name Type Description
indexnumberStarting line index
countnumberAmount of lines to read
callbackreadLinesCallbackThe function called with the result

Returns

void


getClassName

Static getClassName(): string

Returns

string