* @return reference to annotaiton that was added.
     */
    public Annotation addAnnotation(Annotation newAnnotation) {

        // make sure the page annotations have been initialized.
        if (!isInited) {
            try {
                initPageAnnotations();
            } catch (InterruptedException e) {
                logger.warning("Annotation Initialization interupted");
            }
        }

        StateManager stateManager = library.getStateManager();

        Object annots = library.getObject(entries, ANNOTS_KEY.getName());
        boolean isAnnotAReference = library.isReference(entries, ANNOTS_KEY.getName());

        // does the page not already have an annotations or if the annots
        // dictionary is indirect.  If so we have to add the page to the state
        // manager
        if (!isAnnotAReference && annots != null) {
            // get annots array from page
            if (annots instanceof Vector) {
                // update annots dictionary with new annotations reference,
                Vector v = (Vector) annots;
                v.add(newAnnotation.getPObjectReference());
                // add the page as state change
                stateManager.addChange(
                        new PObject(this, this.getPObjectReference()));
            }
        } else if (isAnnotAReference && annots != null) {
            // get annots array from page
            if (annots instanceof Vector) {
                // update annots dictionary with new annotations reference,
                Vector v = (Vector) annots;
                v.add(newAnnotation.getPObjectReference());
                // add the annotations reference dictionary as state has changed
                stateManager.addChange(
                        new PObject(annots, library.getObjectReference(
                                entries, ANNOTS_KEY.getName())));
            }
        }
        // we need to add the a new annots reference
        else {
            Vector annotsVector = new Vector(4);
            annotsVector.add(newAnnotation.getPObjectReference());

            // create a new Dictionary of annotaions using an external reference
            PObject annotsPObject = new PObject(annotsVector,
                    stateManager.getNewReferencNumber());

            // add the new dictionary to the page
            entries.put(ANNOTS_KEY, annotsPObject.getReference());
            // add it to the library so we can resolve the reference
            library.addObject(annotsVector, annotsPObject.getReference());

            // add the page and the new dictionary to the state change
            stateManager.addChange(
                    new PObject(this, this.getPObjectReference()));
            stateManager.addChange(annotsPObject);

            annotations = new ArrayList<Annotation>();
        }

        // update parent page reference.
        newAnnotation.getEntries().put(Annotation.PARENT_PAGE_KEY,
                this.getPObjectReference());

        // add the annotations to the parsed annotations list
        annotations.add(newAnnotation);

        // add the new annotations to the library
        library.addObject(newAnnotation, newAnnotation.getPObjectReference());

        // finally add the new annotations to the state manager
        stateManager.addChange(new PObject(newAnnotation, newAnnotation.getPObjectReference()));

        // return to caller for further manipulations.
        return newAnnotation;
    }