Class 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 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 Detail

      • AuthorDocumentFragment

        public AuthorDocumentFragment​(Content content,
                                      java.util.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,
                                      java.util.List<AuthorNode> elements,
                                      int leftSplits,
                                      int righSplits,
                                      java.util.List<AuthorPersistentHighlight> changeMarkers,
                                      java.util.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,
                                      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 - 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 Detail

      • 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 java.util.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 java.lang.String toString()
        Overrides:
        toString in class java.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 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 java.util.Map<AuthorElement,​java.util.LinkedHashMap<java.lang.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
      • 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 class java.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