class PDPageDestination extends PDDestination
{
    /**
     * Storage for the page destination.
     */
    protected final COSArray array;

    /**
     * Constructor to create empty page destination.
     *
     */
    protected PDPageDestination()
    {
        array = new COSArray();
    }

    /**
     * Constructor to create empty page destination.
     *
     * @param arr A page destination array.
     */
    protected PDPageDestination( COSArray arr )
    {
        array = arr;
    }

    /**
     * This will get the page for this destination. A page destination can either reference a page
     * (for a local destination) or a page number (when doing a remote destination to another PDF).
     * If this object is referencing by page number then this method will return null and
     * {@link #getPageNumber()} should be used.
     *
     * @return The page for this destination.
     */
    public PDPage getPage()
    {<FILL_FUNCTION_BODY>}

    /**
     * Set the page for a local destination. For an external destination, call {@link #setPageNumber(int) setPageNumber(int pageNumber)}.
     *
     * @param page The page for a local destination.
     */
    public void setPage( PDPage page )
    {
        array.set( 0, page );
    }

    /**
     * This will get the page number for this destination. A page destination can either reference a
     * page (for a local destination) or a page number (when doing a remote destination to another
     * PDF). If this object is referencing by page number then this method will return that number,
     * otherwise -1 will be returned.
     *
     * @return The zero-based page number for this destination.
     */
    public int getPageNumber()
    {
        int retval = -1;
        if( !array.isEmpty() )
        {
            COSBase page = array.getObject( 0 );
            if( page instanceof COSNumber )
            {
                retval = ((COSNumber)page).intValue();
            }
        }
        return retval;
    }

    /**
     * Returns the page number for this destination, regardless of whether this is a page number or
     * a reference to a page.
     *
     * @see org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem
     * @return the 0-based page number, or -1 if the destination type is unknown.
     */
    public int retrievePageNumber()
    {
        int retval = -1;
        if (!array.isEmpty())
        {
            COSBase page = array.getObject(0);
            if (page instanceof COSNumber)
            {
                retval = ((COSNumber) page).intValue();
            }
            else if (page instanceof COSDictionary)
            {
                return indexOfPageTree((COSDictionary) page);
            }
        }
        return retval;
    }

    // climb up the page tree up to the top to be able to call PageTree.indexOf for a page dictionary
    private int indexOfPageTree(COSDictionary pageDict)
    {
        COSDictionary parent = pageDict;
        while (true)
        {
            COSDictionary prevParent = parent.getCOSDictionary(COSName.PARENT, COSName.P);
            if (prevParent == null)
            {
                break;
            }
            parent = prevParent;
        }
        if (parent.containsKey(COSName.KIDS)
                && COSName.PAGES.equals(parent.getCOSName(COSName.TYPE)))
        {
            // now parent is the highest pages node
            PDPageTree pages = new PDPageTree(parent);
            return pages.indexOf(new PDPage(pageDict));
        }
        return -1;
    }

    /**
     * Set the page number for a remote destination. For an internal destination, call 
     * {@link #setPage(PDPage) setPage(PDPage page)}.
     *
     * @param pageNumber The page for a remote destination.
     */
    public void setPageNumber( int pageNumber )
    {
        array.set( 0, pageNumber );
    }

    /**
     * Convert this standard java object to a COS object.
     *
     * @return The cos object that matches this Java object.
     */
    @Override
    public COSArray getCOSObject()
    {
        return array;
    }

}

        PDPage retval = null;
        if (!array.isEmpty())
        {
            COSBase page = array.getObject( 0 );
            if( page instanceof COSDictionary )
            {
                retval = new PDPage( (COSDictionary)page );
            }
        }
        return retval;
    
<methods>public non-sealed void <init>() ,public static org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDDestination create(org.apache.pdfbox.cos.COSBase) throws java.io.IOException<variables>