BookmarkData (Apache FOP 2.7 API)
Date: 2022-01-12

org.apache.fop.area

## Class BookmarkData

- java.lang.Object
- - org.apache.fop.area.AbstractOffDocumentItem
  - - org.apache.fop.area.BookmarkData

- All Implemented Interfaces:
    OffDocumentItem, Resolvable

      public class BookmarkData
      extends AbstractOffDocumentItem
      implements Resolvable

  An instance of this class is either a PDF bookmark-tree and its child bookmark-items, or a bookmark-item and the child child bookmark-items under it.

- - ### Field Summary

    - ### Fields inherited from class org.apache.fop.area.AbstractOffDocumentItem

      `AFTER_PAGE, END_OF_DOC, IMMEDIATELY, START_OF_DOC, whenToProcess`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BookmarkData()` Create a new bookmark data root object.
    `BookmarkData(Bookmark bookmark)` Create a new pdf bookmark data object.
    `BookmarkData(BookmarkTree bookmarkTree)` Create a new bookmark data object.
    `BookmarkData(java.lang.String title, boolean showChildren, PageViewport pv, java.lang.String idRef)` Create a new bookmark data object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addSubData(BookmarkData sub)` Add a child bookmark data object.
    `java.lang.String` | `getBookmarkTitle()` Get the title for this bookmark object.
    `int` | `getCount()` Get the size of child data objects.
    `java.lang.String` | `getIDRef()` Get the idref for this bookmark-item
    `java.lang.String[]` | `getIDRefs()` Get the array of idrefs of this resolvable object.
    `java.lang.String` | `getName()` Return a human-readable name for this ODI (for error messages, etc.)
    `PageViewport` | `getPageViewport()` Get the PageViewport object that this bookmark refers to
    `BookmarkData` | `getSubData(int count)` Get the child data object.
    `boolean` | `isResolved()` Check if this resolvable object has been resolved.
    `void` | `resolveIDRef(java.lang.String id, java.util.List<PageViewport> pages)` Resolve this resolvable object.
    `boolean` | `showChildItems()` Indicator of whether to initially display child bookmarks.

    - ### Methods inherited from class org.apache.fop.area.AbstractOffDocumentItem

      `getWhenToProcess`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BookmarkData

          public BookmarkData(BookmarkTree bookmarkTree)

      Create a new bookmark data object. This should only be called by the bookmark-tree item because it has no idref item that needs to be resolved.
      Parameters:
        `bookmarkTree` - fo:bookmark-tree for this document

    - #### BookmarkData

          public BookmarkData(Bookmark bookmark)

      Create a new pdf bookmark data object. This is used by the bookmark-items to create a data object with a idref. During processing, this idref will be subsequently resolved to a particular PageViewport.
      Parameters:
        `bookmark` - the fo:bookmark object

    - #### BookmarkData

          public BookmarkData()

      Create a new bookmark data root object. This constructor is called by the AreaTreeParser when the <bookmarkTree> element is read from the XML file

    - #### BookmarkData

          public BookmarkData(java.lang.String title,
                              boolean showChildren,
                              PageViewport pv,
                              java.lang.String idRef)

      Create a new bookmark data object. This constructor is called by the AreaTreeParser when a <bookmark> element is read from the XML file.
      Parameters:
        `title` - the bookmark's title
        `showChildren` - whether to initially display the bookmark's children
        `pv` - the target PageViewport
        `idRef` - the target ID

  - ### Method Detail

    - #### getIDRef

          public java.lang.String getIDRef()

      Get the idref for this bookmark-item
      Returns:
        the idref for the bookmark-item

    - #### addSubData

          public void addSubData(BookmarkData sub)

      Add a child bookmark data object. This adds a child bookmark in the bookmark hierarchy.
      Parameters:
        `sub` - the child bookmark data

    - #### getBookmarkTitle

          public java.lang.String getBookmarkTitle()

      Get the title for this bookmark object.
      Returns:
        the bookmark title

    - #### showChildItems

          public boolean showChildItems()

      Indicator of whether to initially display child bookmarks.
      Returns:
        true to initially display child bookmarks, false otherwise

    - #### getCount

          public int getCount()

      Get the size of child data objects.
      Returns:
        the number of child bookmark data

    - #### getSubData

          public BookmarkData getSubData(int count)

      Get the child data object.
      Parameters:
        `count` - the index to get
      Returns:
        the child bookmark data

    - #### getPageViewport

          public PageViewport getPageViewport()

      Get the PageViewport object that this bookmark refers to
      Returns:
        the PageViewport that this bookmark points to

    - #### isResolved

          public boolean isResolved()

      Check if this resolvable object has been resolved. A BookmarkData object is considered resolved once the idrefs for it and for all of its child bookmark-items have been resolved.
      Specified by:
        `isResolved` in interface `Resolvable`
      Returns:
        true if this object has been resolved

    - #### getIDRefs

          public java.lang.String[] getIDRefs()

      Get the array of idrefs of this resolvable object. If this object contains child resolvables that are resolved through this then it should return the idref's of the child also.
      Specified by:
        `getIDRefs` in interface `Resolvable`
      Returns:
        the id references for resolving this object

    - #### resolveIDRef

          public void resolveIDRef(java.lang.String id,
                                   java.util.List<PageViewport> pages)

      Resolve this resolvable object. This resolves the idref of this object and if possible also resolves id references of child elements that have the same id reference. This method allows the Resolvable object to resolve one of its unresolved idrefs with the actual set of PageViewports containing the target ID. The Resolvable object initially identifies to the AreaTreeHandler which idrefs it needs resolved. After the idrefs are resolved, the ATH calls this method to allow the Resolvable object to update itself with the PageViewport information.
      Specified by:
        `resolveIDRef` in interface `Resolvable`
      Parameters:
        `id` - an ID matching one of the Resolvable object's unresolved idref's.
        `pages` - the list of PageViewports with the given ID

    - #### getName

          public java.lang.String getName()

      Return a human-readable name for this ODI (for error messages, etc.)
      Specified by:
        `getName` in interface `OffDocumentItem`
      Specified by:
        `getName` in class `AbstractOffDocumentItem`
      Returns:
        String name of ODI

Copyright 1999-2022 The Apache Software Foundation. All Rights Reserved.