Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-10-16 04:32:39 -0400
committerslewis2008-10-16 04:32:39 -0400
commit6923bd04eab574317cd333a28c09f1940fa93c39 (patch)
treea5e99ff8f6a3320107eba97bb18ae8751f5e61da /framework/bundles/org.eclipse.ecf.sync
parent1e9a7e64daff7250e8de7cc707a331e4e49cd1fd (diff)
downloadorg.eclipse.ecf-6923bd04eab574317cd333a28c09f1940fa93c39.tar.gz
org.eclipse.ecf-6923bd04eab574317cd333a28c09f1940fa93c39.tar.xz
org.eclipse.ecf-6923bd04eab574317cd333a28c09f1940fa93c39.zip
Added new test code and fixed issue with serialization of DocumentUpdateMessage
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.sync')
-rw-r--r--framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java23
-rw-r--r--framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java9
2 files changed, 20 insertions, 12 deletions
diff --git a/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java b/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java
index e7bbfd6a5..358bff8d3 100644
--- a/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java
+++ b/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/internal/sync/doc/cola/ColaDocumentChangeMessage.java
@@ -27,7 +27,8 @@ public class ColaDocumentChangeMessage extends DocumentChangeMessage {
// hashCode, i.e. make comparable
private final long localOperationsCount;
private final long remoteOperationsCount;
- private final ColaTransformationStrategy trafoStrat;
+ private final int transformType;
+
private boolean splitUp;
private List splitUpRepresentation;
@@ -39,16 +40,16 @@ public class ColaDocumentChangeMessage extends DocumentChangeMessage {
this.splitUpRepresentation = new LinkedList();
if (super.getLengthOfReplacedText() == 0) {
// this is neither a replacement, nor a deletion
- trafoStrat = ColaInsertionTransformationStategy.getInstance();
+ transformType = 0;
} else {
if (super.getText().length() == 0) {
// something has been replaced, nothing inserted, must be a
// deletion
- trafoStrat = ColaDeletionTransformationStrategy.getInstance();
+ transformType = 1;
} else {
// something has been replaced with some new input, has to be a
// replacement op
- trafoStrat = ColaReplacementTransformationStategy.getInstance();
+ transformType = 2;
//TODO this has not been implemented yet
//throw new IllegalArgumentException("Replacement Handling not implemented yet! Known Bug.");
}
@@ -56,15 +57,15 @@ public class ColaDocumentChangeMessage extends DocumentChangeMessage {
}
public boolean isInsertion() {
- return (this.trafoStrat instanceof ColaInsertionTransformationStategy);
+ return (transformType == 0);
}
public boolean isDeletion() {
- return (this.trafoStrat instanceof ColaDeletionTransformationStrategy);
+ return (transformType == 1);
}
public boolean isReplacement() {
- return (this.trafoStrat instanceof ColaReplacementTransformationStategy);
+ return (transformType == 2);
}
public long getLocalOperationsCount() {
@@ -75,9 +76,15 @@ public class ColaDocumentChangeMessage extends DocumentChangeMessage {
return this.remoteOperationsCount;
}
+ private ColaTransformationStrategy getTransformationStrategy() {
+ if (isInsertion()) return ColaInsertionTransformationStategy.getInstance();
+ if (isDeletion()) return ColaDeletionTransformationStrategy.getInstance();
+ return ColaReplacementTransformationStategy.getInstance();
+ }
+
public ColaDocumentChangeMessage transformAgainst(ColaDocumentChangeMessage localMsg, boolean localMsgHighPrio) {
Trace.entering(Activator.PLUGIN_ID, SyncDebugOptions.METHODS_ENTERING, this.getClass(), "transformAgainst", localMsg); //$NON-NLS-1$
- final ColaDocumentChangeMessage transformedMsg = trafoStrat.getOperationalTransform(this, localMsg, localMsgHighPrio);
+ final ColaDocumentChangeMessage transformedMsg = getTransformationStrategy().getOperationalTransform(this, localMsg, localMsgHighPrio);
Trace.entering(Activator.PLUGIN_ID, SyncDebugOptions.METHODS_EXITING, this.getClass(), "transformAgainst", transformedMsg); //$NON-NLS-1$
return transformedMsg;
}
diff --git a/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java b/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java
index f2db9789d..9a6581770 100644
--- a/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java
+++ b/framework/bundles/org.eclipse.ecf.sync/src/org/eclipse/ecf/sync/doc/DocumentChangeMessage.java
@@ -17,6 +17,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.Serializable;
import org.eclipse.ecf.sync.IModelChangeMessage;
import org.eclipse.ecf.sync.SerializationException;
@@ -24,7 +25,7 @@ import org.eclipse.ecf.sync.SerializationException;
/**
*
*/
-public class DocumentChangeMessage implements IDocumentChange, IModelChangeMessage {
+public class DocumentChangeMessage implements IDocumentChange, IModelChangeMessage, Serializable {
private static final long serialVersionUID = -3195542805471664496L;
@@ -38,9 +39,9 @@ public class DocumentChangeMessage implements IDocumentChange, IModelChangeMessa
}
}
- final String text;
- int offset;
- int length;
+ private String text;
+ private int offset;
+ private int length;
public DocumentChangeMessage(int offset, int length, String text) {
this.offset = offset;

Back to the top