public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter) { doCleanup(); Name.Component selectedComponent = null; Blob selectedEncoding = null; // We need to iterate over both arrays. int totalSize = staleTimeCache_.Count + noStaleTimeCache_.Count; for (int i = 0; i < totalSize; ++i) { MemoryContentCache.Content content; if (i < staleTimeCache_.Count) content = staleTimeCache_[i]; else // We have iterated over the first array. Get from the second. content = noStaleTimeCache_[i - staleTimeCache_.Count]; if (interest.matchesName(content.getName())) { if (interest.getChildSelector() < 0) { // No child selector, so send the first match that we have found. try { face.send(content.getDataEncoding()); } catch (IOException ex) { ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(MemoryContentCache).FullName) .log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex); } return; } else { // Update selectedEncoding based on the child selector. Name.Component component; if (content.getName().size() > interest.getName().size()) component = content.getName().get( interest.getName().size()); else component = emptyComponent_; bool gotBetterMatch = false; if (selectedEncoding == null) // Save the first match. gotBetterMatch = true; else { if (interest.getChildSelector() == 0) { // Leftmost child. if (component.compare(selectedComponent) < 0) gotBetterMatch = true; } else { // Rightmost child. if (component.compare(selectedComponent) > 0) gotBetterMatch = true; } } if (gotBetterMatch) { selectedComponent = component; selectedEncoding = content.getDataEncoding(); } } } } if (selectedEncoding != null) { // We found the leftmost or rightmost child. try { face.send(selectedEncoding); } catch (IOException ex_0) { ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(MemoryContentCache).FullName).log( ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex_0); } } else { // Call the onDataNotFound callback (if defined). Object onDataNotFound = ILOG.J2CsMapping.Collections.Collections.Get(onDataNotFoundForPrefix_,prefix.toUri()); if (onDataNotFound != null) { try { ((OnInterestCallback) onDataNotFound).onInterest(prefix, interest, face, interestFilterId, filter); } catch (Exception ex_1) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onDataNotFound", ex_1); } } } }