private boolean reachedEnd() { return this.contents.getRemaining() <= 0; } }
@Override public DataFrameEntry getNext() throws IOException { closeLast(); if (reachedEnd()) { return null; } // Integrity check. This means that we have a corrupt frame. if (this.contents.getRemaining() < EntryHeader.HEADER_SIZE) { throw new SerializationException(String.format("Data Frame is corrupt. InputStream has insufficient bytes for a new Entry Header (%d).", this.contents.getRemaining())); } // Determine the length of the next record and advance the position by the appropriate amount of bytes. ReadEntryHeader header = new ReadEntryHeader(this.contents); // Integrity check. This means that we have a corrupt frame. if (this.contents.getRemaining() < header.getEntryLength()) { throw new SerializationException(String.format("Data Frame is corrupt. Found Entry Length %d which cannot fit in the Frame's remaining length of %d.", header.getEntryLength(), this.contents.getRemaining())); } // Get the result contents && advance the positions. int frameOffset = this.bufferOffset + this.contents.getBound() - this.contents.getRemaining(); BoundedInputStream resultContents = this.contents.subStream(header.getEntryLength()); this.lastEntryContents = resultContents; return new DataFrameEntry(header, resultContents, this.frameAddress, reachedEnd(), frameOffset); }