public class TextSelection extends Object implements ITextSelection
ITextSelection.
Makes 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 a shared instance of an empty text selection.
|
boolean |
equals(Object obj) |
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()
Returns true if the offset and length are smaller than 0.
|
public TextSelection(int offset,
int length)
setSelection
method of selection providers.offset - the offset of the rangelength - the length of the rangepublic TextSelection(IDocument document, int offset, int length)
getSelection.document - the document whose text range is selected in a vieweroffset - the offset of the selected rangelength - the length of the selected rangepublic static ITextSelection emptySelection()
public boolean isEmpty()
isEmpty in interface ISelectiontrue if this selection is emptyISelection.isEmpty()public int getOffset()
ITextSelectiongetOffset in interface ITextSelectionpublic int getLength()
ITextSelectiongetLength in interface ITextSelectionpublic int getStartLine()
ITextSelectiongetStartLine in interface ITextSelection-1 if there is no valid line informationpublic int getEndLine()
ITextSelectiongetEndLine in interface ITextSelection-1 if there is no valid line informationpublic String getText()
ITextSelectiongetText in interface ITextSelectionnull if there is no valid text informationGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.