class PDDocumentNameDestinationDictionary implements COSObjectable
{
    private final COSDictionary nameDictionary;

     /**
     * Constructor.
     *
     * @param dict The dictionary of names and corresponding destinations.
     */
    public PDDocumentNameDestinationDictionary(COSDictionary dict)
    {
        this.nameDictionary = dict;
    }

    /**
     * Convert this standard java object to a COS object.
     *
     * @return The cos dictionary for this object.
     */
    @Override
    public COSDictionary getCOSObject()
    {
        return nameDictionary;
    }
    
    /**
     * Returns the destination corresponding to the parameter.
     *
     * @param name The destination name.
     * @return The destination for that name, or null if there isn't any.
     * 
     * @throws IOException if something goes wrong when creating the destination object.
     */
    public PDDestination getDestination(String name) throws IOException
    {<FILL_FUNCTION_BODY>}

}

        COSBase item = nameDictionary.getDictionaryObject(name);

        // "The value of this entry shall be a dictionary in which each key is a destination name
        // and the corresponding value is either an array defining the destination (...) 
        // or a dictionary with a D entry whose value is such an array."                
        if (item instanceof COSArray)
        {
            return PDDestination.create(item);
        }
        else if (item instanceof COSDictionary)
        {
            COSDictionary dict = (COSDictionary) item;
            if (dict.containsKey(COSName.D))
            {
                return PDDestination.create(dict.getDictionaryObject(COSName.D));
            }
        }
        return null;
    
<no_super_class>