/** * get am iterator of listeners for a particular document * * @param path the document path * @param name the name of the document * * @return an Iterator POIFSReaderListeners; may be empty */ Iterable<POIFSReaderListener> getListeners(final POIFSDocumentPath path, final String name) { Set<POIFSReaderListener> rval = new HashSet<>(omnivorousListeners); Set<POIFSReaderListener> selectiveListenersInner = chosenDocumentDescriptors.get(new DocumentDescriptor(path, name)); if (selectiveListenersInner != null) { rval.addAll(selectiveListenersInner); } 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 */ void registerListener(final POIFSReaderListener listener, final POIFSDocumentPath path, final String documentName) { if (!omnivorousListeners.contains(listener)) { // not an omnivorous listener (if it was, this method is a // no-op) Set<DocumentDescriptor> descriptors = selectiveListeners.computeIfAbsent(listener, k -> new HashSet<>()); // this listener has not registered before DocumentDescriptor descriptor = new DocumentDescriptor(path, documentName); if (descriptors.add(descriptor)) { // this listener wasn't already listening for this // document -- add the listener to the set of // listeners for this document Set<POIFSReaderListener> listeners = chosenDocumentDescriptors.computeIfAbsent(descriptor, k -> new HashSet<>()); // nobody was listening for this document before listeners.add(listener); } } }
/** * get am iterator of listeners for a particular document * * @param path the document path * @param name the name of the document * * @return an Iterator POIFSReaderListeners; may be empty */ Iterable<POIFSReaderListener> getListeners(final POIFSDocumentPath path, final String name) { Set<POIFSReaderListener> rval = new HashSet<>(omnivorousListeners); Set<POIFSReaderListener> selectiveListenersInner = chosenDocumentDescriptors.get(new DocumentDescriptor(path, name)); if (selectiveListenersInner != null) { rval.addAll(selectiveListenersInner); } return rval; }
/** * get am iterator of listeners for a particular document * * @param path the document path * @param name the name of the document * * @return an Iterator POIFSReaderListeners; may be empty */ Iterator getListeners(final POIFSDocumentPath path, final String name) { Set rval = new HashSet(omnivorousListeners); Set selectiveListeners = ( Set ) chosenDocumentDescriptors.get(new DocumentDescriptor(path, name)); if (selectiveListeners != null) { rval.addAll(selectiveListeners); } return rval.iterator(); }
/** * get am iterator of listeners for a particular document * * @param path the document path * @param name the name of the document * * @return an Iterator POIFSReaderListeners; may be empty */ Iterator getListeners(final POIFSDocumentPath path, final String name) { Set rval = new HashSet(omnivorousListeners); Set selectiveListeners = ( Set ) chosenDocumentDescriptors.get(new DocumentDescriptor(path, name)); if (selectiveListeners != null) { rval.addAll(selectiveListeners); } return rval.iterator(); }
/** * 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 */ void registerListener(final POIFSReaderListener listener, final POIFSDocumentPath path, final String documentName) { if (!omnivorousListeners.contains(listener)) { // not an omnivorous listener (if it was, this method is a // no-op) Set<DocumentDescriptor> descriptors = selectiveListeners.computeIfAbsent(listener, k -> new HashSet<>()); // this listener has not registered before DocumentDescriptor descriptor = new DocumentDescriptor(path, documentName); if (descriptors.add(descriptor)) { // this listener wasn't already listening for this // document -- add the listener to the set of // listeners for this document Set<POIFSReaderListener> listeners = chosenDocumentDescriptors.computeIfAbsent(descriptor, k -> new HashSet<>()); // nobody was listening for this document before listeners.add(listener); } } }
selectiveListeners.put(listener, descriptors); DocumentDescriptor descriptor = new DocumentDescriptor(path, documentName);
selectiveListeners.put(listener, descriptors); DocumentDescriptor descriptor = new DocumentDescriptor(path, documentName);