Пример #1
0
        /**
         * Register a POIFSReaderListener for a particular document
         *
         * @param listener the listener
         * @param path the path of the document of interest
         * @param documentName the name of the document of interest
         */

        public void RegisterListener(POIFSReaderListener listener,
                              POIFSDocumentPath path,
                              String documentName)
        {
            if (!omnivorousListeners.Contains(listener))
            {

                // not an omnivorous listener (if it was, this method is a
                // no-op)
                ArrayList descriptors = (ArrayList)selectiveListeners[listener];

                if (descriptors == null)
                {

                    // this listener has not Registered before
                    descriptors = new ArrayList();
                    selectiveListeners[listener] = descriptors;
                }
                DocumentDescriptor descriptor = new DocumentDescriptor(path,
                                                    documentName);

                if (descriptors.Add(descriptor) >= 0)
                {

                    // this listener wasn't alReady listening for this
                    // document -- Add the listener to the Set of
                    // listeners for this document
                    ArrayList listeners =
                        (ArrayList)chosenDocumentDescriptors[descriptor];

                    if (listeners == null)
                    {

                        // nobody was listening for this document before
                        listeners = new ArrayList();
                        chosenDocumentDescriptors[descriptor] = listeners;
                    }
                    listeners.Add(listener);
                }
            }
        }
Пример #2
0
        private void DropDocument(POIFSReaderListener listener,
                                  DocumentDescriptor descriptor)
        {
            ArrayList listeners = (ArrayList)chosenDocumentDescriptors[descriptor];

            listeners.Remove(listener);
            if (listeners.Count == 0)
            {
                chosenDocumentDescriptors.Remove(descriptor);
            }
        }