Package de.unirostock.sems.bives.ds
Class Patch
- java.lang.Object
-
- de.unirostock.sems.bives.ds.Patch
-
public class Patch extends Object
The Class Patch storing all operations necessary to transfer one document into another.- Author:
- Martin Scharm
- See Also:
- delta documentation
-
-
Field Summary
Fields Modifier and Type Field Description static URI
PATCH_FILE_NAME
The default file name of the path.
-
Constructor Summary
Constructors Constructor Description Patch()
Instantiates a new patch.Patch(boolean fullDiff)
Instantiates a new patch specifying the fullDiff flag.Patch(boolean fullDiff, DiffAnnotator diffAnnotator)
Instantiates a new patch specifying the fullDiff flag and an annotator to annotate the differences.Patch(boolean fullDiff, URI patchFileName)
Instantiates a new patch specifying the fullDiff flag and the file name of the resulting patch.Patch(boolean fullDiff, URI patchFileName, DiffAnnotator diffAnnotator)
Instantiates a new patch specifying the fullDiff flag, the file name of the resulting patch, and an annotator to annotate the differences.Patch(DiffAnnotator diffAnnotator)
Instantiates a new patch specifying.Patch(URI patchFileName)
Instantiates a new patch specifying the file name of the resulting patch.Patch(URI patchFileName, DiffAnnotator diffAnnotator)
Instantiates a new patch specifying the file name of the resulting patch and an annotator to annotate the differences.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
annotatePatch()
Annotate the whole patch.void
deleteNode(de.unirostock.sems.xmlutils.ds.TreeNode toDelete, int chainId)
Delete a single node.void
deleteSubtree(de.unirostock.sems.xmlutils.ds.TreeNode toDelete, int chainId)
Mark a whole subtree as deleted.String
getAnnotationDocumentXml()
Gets the annotation document encoded in XML.de.unirostock.sems.comodi.ChangeFactory
getAnnotations()
Gets the actual annotations.org.jdom2.Element
getDeletes()
Gets the deletes.org.jdom2.Document
getDocument()
Gets the document containing all changes.org.jdom2.Document
getDocument(boolean inclAnnotations)
Gets the document containing all changes.org.jdom2.Element
getInserts()
Gets the inserts.org.jdom2.Element
getMoves()
Gets the moves.int
getNumAnnotations()
Gets the number of annotations for the differences in this patch.int
getNumAttributeChanges()
Gets the number of attribute changes.int
getNumDeletes()
Gets the number of stored delete operations.int
getNumInserts()
Gets the number of stored insert operations.int
getNumMoves()
Gets the number of stored move operations.int
getNumNodeChanges()
Gets the number of node changes.int
getNumTextChanges()
Gets the number of text changes.int
getNumUpdates()
Gets the number of stored update operations.org.jdom2.Element
getUpdates()
Gets the updates.int
insertNode(de.unirostock.sems.xmlutils.ds.DocumentNode toInsert, int chainId)
Insert a single node.void
insertNode(de.unirostock.sems.xmlutils.ds.TreeNode toInsert, int chainId)
Insert a single node.void
insertSubtree(de.unirostock.sems.xmlutils.ds.TreeNode toInsert, int chainId)
Mark a whole subtree as inserted.void
updateNode(NodeConnection c, SimpleConnectionManager conMgmt)
Update a node.
-
-
-
Field Detail
-
PATCH_FILE_NAME
public static URI PATCH_FILE_NAME
The default file name of the path. This name will be used in the annotations to refer to elements in the path file.
-
-
Constructor Detail
-
Patch
public Patch(URI patchFileName, DiffAnnotator diffAnnotator)
Instantiates a new patch specifying the file name of the resulting patch and an annotator to annotate the differences. This will result in a patch of type fullDiff.- Parameters:
patchFileName
- the file name of the final patchdiffAnnotator
- the annotator for detected differences- See Also:
- fullDiff documentation
-
Patch
public Patch(DiffAnnotator diffAnnotator)
Instantiates a new patch specifying. an annotator to annotate the differences. This constructor assumes that the final patch will be calledPATCH_FILE_NAME
. This will result in a patch of type fullDiff.- Parameters:
diffAnnotator
- the annotator for detected differences- See Also:
- fullDiff documentation
-
Patch
public Patch(boolean fullDiff, URI patchFileName, DiffAnnotator diffAnnotator)
Instantiates a new patch specifying the fullDiff flag, the file name of the resulting patch, and an annotator to annotate the differences. If the fullDiff flag is set to false only a partially delta will be generated. Thus, the delta will briefly describe the modifications, but cannot be used to transform one version of a document into the other. Set it to true to obtain a full delta.- Parameters:
fullDiff
- the fullDiff flagpatchFileName
- the file name of the final patchdiffAnnotator
- the annotator for detected differences- See Also:
- fullDiff documentation
-
Patch
public Patch(boolean fullDiff, DiffAnnotator diffAnnotator)
Instantiates a new patch specifying the fullDiff flag and an annotator to annotate the differences. If the fullDiff flag is set to false only a partial delta will be generated. Thus, the delta will briefly describe the modifications, but cannot be used to transform one version of a document into the other. Set it to true to obtain a full delta. This constructor assumes that the final patch will be calledPATCH_FILE_NAME
.- Parameters:
fullDiff
- the fullDiff flagdiffAnnotator
- the annotator for detected differences- See Also:
- fullDiff documentation
-
Patch
public Patch(URI patchFileName)
Instantiates a new patch specifying the file name of the resulting patch. This constructor assumes that the final patch will be calledPATCH_FILE_NAME
. To annotate the differences a new instance of theDefaultDiffAnnotator
will be created. This will result in a patch of type fullDiff.- Parameters:
patchFileName
- the file name of the final patch- See Also:
- fullDiff documentation
-
Patch
public Patch()
Instantiates a new patch. This constructor assumes that the final patch will be calledPATCH_FILE_NAME
. To annotate the differences a new instance of theDefaultDiffAnnotator
will be created. This will result in a patch of type fullDiff.- See Also:
- fullDiff documentation
-
Patch
public Patch(boolean fullDiff, URI patchFileName)
Instantiates a new patch specifying the fullDiff flag and the file name of the resulting patch. If the fullDiff flag is set to false only a partial delta will be generated. Thus, the delta will briefly describe the modifications, but cannot be used to transform one version of a document into the other. Set it to true to obtain a full delta. To annotate the differences a new instance of theDefaultDiffAnnotator
will be created.- Parameters:
fullDiff
- the fullDiff flagpatchFileName
- the file name of the final patch- See Also:
- fullDiff documentation
-
Patch
public Patch(boolean fullDiff)
Instantiates a new patch specifying the fullDiff flag. If the fullDiff flag is set to false only a partial delta will be generated. Thus, the delta will briefly describe the modifications, but cannot be used to transform one version of a document into the other. Set it to true to obtain a full delta. This constructor assumes that the final patch will be calledPATCH_FILE_NAME
. To annotate the differences a new instance of theDefaultDiffAnnotator
will be created.- Parameters:
fullDiff
- the fullDiff flag- See Also:
- fullDiff documentation
-
-
Method Detail
-
getNumMoves
public int getNumMoves()
Gets the number of stored move operations.- Returns:
- the number of moves
-
getNumUpdates
public int getNumUpdates()
Gets the number of stored update operations.- Returns:
- the number of updates
-
getNumDeletes
public int getNumDeletes()
Gets the number of stored delete operations.- Returns:
- the number of deletes
-
getNumInserts
public int getNumInserts()
Gets the number of stored insert operations.- Returns:
- the number of inserts
-
getDeletes
public org.jdom2.Element getDeletes()
Gets the deletes.- Returns:
- the deletes
-
getInserts
public org.jdom2.Element getInserts()
Gets the inserts.- Returns:
- the inserts
-
getUpdates
public org.jdom2.Element getUpdates()
Gets the updates.- Returns:
- the updates
-
getMoves
public org.jdom2.Element getMoves()
Gets the moves.- Returns:
- the moves
-
getNumNodeChanges
public int getNumNodeChanges()
Gets the number of node changes. That is the number of differences in this patch that affect XML nodes.- Returns:
- the number of node changes
-
getNumTextChanges
public int getNumTextChanges()
Gets the number of text changes. That is the number of differences in this patch that affect XML text nodes.- Returns:
- the number of text changes
-
getNumAttributeChanges
public int getNumAttributeChanges()
Gets the number of attribute changes. That is the number of differences in this patch that affect XML attributes.- Returns:
- the number of attribute changes
-
getDocument
public org.jdom2.Document getDocument(boolean inclAnnotations)
Gets the document containing all changes. IfinclAnnotations
is set to true the patch will have an embedded RDF subtree with annotations of the differences.- Parameters:
inclAnnotations
- should the annotations be embedded into the patch- Returns:
- the document
-
getNumAnnotations
public int getNumAnnotations()
Gets the number of annotations for the differences in this patch.- Returns:
- the number annotations
-
getDocument
public org.jdom2.Document getDocument()
Gets the document containing all changes.- Returns:
- the document
-
getAnnotationDocumentXml
public String getAnnotationDocumentXml()
Gets the annotation document encoded in XML.- Returns:
- the annotation document
-
getAnnotations
public de.unirostock.sems.comodi.ChangeFactory getAnnotations()
Gets the actual annotations.- Returns:
- the annotations
-
deleteSubtree
public void deleteSubtree(de.unirostock.sems.xmlutils.ds.TreeNode toDelete, int chainId)
Mark a whole subtree as deleted.- Parameters:
toDelete
- the node rooting the subtree to deletechainId
- the chain id: id of the trigger, if this modification was triggered, or <1 otherwise
-
deleteNode
public void deleteNode(de.unirostock.sems.xmlutils.ds.TreeNode toDelete, int chainId)
Delete a single node.- Parameters:
toDelete
- the node to deletechainId
- the chain id: id of the trigger, if this modification was triggered, or <1 otherwise
-
insertSubtree
public void insertSubtree(de.unirostock.sems.xmlutils.ds.TreeNode toInsert, int chainId)
Mark a whole subtree as inserted.- Parameters:
toInsert
- the node rooting the subtree to insertchainId
- the chain id: id of the trigger, if this modification was triggered, or <1 otherwise
-
insertNode
public void insertNode(de.unirostock.sems.xmlutils.ds.TreeNode toInsert, int chainId)
Insert a single node.- Parameters:
toInsert
- the node to insertchainId
- the chain id: id of the trigger, if this modification was triggered, or <1 otherwise
-
insertNode
public int insertNode(de.unirostock.sems.xmlutils.ds.DocumentNode toInsert, int chainId)
Insert a single node.- Parameters:
toInsert
- the document node to insertchainId
- the chain id: id of the trigger, if this modification was triggered, or <1 otherwise- Returns:
- the id of the insert-operation-node in the XML delta
-
updateNode
public void updateNode(NodeConnection c, SimpleConnectionManager conMgmt)
Update a node.- Parameters:
c
- the connection between the old version of the node and the new version of it.conMgmt
- the connection manager
-
annotatePatch
public void annotatePatch()
Annotate the whole patch.
-
-