bluej.extensions.editor
Class TextLocation

java.lang.Object
  extended by bluej.extensions.editor.TextLocation

public class TextLocation
extends java.lang.Object

A TextLocation object groups two pieces of information: a line number and a column number. They represent a position in the editor's text. A text location represents the gap to the left of the position identified, so that (0, 0) is the start of the file, (0, 1) is between the first and second characters in the file, and so on. There is a TextLocation position to the right of the last character on a line. The column value of this position can be determined using Editor.getLineLength(int line). When applied to a particular edited text, a TextLocation may be invalid. That is, at the time of use, it points to an area outside the text being edited.

Version:
$Id: TextLocation.java 6215 2009-03-30 13:28:25Z polle $

Constructor Summary
TextLocation(int line, int column)
          Create a TextLocation representing the text position at the specified line and column
 
Method Summary
 int getColumn()
          Returns the column of this text location
 int getLine()
          Returns the line of this text position
 void setColumn(int column)
          Sets the column of this text position, leaving the line number unchanged.
 void setLine(int line)
          Sets the line number of this text position, leaving the column unchanged.
 void setPosition(int line, int column)
          Set both the line number and column of this text location
 java.lang.String toString()
          Returns a string representation of this text location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextLocation

public TextLocation(int line,
                    int column)
Create a TextLocation representing the text position at the specified line and column

Parameters:
line - a line number starting from 0
column - a column number starting from 0
Method Detail

setLine

public void setLine(int line)
Sets the line number of this text position, leaving the column unchanged.

Parameters:
line - the line number starting from zero

getLine

public int getLine()
Returns the line of this text position

Returns:
the line number of this text position

setColumn

public void setColumn(int column)
Sets the column of this text position, leaving the line number unchanged.

Parameters:
column - the column number starting from zero

getColumn

public int getColumn()
Returns the column of this text location

Returns:
the column number of this text location

setPosition

public void setPosition(int line,
                        int column)
Set both the line number and column of this text location

Parameters:
line - a line number starting from zero
column - a column number starting from zero

toString

public java.lang.String toString()
Returns a string representation of this text location.

Overrides:
toString in class java.lang.Object
Returns:
a string that represents this object status


BlueJ homepage