Class AuthorDocumentFragment

java.lang.Object
ro.sync.ecss.extensions.api.node.AuthorDocumentFragment

@API(type=NOT_EXTENDABLE, src=PUBLIC) public class AuthorDocumentFragment extends 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 of 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:

Author document fragment architecture.
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 Details

    • AuthorDocumentFragment

      public AuthorDocumentFragment(Content content, List<AuthorNode> elements, int leftSplits, int righSplits)
      Constructor.
      Parameters:
      content - The Content 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, List<AuthorNode> elements, int leftSplits, int righSplits, List<AuthorPersistentHighlight> changeMarkers, List<AuthorPersistentHighlight> commentMarkers)
      Constructor.
      Parameters:
      content - The Content 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 markers
      commentMarkers - 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 - The Content 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 markers
      commentMarkers - Comment markers
      attributesChanges - The map of attribute changes.
  • Method Details

    • getContent

      public Content getContent()
      Returns:
      the Content object 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

      public List<AuthorNode> getContentNodes()
      Get the list of the first-level nodes contained in this Author document fragment. Each of this AuthorNode can contain another nodes (the Author nodes model is similar with the DOM model).
      Returns:
      The nodes that make up this fragment.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • 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 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 always NULL).

      To get the list with all change tracking highlights from the document use the ChangeTrackingController.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 of AuthorPersistentHighlight.PersistentHighlightType.CHANGE_INSERT or AuthorPersistentHighlight.PersistentHighlightType.CHANGE_DELETE
      Since:
      12
    • getAttributesChangeHighlights

      public Map<AuthorElement,LinkedHashMap<String,AuthorPersistentHighlight>> getAttributesChangeHighlights()
      Get the map of attribute changes in the fragment. Can be null. Each element can have one or more attribute changes.
      Returns:
      Returns the attributesChangeTracking.
      Since:
      15.1
    • getCommentsAndCustomHighlights

      public 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 the AuthorReviewController.getCommentHighlights() and AuthorPersistentHighlighter.getHighlights() methods.
      Returns:
      Returns the fragment comment highlights or custom highlights list. The type for a returned AuthorPersistentHighlight can be AuthorPersistentHighlight.PersistentHighlightType.COMMENT or AuthorPersistentHighlight.PersistentHighlightType.CUSTOM_HIGHLIGHT. The custom highlights can be inserted and managed by using the AuthorPersistentHighlighter.
      Since:
      12
    • setCommentAndCustomHighlights

      public void setCommentAndCustomHighlights(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(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(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:
      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

      Clone a fragment.
      Overrides:
      clone in class Object
      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

      public void setContentNodes(List<AuthorNode> nodes)
      Set the content nodes.
      Parameters:
      nodes - The content nodes