Package org.eclipse.jface.text.link
Class LinkedPosition
- java.lang.Object
-
- org.eclipse.jface.text.Position
-
- org.eclipse.jface.text.link.LinkedPosition
-
- Direct Known Subclasses:
ProposalPosition
public class LinkedPosition extends Position
APosition
on a document that knows which document it is registered with and has a sequence number for tab stops.Clients may extend this class.
- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description LinkedPosition(IDocument document, int offset, int length)
Creates a new instance.LinkedPosition(IDocument document, int offset, int length, int sequence)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
String
getContent()
Returns the content of this position on the referenced document.IDocument
getDocument()
int
getSequenceNumber()
Returns the sequence number of this position.int
hashCode()
boolean
includes(int pOffset)
OverridesPosition.includes(int)
so every offset is considered included that lies in between the first and last offset of this position, and offsets that are right at the end of the position.boolean
includes(DocumentEvent event)
Returns whether this position includesevent
.protected boolean
includes(IDocument doc, int off, int len)
Returns whether this position includes the range given byoffset
andlength
.boolean
includes(LinkedPosition position)
Returns whether this position includesposition
.boolean
overlapsWith(LinkedPosition position)
Returns whether this position overlaps withposition
.void
setSequenceNumber(int sequence)
Sets the sequence number of this position.
-
-
-
Constructor Detail
-
LinkedPosition
public LinkedPosition(IDocument document, int offset, int length, int sequence)
Creates a new instance.- Parameters:
document
- the documentoffset
- the offset of the positionlength
- the length of the positionsequence
- the iteration sequence rank
-
LinkedPosition
public LinkedPosition(IDocument document, int offset, int length)
Creates a new instance. Equivalent to callingLinkedPosition(document, offset, length, LinkedPositionGroup.NO_STOP)
- Parameters:
document
- the documentoffset
- the offset of the positionlength
- the length of the position
-
-
Method Detail
-
getDocument
public IDocument getDocument()
- Returns:
- Returns the document.
-
overlapsWith
public boolean overlapsWith(LinkedPosition position)
Returns whether this position overlaps withposition
.- Parameters:
position
- the position to check.- Returns:
true
if this position overlaps withposition
,false
otherwise
-
includes
public boolean includes(DocumentEvent event)
Returns whether this position includesevent
.- Parameters:
event
- the event to check.- Returns:
true
if this position includesevent
,false
otherwise
-
includes
public boolean includes(LinkedPosition position)
Returns whether this position includesposition
.- Parameters:
position
- the position to check.- Returns:
true
if this position includesposition
,false
otherwise
-
includes
public boolean includes(int pOffset)
OverridesPosition.includes(int)
so every offset is considered included that lies in between the first and last offset of this position, and offsets that are right at the end of the position.
-
includes
protected boolean includes(IDocument doc, int off, int len)
Returns whether this position includes the range given byoffset
andlength
. A range is included by aLinkedPosition
ifincludes(offset)
returns true for every offset in the range, including the borders of the range.- Parameters:
doc
- the document that the given range refers to, may benull
off
- the offset of the range, referring todocument
len
- the length of the range- Returns:
true
ifdoc
is the same document as this position refers to, and if the entire range is included in this position
-
getContent
public String getContent() throws BadLocationException
Returns the content of this position on the referenced document.- Returns:
- the content of the document at this position
- Throws:
BadLocationException
- if the position is not valid
-
getSequenceNumber
public int getSequenceNumber()
Returns the sequence number of this position.- Returns:
- the sequence number of this position
-
setSequenceNumber
public void setSequenceNumber(int sequence)
Sets the sequence number of this position.- Parameters:
sequence
- the new sequence number
-
-