public class DiffMatchPatchServerSynchronizer extends Object implements ServerSynchronizer<String,DiffMatchPatchEdit>
ServerSynchronizer
implementation that can handle text documents.Constructor and Description |
---|
DiffMatchPatchServerSynchronizer() |
DiffMatchPatchServerSynchronizer(DiffMatchPatch diffMatchPatch) |
Modifier and Type | Method and Description |
---|---|
DiffMatchPatchEdit |
clientDiff(Document<String> document,
ShadowDocument<String> shadowDocument)
Is called to produce an
Edit of changes coming from a client. |
PatchMessage<DiffMatchPatchEdit> |
createPatchMessage(String documentId,
String clientId,
Queue<DiffMatchPatchEdit> edits)
Creates a new
PatchMessage with the with the type of Edit that this
synchronizer can handle. |
Document<String> |
documentFromJson(com.fasterxml.jackson.databind.JsonNode json)
Converts the
JsonNode into a Document instance. |
Document<String> |
patchDocument(DiffMatchPatchEdit edit,
Document<String> document)
Called when the document should be patched.
|
PatchMessage<DiffMatchPatchEdit> |
patchMessageFromJson(String json)
Creates a {link PatchMessage} by parsing the passed-in json.
|
ShadowDocument<String> |
patchShadow(DiffMatchPatchEdit edit,
ShadowDocument<String> shadowDocument)
Called when the shadow should be patched.
|
DiffMatchPatchEdit |
serverDiff(Document<String> document,
ShadowDocument<String> shadowDocument)
The first step in a sync is to produce a an edit for the changes.
|
public DiffMatchPatchServerSynchronizer()
public DiffMatchPatchServerSynchronizer(DiffMatchPatch diffMatchPatch)
public DiffMatchPatchEdit clientDiff(Document<String> document, ShadowDocument<String> shadowDocument)
ServerSynchronizer
Edit
of changes coming from a client.clientDiff
in interface ServerSynchronizer<String,DiffMatchPatchEdit>
document
- the server side document .shadowDocument
- the document shadow containing the client changes.Edit
the edit representing the diff between the document and it's shadow document.public DiffMatchPatchEdit serverDiff(Document<String> document, ShadowDocument<String> shadowDocument)
ServerSynchronizer
serverDiff
in interface ServerSynchronizer<String,DiffMatchPatchEdit>
document
- the document containingshadowDocument
- the document shadow.Edit
the edit representing the diff between the document and it's shadow document.public ShadowDocument<String> patchShadow(DiffMatchPatchEdit edit, ShadowDocument<String> shadowDocument)
ServerSynchronizer
patchShadow
in interface ServerSynchronizer<String,DiffMatchPatchEdit>
edit
- The edits.shadowDocument
- the ShadowDocument
to patchShadowDocument
a new patched shadow document.public Document<String> patchDocument(DiffMatchPatchEdit edit, Document<String> document)
ServerSynchronizer
patchDocument
in interface ServerSynchronizer<String,DiffMatchPatchEdit>
edit
- the edit to use to path the documentdocument
- the document to be patched.Document
a new patched document.public PatchMessage<DiffMatchPatchEdit> createPatchMessage(String documentId, String clientId, Queue<DiffMatchPatchEdit> edits)
ServerSynchronizer
PatchMessage
with the with the type of Edit
that this
synchronizer can handle.createPatchMessage
in interface ServerSynchronizer<String,DiffMatchPatchEdit>
documentId
- the document identifier for the PatchMessage
clientId
- the client identifier for the PatchMessage
edits
- the Edit
s for the PatchMessage
PatchMessage
the created {code PatchMessage}public PatchMessage<DiffMatchPatchEdit> patchMessageFromJson(String json)
ServerSynchronizer
patchMessageFromJson
in interface ServerSynchronizer<String,DiffMatchPatchEdit>
json
- the json representation of a PatchMessage
PatchMessage
the created {code PatchMessage}public Document<String> documentFromJson(com.fasterxml.jackson.databind.JsonNode json)
ServerSynchronizer
JsonNode
into a Document
instance.documentFromJson
in interface ServerSynchronizer<String,DiffMatchPatchEdit>
json
- the JsonNode
to convertDocument
the document representing the contents of the JsonNode
instance.Copyright © 2015 JBoss by Red Hat. All Rights Reserved.