/** * Returns the SourceEntry that contains the byte at the specified offset * sourceReleased is called as a notification callback so subclasses can take care of cleanup * when the source is no longer the active source * @param offset the offset of the byte to look for * @return the SourceEntry that contains the byte at the specified offset * @throws java.io.IOException if there is a problem with IO (usually the result of the sourceReleased() call) */ private SourceEntry getSourceEntryForOffset(long offset) throws java.io.IOException { if (offset >= size) return null; if (offset >= currentSourceEntry.firstByte && offset <= currentSourceEntry.lastByte) return currentSourceEntry; // hook to allow subclasses to release resources if necessary sourceReleased(currentSourceEntry.source); int startAt = getStartingSourceIndex(offset); for(int i = startAt; i < sources.length; i++){ if (offset >= sources[i].firstByte && offset <= sources[i].lastByte){ currentSourceEntry = sources[i]; sourceInUse(currentSourceEntry.source); return currentSourceEntry; } } return null; }
/** * Returns the SourceEntry that contains the byte at the specified offset * sourceReleased is called as a notification callback so subclasses can take care of cleanup * when the source is no longer the active source * @param offset the offset of the byte to look for * @return the SourceEntry that contains the byte at the specified offset * @throws java.io.IOException if there is a problem with IO (usually the result of the sourceReleased() call) */ private SourceEntry getSourceEntryForOffset(long offset) throws java.io.IOException { if (offset >= size) return null; if (offset >= currentSourceEntry.firstByte && offset <= currentSourceEntry.lastByte) return currentSourceEntry; // hook to allow subclasses to release resources if necessary sourceReleased(currentSourceEntry.source); int startAt = getStartingSourceIndex(offset); for(int i = startAt; i < sources.length; i++){ if (offset >= sources[i].firstByte && offset <= sources[i].lastByte){ currentSourceEntry = sources[i]; sourceInUse(currentSourceEntry.source); return currentSourceEntry; } } return null; }