edu.rice.cs.drjava.model
Class MovingDocumentRegion

java.lang.Object
  extended by edu.rice.cs.drjava.model.DocumentRegion
      extended by edu.rice.cs.drjava.model.MovingDocumentRegion
All Implemented Interfaces:
IDocumentRegion, OrderedDocumentRegion, Region, Comparable<OrderedDocumentRegion>

public class MovingDocumentRegion
extends DocumentRegion

Class for a document region that moves with changes in the document; it also includes a lazy tool-tip and line boundaries. TODO: convert _startPos and _endPos to _cachedStart and _cachedEnd which are updated by updateLines

Version:
$Id$Regiong

Field Summary
protected  Position _endPos
           
protected  Position _lineEndPos
           
protected  Position _lineStartPos
           
protected  Position _startPos
           
protected  Thunk<String> _stringSuspension
          Suspension that generates the JTree label excerpt for this region.
 
Fields inherited from class edu.rice.cs.drjava.model.DocumentRegion
_doc, _end, _start
 
Constructor Summary
MovingDocumentRegion(OpenDefinitionsDocument doc, int start, int end, int lineStart, int lineEnd)
          Create a new moving document region.
 
Method Summary
static boolean equals(Object a, Object b)
           
 OpenDefinitionsDocument getDocument()
           
 int getEndOffset()
           
 int getLineEndOffset()
          Throws exception indicating that getLineEnd() is not supported.
 int getLineStartOffset()
          Throws exception indicating that getLineStart() is not supported.
 int getStartOffset()
           
 String getString()
          Throws exception indicating that getString() is not supported.
 void update()
          Update _lineStartPos and _lineEndPos after line has been edited.
 
Methods inherited from class edu.rice.cs.drjava.model.DocumentRegion
compareTo, equals, isEmpty, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_startPos

protected final Position _startPos

_endPos

protected final Position _endPos

_lineStartPos

protected volatile Position _lineStartPos

_lineEndPos

protected volatile Position _lineEndPos

_stringSuspension

protected final Thunk<String> _stringSuspension
Suspension that generates the JTree label excerpt for this region.

Constructor Detail

MovingDocumentRegion

public MovingDocumentRegion(OpenDefinitionsDocument doc,
                            int start,
                            int end,
                            int lineStart,
                            int lineEnd)
Create a new moving document region.

Method Detail

update

public void update()
Update _lineStartPos and _lineEndPos after line has been edited.

Specified by:
update in interface OrderedDocumentRegion
Overrides:
update in class DocumentRegion

getDocument

public OpenDefinitionsDocument getDocument()
Specified by:
getDocument in interface IDocumentRegion
Overrides:
getDocument in class DocumentRegion
Returns:
the document, or null if it hasn't been established yet

getStartOffset

public int getStartOffset()
Specified by:
getStartOffset in interface Region
Overrides:
getStartOffset in class DocumentRegion
Returns:
region start.

getEndOffset

public int getEndOffset()
Specified by:
getEndOffset in interface Region
Overrides:
getEndOffset in class DocumentRegion
Returns:
region end.

getLineStartOffset

public int getLineStartOffset()
Description copied from class: DocumentRegion
Throws exception indicating that getLineStart() is not supported.

Specified by:
getLineStartOffset in interface OrderedDocumentRegion
Overrides:
getLineStartOffset in class DocumentRegion
Returns:
line start preeding region.

getLineEndOffset

public int getLineEndOffset()
Description copied from class: DocumentRegion
Throws exception indicating that getLineEnd() is not supported.

Specified by:
getLineEndOffset in interface OrderedDocumentRegion
Overrides:
getLineEndOffset in class DocumentRegion
Returns:
line end following region.

getString

public String getString()
Description copied from class: DocumentRegion
Throws exception indicating that getString() is not supported.

Specified by:
getString in interface OrderedDocumentRegion
Overrides:
getString in class DocumentRegion
Returns:
the string it was assigned

equals

public static boolean equals(Object a,
                             Object b)
Returns:
true if objects a and b are equal; null values are handled correctly.