org.eclipse.ecf.sync.doc
Class DocumentChangeMessage

java.lang.Object
  extended by org.eclipse.ecf.sync.doc.DocumentChangeMessage
All Implemented Interfaces:
java.io.Serializable, org.eclipse.core.runtime.IAdaptable, IDocumentChange, IModelChange, IModelChangeMessage

public class DocumentChangeMessage
extends java.lang.Object
implements IDocumentChange, IModelChangeMessage, java.io.Serializable

Document change message of communicating document change events to remote models.

Since:
2.1
See Also:
Serialized Form

Constructor Summary
DocumentChangeMessage(int offset, int length, java.lang.String text)
          Create document change message for given offset, length of replacement, and text to replace.
 
Method Summary
 void applyToModel(java.lang.Object model)
          Apply the change to a model.
static DocumentChangeMessage deserialize(byte[] bytes)
           
 java.lang.Object getAdapter(java.lang.Class adapter)
           
 int getLengthOfInsertedText()
           
 int getLengthOfReplacedText()
          Returns the length of replaced text.
 int getOffset()
          Returns the modification index of the operation resembled by this message.
 java.lang.String getText()
          Get the new text.
 byte[] serialize()
          Serialize the current message
 void setLengthOfReplacedText(int length)
           
 void setOffset(int updatedOffset)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DocumentChangeMessage

public DocumentChangeMessage(int offset,
                             int length,
                             java.lang.String text)
Create document change message for given offset, length of replacement, and text to replace.

Parameters:
offset - the offset (number of characters) in the document where change is to occur.
length - the length (number of characters) that are to be replace in existing document.
text - the text to actually replace.
Method Detail

deserialize

public static DocumentChangeMessage deserialize(byte[] bytes)
                                         throws SerializationException
Throws:
SerializationException

getOffset

public int getOffset()
Returns the modification index of the operation resembled by this message.

Specified by:
getOffset in interface IDocumentChange
Returns:
modification index

setOffset

public void setOffset(int updatedOffset)

getLengthOfReplacedText

public int getLengthOfReplacedText()
Returns the length of replaced text.

Specified by:
getLengthOfReplacedText in interface IDocumentChange
Returns:
length of replaced text

setLengthOfReplacedText

public void setLengthOfReplacedText(int length)

getText

public java.lang.String getText()
Description copied from interface: IDocumentChange
Get the new text.

Specified by:
getText in interface IDocumentChange
Returns:
text

getLengthOfInsertedText

public int getLengthOfInsertedText()
Returns:
the length of the inserted text

toString

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

serialize

public byte[] serialize()
                 throws SerializationException
Serialize the current message

Specified by:
serialize in interface IModelChangeMessage
Returns:
byte [] that is serialized representation of this model change message.
Throws:
SerializationException - if this model change message cannot be serialized.

getAdapter

public java.lang.Object getAdapter(java.lang.Class adapter)
Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable

applyToModel

public void applyToModel(java.lang.Object model)
                  throws ModelUpdateException
Description copied from interface: IModelChange
Apply the change to a model. Clients may use this method to apply the change to a model of appropriate type (e.g. IDocument for IDocumentChange).

Specified by:
applyToModel in interface IModelChange
Parameters:
model - the model to apply this change to. Must not be null. Should be of type appropriate to the model.
Throws:
ModelUpdateException - thrown if model is null, of incorrect type, or cannot be changed.