org.electrocodeogram.cpc.core.api.provider.track
Class CPCPosition

java.lang.Object
  extended by org.eclipse.jface.text.Position
      extended by org.electrocodeogram.cpc.core.api.provider.track.CPCPosition

public class CPCPosition
extends org.eclipse.jface.text.Position

Represents the position of an IClone object during modifications of an IDocument.
Keeps reference to the corresponding IClone object.

NOTE: updating a CPCPosition does not directly affect the corresponding IClone instance. Modifications may be cached and written back to the clone objects at a later point in time.

NOTE: CPCPositions are not encapsulated behind a separate interface for performance reasons.
The IPositionUpdateStrategyProvider may directly access and modify field values to improve performance.

Author:
vw
See Also:
IPositionUpdateStrategyProvider

Field Summary
 IClone clone
           
 java.lang.String content
           
 boolean contentModified
           
 java.util.List<CPCDocumentEvent> contentModifyingDocumentEvents
           
static java.lang.String CPC_POSITION_CATEGORY
          The unique position category name for all CPCPosition entries.
 
Fields inherited from class org.eclipse.jface.text.Position
isDeleted, length, offset
 
Constructor Summary
CPCPosition(IClone clone)
          Creates a new CPCPosition with the position of the given clone object.
 
Method Summary
 void addContentModifyingDocumentEvent(CPCDocumentEvent cpcEvent)
          Adds the given CPCDocumentEvent to this CPCPosition.
 IClone getClone()
          Retrieves the clone corresponding to this position.
 java.lang.String getContent()
          Retrieves the current content of the corresponding clone entry.
 java.util.List<CPCDocumentEvent> getContentModifyingDocumentEvents()
          Retrieves a list of events which affected this position.
 int getEndOffset()
          Retrieves the end offset of this position.
 boolean isContentModified()
          Checks whether the clone content of this position was modified.
 void setContent(java.lang.String content)
          Sets current content of the corresponding clone entry.
 void setContentModified(boolean contentModified)
          Specifies whether the clone content of this position was modified.
 java.lang.String toString()
           
 
Methods inherited from class org.eclipse.jface.text.Position
delete, equals, getLength, getOffset, hashCode, includes, isDeleted, overlapsWith, setLength, setOffset, undelete
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CPC_POSITION_CATEGORY

public static final java.lang.String CPC_POSITION_CATEGORY
The unique position category name for all CPCPosition entries.

See Also:
Constant Field Values

clone

public IClone clone
See Also:
getClone()

content

public java.lang.String content
See Also:
getContent()

contentModified

public boolean contentModified
See Also:
isContentModified()

contentModifyingDocumentEvents

public java.util.List<CPCDocumentEvent> contentModifyingDocumentEvents
See Also:
getContentModifyingDocumentEvents()
Constructor Detail

CPCPosition

public CPCPosition(IClone clone)
Creates a new CPCPosition with the position of the given clone object.

Parameters:
clone - the clone object which this position should represent, never null.
Method Detail

getClone

public IClone getClone()
Retrieves the clone corresponding to this position.

Returns:
the clone corresponding to this position, never null.

isContentModified

public boolean isContentModified()
Checks whether the clone content of this position was modified.

Returns:
whether the clone content of this position was modified.

setContentModified

public void setContentModified(boolean contentModified)
Specifies whether the clone content of this position was modified.

See Also:
isContentModified()

getContent

public java.lang.String getContent()
Retrieves the current content of the corresponding clone entry.

Returns:
the current content of the corresponding clone entry.

setContent

public void setContent(java.lang.String content)
Sets current content of the corresponding clone entry.

See Also:
getContent()

getContentModifyingDocumentEvents

public java.util.List<CPCDocumentEvent> getContentModifyingDocumentEvents()
Retrieves a list of events which affected this position.

Returns:
may be NULL

addContentModifyingDocumentEvent

public void addContentModifyingDocumentEvent(CPCDocumentEvent cpcEvent)
Adds the given CPCDocumentEvent to this CPCPosition.

Parameters:
cpcEvent - the CPCDocumentEvent to add, never null.

getEndOffset

public int getEndOffset()
Retrieves the end offset of this position.
Convenience method.

Returns:
value of: Position.getOffset() + Position.getLength() - 1

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object