saker.util Documentation TaskDoc JavaDoc Packages
package saker.util
public class LineIndexMapBuilder implements Appendable
Class that creates a line index map based on the character data passed to it.

The class creates line index map the same way as StringUtils.getLineIndexMap(CharSequence), but doesn't require to have the whole character sequence to be accessible, character data can be written to it in sequence.

Use getIndexMap() to retrieve the line index map.

Constructors
public
Creates a new instance initialized to receive character data.
public
LineIndexMapBuilder(int estimatedlinecount)
Crates a new builder with an estimated number of lines that the result will contain.
Methods
public LineIndexMapBuilder
append(char c)
Appends the specified character to this Appendable.
public LineIndexMapBuilder
Appends the specified character sequence to this Appendable.
public LineIndexMapBuilder
append(CharSequence csq, int start, int end)
Appends a subsequence of the specified character sequence to this Appendable.
public LineIndexMapBuilder
append(char[] csq)
Appends the argument characters to the index builder.
public LineIndexMapBuilder
append(char[] csq, int start, int end)
Appends a range of characters from a given array to the index builder.
public int[]
Gets the line index map that was built from the character data passed to this builder.
Creates a new instance initialized to receive character data.
public LineIndexMapBuilder(int estimatedlinecount) throws IllegalArgumentException
Crates a new builder with an estimated number of lines that the result will contain.

The passed line count is an estimate, the build will grow accordingly if more lines are encountered.

estimatedlinecountThe estimated line count.
IllegalArgumentExceptionIf the estimation is 0 or negative.
Overridden from: Appendable
Appends the specified character to this Appendable.
cThe character to append
A reference to this Appendable
Overridden from: Appendable
Appends the specified character sequence to this Appendable.

Depending on which class implements the character sequence csq, the entire sequence may not be appended. For instance, if csq is a CharBuffer then the subsequence to append is defined by the buffer's position and limit.

dataThe character sequence to append. If csq is null, then the four characters "null" are appended to this Appendable.
A reference to this Appendable
public LineIndexMapBuilder append(CharSequence csq, int start, int end)
Overridden from: Appendable
Appends a subsequence of the specified character sequence to this Appendable.

An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

     out.append(csq.subSequence(start, end)) 
csqThe character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
startThe index of the first character in the subsequence
endThe index of the character following the last character in the subsequence
A reference to this Appendable
public LineIndexMapBuilder append(char[] csq)
Appends the argument characters to the index builder.
csqThe characters.
this
public LineIndexMapBuilder append(char[] csq, int start, int end) throws IndexOutOfBoundsException
Appends a range of characters from a given array to the index builder.
csqThe character array.
startThe starting index in the array. (inclusive)
endThe end index in the array. (exclusive)
this
IndexOutOfBoundsExceptionIf the range is out of the array's bounds.
public int[] getIndexMap()
Gets the line index map that was built from the character data passed to this builder.

The builder instance is reuseable. The builder is not reset by this call, so appending more data will continue building the same line index.

The line index map.