/// <summary> /// equality. Two DocumentDescriptor instances are equal if they /// have equal paths and names /// </summary> /// <param name="o">the object we're checking equality for</param> /// <returns>true if the object is equal to this object</returns> public override bool Equals(Object o) { bool rval = false; if ((o != null) && (o.GetType() == this.GetType())) { if (this == o) { rval = true; } else { DocumentDescriptor descriptor = ( DocumentDescriptor )o; rval = this.path.Equals(descriptor.path) && this.name.Equals(descriptor.name); } } return(rval); }
/** * 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); } } }
private void DropDocument(POIFSReaderListener listener, DocumentDescriptor descriptor) { ArrayList listeners = (ArrayList)chosenDocumentDescriptors[descriptor]; listeners.Remove(listener); if (listeners.Count == 0) { chosenDocumentDescriptors.Remove(descriptor); } }