class PDDocumentNameDictionary implements COSObjectable
{
    private final COSDictionary nameDictionary;
    private final PDDocumentCatalog catalog;

    /**
     * Constructor.
     *
     * @param cat The document catalog that this dictionary is part of.
     */
    public PDDocumentNameDictionary( PDDocumentCatalog cat )
    {
        COSDictionary names = cat.getCOSObject().getCOSDictionary(COSName.NAMES);
        if (names == null)
        {
            names = new COSDictionary();
            cat.getCOSObject().setItem(COSName.NAMES, names);
        }
        nameDictionary = names;
        catalog = cat;
    }

    /**
     * Constructor.
     *
     * @param cat The document that this dictionary is part of.
     * @param names The names dictionary.
     */
    public PDDocumentNameDictionary( PDDocumentCatalog cat, COSDictionary names )
    {
        catalog = cat;
        nameDictionary = names;
    }

    /**
     * Convert this standard java object to a COS object.
     *
     * @return The cos dictionary for this object.
     */
    @Override
    public COSDictionary getCOSObject()
    {
        return nameDictionary;
    }

    /**
     * Get the destination named tree node. The values in this name tree will be
     * PDPageDestination objects.
     *
     * @return The destination name tree node.
     */
    public PDDestinationNameTreeNode getDests()
    {<FILL_FUNCTION_BODY>}

    /**
     * Set the named destinations that are associated with this document.
     *
     * @param dests The destination names.
     */
    public void setDests( PDDestinationNameTreeNode dests )
    {
        nameDictionary.setItem( COSName.DESTS, dests );
        //The dests can either be in the document catalog or in the
        //names dictionary, PDFBox will just maintain the one in the
        //names dictionary for now unless there is a reason to do
        //something else.
        //clear the potentially out of date Dests reference.
        catalog.getCOSObject().setItem( COSName.DESTS, (COSObjectable)null);
    }

    /**
     * Get the embedded files named tree node. The values in this name tree will
     * be PDComplexFileSpecification objects.
     *
     * @return The embedded files name tree node.
     */
    public PDEmbeddedFilesNameTreeNode getEmbeddedFiles()
    {
        COSDictionary dic = nameDictionary.getCOSDictionary(COSName.EMBEDDED_FILES);
        return dic != null ? new PDEmbeddedFilesNameTreeNode(dic) : null;
    }

    /**
     * Set the named embedded files that are associated with this document.
     *
     * @param ef The new embedded files
     */
    public void setEmbeddedFiles( PDEmbeddedFilesNameTreeNode ef )
    {
        nameDictionary.setItem( COSName.EMBEDDED_FILES, ef );
    }

    /**
     * Get the document level JavaScript name tree. When the document is opened, all the JavaScript
     * actions in it shall be executed, defining JavaScript functions for use by other scripts in
     * the document.
     *
     * @return The document level JavaScript name tree.
     */
    public PDJavascriptNameTreeNode getJavaScript()
    {
        COSDictionary dic = nameDictionary.getCOSDictionary(COSName.JAVA_SCRIPT);
        return dic != null ? new PDJavascriptNameTreeNode(dic) : null;
    }

    /**
     * Set the named javascript entries that are associated with this document.
     *
     * @param js The new Javascript entries.
     */
    public void setJavascript( PDJavascriptNameTreeNode js )
    {
        nameDictionary.setItem( COSName.JAVA_SCRIPT, js );
    }
}

        COSDictionary dic = nameDictionary.getCOSDictionary(COSName.DESTS);
        //The document catalog also contains the Dests entry sometimes
        //so check there as well.
        if( dic == null )
        {
            dic = catalog.getCOSObject().getCOSDictionary(COSName.DESTS);
        }
        return dic != null ? new PDDestinationNameTreeNode(dic) : null;
    
<no_super_class>