Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.text
Class TextSelection


java.lang.Object
  extended by 
org.eclipse.jface.text.TextSelection
All Implemented Interfaces:
ITextSelection, ISelection
Direct Known Subclasses:
BlockTextSelection

public class TextSelection
extends Object
implements ITextSelection

Standard implementation of 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 Summary
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.
 
Method Summary
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.
 
Methods inherited from class java.lang. Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextSelection

public TextSelection(int offset,
                     int length)
Creates a text selection for the given range. This selection object describes generically a text range and is intended to be an argument for the setSelection method of selection providers.

Parameters:
offset - the offset of the range, must not be negative
length - the length of the range, must not be negative

TextSelection

public TextSelection(
IDocument document,
                     int offset,
                     int length)
Creates a text selection for the given range of the given document. This selection object is created by selection providers in responds getSelection.

Parameters:
document - the document whose text range is selected in a viewer
offset - the offset of the selected range, must not be negative
length - the length of the selected range, must not be negative
Method Detail

emptySelection

public static 
ITextSelection emptySelection()
Returns the shared instance of the empty text selection.

Returns:
the shared instance of an empty text selection

isEmpty

public boolean isEmpty()
Tells whether this text selection is the empty selection.

A selection of length 0 is not an empty text selection as it describes, e.g., the cursor position in a viewer.

Specified by:
isEmpty in interface ISelection
Returns:
true if this selection is empty
See Also:
emptySelection()

getOffset

public int getOffset()
Description copied from interface: ITextSelection
Returns the offset of the selected text.

Specified by:
getOffset in interface ITextSelection
Returns:
the offset of the selected text or -1 if there is no valid text information

getLength

public int getLength()
Description copied from interface: ITextSelection
Returns the length of the selected text.

Specified by:
getLength in interface ITextSelection
Returns:
the length of the selected text or -1 if there is no valid text information

getStartLine

public int getStartLine()
Description copied from interface: ITextSelection
Returns number of the line containing the offset of the selected text. If the underlying text has been changed between the creation of this selection object and the call of this method, the value returned might differ from what it would have been at the point of creation.

Specified by:
getStartLine in interface ITextSelection
Returns:
the start line of this selection or -1 if there is no valid line information

getEndLine

public int getEndLine()
Description copied from interface: ITextSelection
Returns the number of the line containing the last character of the selected text. If the underlying text has been changed between the creation of this selection object and the call of this method, the value returned might differ from what it would have been at the point of creation.

Specified by:
getEndLine in interface ITextSelection
Returns:
the end line of this selection or -1 if there is no valid line information

getText

public 
String getText()
Description copied from interface: ITextSelection
Returns the selected text. If the underlying text has been changed between the creation of this selection object and the call of this method, the value returned might differ from what it would have been at the point of creation.

Specified by:
getText in interface ITextSelection
Returns:
the selected text or null if there is no valid text information

equals

public boolean equals(
Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getDocument

protected 
IDocument getDocument()
Returns the document underlying the receiver, possibly null.

Returns:
the document underlying the receiver, possibly null
Since:
3.5

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire