Package ro.sync.ecss.extensions.api.node
Class AuthorDocumentFragment
- java.lang.Object
-
- ro.sync.ecss.extensions.api.node.AuthorDocumentFragment
-
@API(type=NOT_EXTENDABLE, src=PUBLIC) public class AuthorDocumentFragment extends java.lang.Object
Represents a fragment of an XML document. It holds a copy of the content of a document fragment. A change in the fragment does not change the edited document. For changing the edited document use insert methods ofAuthorDocumentController
.
For the following XML code fragment:
accounting<person><name>John W.</name><email>john@gmail.com</email></person><person><name>Mary B.</name><email>mary@msn.com</email></person>
the corresponding document fragment structure can be represented as:
The image represents the content of the fragment and the red markers represent special control characters which are used to point to the start and the end offsets of the fragment containing nodes.
-
-
Constructor Summary
Constructors Constructor Description AuthorDocumentFragment(Content content, java.util.List<AuthorNode> elements, int leftSplits, int righSplits)
Constructor.AuthorDocumentFragment(Content content, java.util.List<AuthorNode> elements, int leftSplits, int righSplits, java.util.List<AuthorPersistentHighlight> changeMarkers, java.util.List<AuthorPersistentHighlight> commentMarkers)
Constructor.AuthorDocumentFragment(Content content, java.util.List<AuthorNode> elements, int leftSplits, int righSplits, java.util.List<AuthorPersistentHighlight> changeMarkers, java.util.List<AuthorPersistentHighlight> commentMarkers, java.util.Map<AuthorElement,java.util.LinkedHashMap<java.lang.String,AuthorPersistentHighlight>> attributesChanges)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthorDocumentFragment
clone()
Clone a fragment.boolean
containsSimpleText()
Check if an author document fragment content contains simple text.int
getAcceptedLength()
java.util.Map<AuthorElement,java.util.LinkedHashMap<java.lang.String,AuthorPersistentHighlight>>
getAttributesChangeHighlights()
Get the map of attribute changes in the fragment.java.util.List<AuthorPersistentHighlight>
getChangeHighlights()
Returns the list with the fragment change tracking highlights.java.util.List<AuthorPersistentHighlight>
getCommentsAndCustomHighlights()
Returns the list with the fragment comment highlights or custom highlights.Content
getContent()
java.util.List<AuthorNode>
getContentNodes()
Get the list of the first-level nodes contained in this Author document fragment.int
getLeftSplits()
This method is intended for internal use only.int
getLength()
int
getRightSplits()
This method is intended for internal use only.int
getSuggestedRelativeCaretOffset()
Get the offset were the caret should be placed, relative to the beginning of the fragment.boolean
isEmpty()
void
setAttributesChanges(java.util.Map<AuthorElement,java.util.LinkedHashMap<java.lang.String,AuthorPersistentHighlight>> attributesChanges)
Set the map of element to attribute changes.void
setChangeHighlights(java.util.List<AuthorPersistentHighlight> markers)
This class is intended for internal use only.
Set the list with the change tracking highlights.void
setCommentAndCustomHighlights(java.util.List<AuthorPersistentHighlight> highlights)
This class is intended for internal use only.
Set the list with the fragment comment highlights or custom highlights.void
setContentNodes(java.util.List<AuthorNode> nodes)
Set the content nodes.void
setLeftSplits(int leftSplits)
This method is intended for internal use only.
Set the number of the elements the fragment splits to the left.void
setRighSplits(int righSplits)
This method is intended for internal use only.
Set the number of the elements the fragment splits to the right.void
setSuggestedRelativeCaretOffset(int suggestedRelativeCaretOffset)
Set the offset were the caret should be placed, relative to the beginning of the fragment.java.lang.String
toString()
-
-
-
Constructor Detail
-
AuthorDocumentFragment
public AuthorDocumentFragment(Content content, java.util.List<AuthorNode> elements, int leftSplits, int righSplits)
Constructor.- Parameters:
content
- TheContent
holding the fragment's content.elements
- Elements that make up this fragment.leftSplits
- Number of elements it splits to the left.righSplits
- Number of elements it splits to the right.
-
AuthorDocumentFragment
public AuthorDocumentFragment(Content content, java.util.List<AuthorNode> elements, int leftSplits, int righSplits, java.util.List<AuthorPersistentHighlight> changeMarkers, java.util.List<AuthorPersistentHighlight> commentMarkers)
Constructor.- Parameters:
content
- TheContent
holding the fragment's content.elements
- Elements that make up this fragment.leftSplits
- Number of elements it splits to the left.righSplits
- Number of elements it splits to the right.changeMarkers
- The list of change markerscommentMarkers
- Comment markers
-
AuthorDocumentFragment
public AuthorDocumentFragment(Content content, java.util.List<AuthorNode> elements, int leftSplits, int righSplits, java.util.List<AuthorPersistentHighlight> changeMarkers, java.util.List<AuthorPersistentHighlight> commentMarkers, java.util.Map<AuthorElement,java.util.LinkedHashMap<java.lang.String,AuthorPersistentHighlight>> attributesChanges)
Constructor.- Parameters:
content
- TheContent
holding the fragment's content.elements
- Elements that make up this fragment.leftSplits
- Number of elements it splits to the left.righSplits
- Number of elements it splits to the right.changeMarkers
- The list of change markerscommentMarkers
- Comment markersattributesChanges
- The map of attribute changes.
-
-
Method Detail
-
getAcceptedLength
public int getAcceptedLength()
- Returns:
- The number of characters, including sentinels (element start and end markers), present in the fragment. If there are delete change markers, they are treated as accepted
-
getLength
public int getLength()
- Returns:
- The number of characters, including sentinels (element start and end markers), present in the fragment.
-
getContentNodes
public java.util.List<AuthorNode> getContentNodes()
Get the list of the first-level nodes contained in this Author document fragment. Each of thisAuthorNode
can contain another nodes (the Author nodes model is similar with the DOM model).- Returns:
- The nodes that make up this fragment.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
getLeftSplits
public int getLeftSplits()
This method is intended for internal use only.- Returns:
- Number of nodes the fragment splits to the left.
-
getRightSplits
public int getRightSplits()
This method is intended for internal use only.- Returns:
- Number of nodes the fragment splits to the right.
-
setLeftSplits
public void setLeftSplits(int leftSplits)
This method is intended for internal use only.
Set the number of the elements the fragment splits to the left.- Parameters:
leftSplits
- The left splits count.
-
setRighSplits
public void setRighSplits(int righSplits)
This method is intended for internal use only.
Set the number of the elements the fragment splits to the right.- Parameters:
righSplits
- The right splits count.
-
getChangeHighlights
public java.util.List<AuthorPersistentHighlight> getChangeHighlights()
Returns the list with the fragment change tracking highlights.
If the fragment is created when change tracking is turned OFF and the fragment contains Track Changes, then the returned list will contain the changes which intersected the fragment region, made relative to the fragment content.
If the fragment is created when change tracking in turned ON then the fragment will contain the selection with all changes accepted (so the list will be alwaysNULL
).
To get the list with all change tracking highlights from the document use theChangeTrackingController.getChangeHighlights()
method.- Returns:
- Returns list with the fragment change tracking highlights.
The start and end offset of the returned change tracking highlights are relative to the start offset of this document fragment.
The type of the highlights can be one ofAuthorPersistentHighlight.PersistentHighlightType.CHANGE_INSERT
orAuthorPersistentHighlight.PersistentHighlightType.CHANGE_DELETE
- Since:
- 12
-
getAttributesChangeHighlights
public java.util.Map<AuthorElement,java.util.LinkedHashMap<java.lang.String,AuthorPersistentHighlight>> getAttributesChangeHighlights()
Get the map of attribute changes in the fragment. Can benull
. Each element can have one or more attribute changes.- Returns:
- Returns the attributesChangeTracking.
- Since:
- 15.1
-
getCommentsAndCustomHighlights
public java.util.List<AuthorPersistentHighlight> getCommentsAndCustomHighlights()
Returns the list with the fragment comment highlights or custom highlights.
If the fragment contains comments or custom highlights then the returned list will contain the comments which intersected the fragment, made relative to the fragment content.
To get the list with all the comments or persistent highlights from the document see theAuthorReviewController.getCommentHighlights()
andAuthorPersistentHighlighter.getHighlights()
methods.- Returns:
- Returns the fragment comment highlights or custom highlights list.
The type for a returned
AuthorPersistentHighlight
can beAuthorPersistentHighlight.PersistentHighlightType.COMMENT
orAuthorPersistentHighlight.PersistentHighlightType.CUSTOM_HIGHLIGHT
. The custom highlights can be inserted and managed by using theAuthorPersistentHighlighter
. - Since:
- 12
-
setCommentAndCustomHighlights
public void setCommentAndCustomHighlights(java.util.List<AuthorPersistentHighlight> highlights)
This class is intended for internal use only.
Set the list with the fragment comment highlights or custom highlights.- Parameters:
highlights
- The comment highlights or custom highlights list.- Since:
- 12
-
setChangeHighlights
public void setChangeHighlights(java.util.List<AuthorPersistentHighlight> markers)
This class is intended for internal use only.
Set the list with the change tracking highlights.- Parameters:
markers
- The change tracking highlights list.- Since:
- 12
-
setAttributesChanges
public void setAttributesChanges(java.util.Map<AuthorElement,java.util.LinkedHashMap<java.lang.String,AuthorPersistentHighlight>> attributesChanges)
Set the map of element to attribute changes.- Parameters:
attributesChanges
- The map between element and attribute changes- Since:
- 15.1
-
isEmpty
public boolean isEmpty()
- Returns:
true
If the fragment is empty.
-
containsSimpleText
public boolean containsSimpleText()
Check if an author document fragment content contains simple text.- Returns:
True
if the content of the given author document fragment contains simple text (the whitespaces are ignored).
-
clone
public AuthorDocumentFragment clone() throws java.lang.CloneNotSupportedException
Clone a fragment.- Overrides:
clone
in classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
- Since:
- 21.1
- See Also:
Object.clone()
-
setSuggestedRelativeCaretOffset
public void setSuggestedRelativeCaretOffset(int suggestedRelativeCaretOffset)
Set the offset were the caret should be placed, relative to the beginning of the fragment.- Parameters:
suggestedRelativeCaretOffset
- The offset relative to the beginning of the fragment.- Since:
- 23
-
getSuggestedRelativeCaretOffset
public int getSuggestedRelativeCaretOffset()
Get the offset were the caret should be placed, relative to the beginning of the fragment.- Returns:
- Returns the offset.
- Since:
- 23
-
setContentNodes
public void setContentNodes(java.util.List<AuthorNode> nodes)
Set the content nodes.- Parameters:
nodes
- The content nodes
-
-