Package ro.sync.ecss.extensions.api.node
Class AuthorDocumentFragment
java.lang.Object
ro.sync.ecss.extensions.api.node.AuthorDocumentFragment
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 of
For the following XML code fragment:
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.
AuthorDocumentController.
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
ConstructorsConstructorDescriptionAuthorDocumentFragment(Content content, List<AuthorNode> elements, int leftSplits, int righSplits) Constructor.AuthorDocumentFragment(Content content, List<AuthorNode> elements, int leftSplits, int righSplits, List<AuthorPersistentHighlight> changeMarkers, List<AuthorPersistentHighlight> commentMarkers) Constructor.AuthorDocumentFragment(Content content, List<AuthorNode> elements, int leftSplits, int righSplits, List<AuthorPersistentHighlight> changeMarkers, List<AuthorPersistentHighlight> commentMarkers, Map<AuthorElement, LinkedHashMap<String, AuthorPersistentHighlight>> attributesChanges) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()Clone a fragment.booleanCheck if an author document fragment content contains simple text.intGet the map of attribute changes in the fragment.Returns the list with the fragment change tracking highlights.Returns the list with the fragment comment highlights or custom highlights.Get the list of the first-level nodes contained in this Author document fragment.intThis method is intended for internal use only.intintThis method is intended for internal use only.intGet the offset were the caret should be placed, relative to the beginning of the fragment.booleanisEmpty()voidsetAttributesChanges(Map<AuthorElement, LinkedHashMap<String, AuthorPersistentHighlight>> attributesChanges) Set the map of element to attribute changes.voidsetChangeHighlights(List<AuthorPersistentHighlight> markers) This class is intended for internal use only.
Set the list with the change tracking highlights.voidsetCommentAndCustomHighlights(List<AuthorPersistentHighlight> highlights) This class is intended for internal use only.
Set the list with the fragment comment highlights or custom highlights.voidsetContentNodes(List<AuthorNode> nodes) Set the content nodes.voidsetLeftSplits(int leftSplits) This method is intended for internal use only.
Set the number of the elements the fragment splits to the left.voidsetRighSplits(int righSplits) This method is intended for internal use only.
Set the number of the elements the fragment splits to the right.voidsetSuggestedRelativeCaretOffset(int suggestedRelativeCaretOffset) Set the offset were the caret should be placed, relative to the beginning of the fragment.toString()
-
Constructor Details
-
AuthorDocumentFragment
public AuthorDocumentFragment(Content content, List<AuthorNode> elements, int leftSplits, int righSplits) Constructor.- Parameters:
content- TheContentholding 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, List<AuthorNode> elements, int leftSplits, int righSplits, List<AuthorPersistentHighlight> changeMarkers, List<AuthorPersistentHighlight> commentMarkers) Constructor.- Parameters:
content- TheContentholding 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, List<AuthorNode> elements, int leftSplits, int righSplits, List<AuthorPersistentHighlight> changeMarkers, List<AuthorPersistentHighlight> commentMarkers, Map<AuthorElement, LinkedHashMap<String, AuthorPersistentHighlight>> attributesChanges) Constructor.- Parameters:
content- TheContentholding 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 Details
-
getContent
- Returns:
- the
Contentobject holding this fragment's content.
-
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
Get the list of the first-level nodes contained in this Author document fragment. Each of thisAuthorNodecan contain another nodes (the Author nodes model is similar with the DOM model).- Returns:
- The nodes that make up this fragment.
-
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
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_INSERTorAuthorPersistentHighlight.PersistentHighlightType.CHANGE_DELETE - Since:
- 12
-
getAttributesChangeHighlights
public Map<AuthorElement,LinkedHashMap<String, getAttributesChangeHighlights()AuthorPersistentHighlight>> 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
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
AuthorPersistentHighlightcan beAuthorPersistentHighlight.PersistentHighlightType.COMMENTorAuthorPersistentHighlight.PersistentHighlightType.CUSTOM_HIGHLIGHT. The custom highlights can be inserted and managed by using theAuthorPersistentHighlighter. - Since:
- 12
-
setCommentAndCustomHighlights
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
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(Map<AuthorElement, LinkedHashMap<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:
trueIf the fragment is empty.
-
containsSimpleText
public boolean containsSimpleText()Check if an author document fragment content contains simple text.- Returns:
Trueif the content of the given author document fragment contains simple text (the whitespaces are ignored).
-
clone
Clone a fragment.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException- Since:
- 21.1
- See Also:
-
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
Set the content nodes.- Parameters:
nodes- The content nodes
-