public class TextSelection extends Object implements ITextSelection
ITextSelection
.
Takes advantage of the weak contract of correctness of its interface. If generated from a selection provider, it only remembers its offset and length and computes the remaining information on request.
Constructor and Description |
---|
TextSelection(IDocument document,
int offset,
int length)
Creates a text selection for the given range of the given document.
|
TextSelection(int offset,
int length)
Creates a text selection for the given range.
|
Modifier and Type | Method and Description |
---|---|
static ITextSelection |
emptySelection()
Returns the shared instance of the empty text selection.
|
boolean |
equals(Object obj) |
protected IDocument |
getDocument()
Returns the document underlying the receiver, possibly
null . |
int |
getEndLine()
Returns the number of the line containing the last character of the selected text.
|
int |
getLength()
Returns the length of the selected text.
|
int |
getOffset()
Returns the offset of the selected text.
|
int |
getStartLine()
Returns number of the line containing the offset of the selected text.
|
String |
getText()
Returns the selected text.
|
int |
hashCode() |
boolean |
isEmpty()
Tells whether this text selection is the empty selection.
|
public TextSelection(int offset, int length)
setSelection
method of selection providers.offset
- the offset of the range, must not be negativelength
- the length of the range, must not be negativepublic TextSelection(IDocument document, int offset, int length)
getSelection
.document
- the document whose text range is selected in a vieweroffset
- the offset of the selected range, must not be negativelength
- the length of the selected range, must not be negativepublic static ITextSelection emptySelection()
public boolean isEmpty()
A selection of length 0 is not an empty text selection as it describes, e.g., the cursor position in a viewer.
isEmpty
in interface ISelection
true
if this selection is emptyemptySelection()
public int getOffset()
ITextSelection
getOffset
in interface ITextSelection
public int getLength()
ITextSelection
getLength
in interface ITextSelection
public int getStartLine()
ITextSelection
getStartLine
in interface ITextSelection
public int getEndLine()
ITextSelection
getEndLine
in interface ITextSelection
public String getText()
ITextSelection
getText
in interface ITextSelection
null
if there is no valid text informationprotected IDocument getDocument()
null
.null
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.