Package bluej.extensions2.editor
Class TextLocation
- java.lang.Object
-
- bluej.extensions2.editor.TextLocation
-
public class TextLocation extends java.lang.Object
ATextLocation
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 usingJavaEditor.getLineLength(int line)
. When applied to a particular edited text, aTextLocation
may be invalid. That is, at the time of use, it points to an area outside the text being edited.
-
-
Constructor Summary
Constructors Constructor Description TextLocation(int line, int column)
Creates a TextLocation representing the text position at the specified line and column.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)
Sets both the line number and column of this text location.java.lang.String
toString()
Returns a literal representation of this text location.
-
-
-
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 0.
-
getLine
public int getLine()
Returns the line 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 0.
-
getColumn
public int getColumn()
Returns the column of this text location.
-
setPosition
public void setPosition(int line, int column)
Sets both the line number and column of this text location.- Parameters:
line
- a line number starting from 0.column
- a column number starting from 0.
-
toString
public java.lang.String toString()
Returns a literal representation of this text location.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A
String
object containing the literal value formatted as"line=i column=j"
wherei
andj
are respectively the line number value and the column number value of this text location.
-
-