Extension SDK 10.1.2

oracle.javatools.buffer
Interface LineMap


public interface LineMap

A LineMap is an interface for accessing the line structure information of a TextBuffer. This allows clients to determine the line that an offset is on, the starting and ending offset of a specific line, and the total number of lines in the TextBuffer.

Client Usage Notes:

Note that we do not follow the convention of the Swing text package, where documents have the implicit trailing '\n' character. The very last line of the TextBuffer does NOT have a trailing '\n' character.

See Also:
TextBuffer

Method Summary
 int getLineCount()
          Fetches the number of lines in this TextBuffer.
 int getLineEndOffset(int line)
          Given a specified line, returns the offset from the beginning of a TextBuffer that the line ends at.
 int getLineFromOffset(int offset)
          Given an offset from the beginning of the underlying TextBuffer, fetches the line number containing that offset using a Forward bias.
 int getLineStartOffset(int line)
          Given a specified line, returns the offset from the beginning of the TextBuffer for the start of the line.
 TextBuffer getTextBuffer()
          Fetches the underlying TextBuffer of this line map.
 

Method Detail

getTextBuffer

public TextBuffer getTextBuffer()
Fetches the underlying TextBuffer of this line map.

Returns:
the text buffer

getLineCount

public int getLineCount()
Fetches the number of lines in this TextBuffer. For example, a 5-line TextBuffer has lines 0 through 4.

Returns:
number of lines in TextBuffer

getLineFromOffset

public int getLineFromOffset(int offset)
Given an offset from the beginning of the underlying TextBuffer, fetches the line number containing that offset using a Forward bias. This means if line A starts with offset B, and previous line A-1 ends with offset B, getLineFromOffset(B) will return line A.

Returns:
the line containing an offset

getLineStartOffset

public int getLineStartOffset(int line)
Given a specified line, returns the offset from the beginning of the TextBuffer for the start of the line.

Parameters:
line - a line in the TextBuffer
Returns:
the starting offset of the specified line

getLineEndOffset

public int getLineEndOffset(int line)
Given a specified line, returns the offset from the beginning of a TextBuffer that the line ends at.

Parameters:
line - a line in the TextBuffer

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.