Package com.pd4ml.pdf.cos.parser
Class RandomAccessBuffer
- java.lang.Object
-
- com.pd4ml.pdf.cos.parser.RandomAccessBuffer
-
public final class RandomAccessBuffer extends java.lang.ObjectMinimal seekable byte source over an in-memory PDF file. Kept as a small, self-contained abstraction (rather than depending on RandomAccessFile) so the same lexer/parser code works identically for bytes read from disk, downloaded, or held entirely in memory.
-
-
Constructor Summary
Constructors Constructor Description RandomAccessBuffer(byte[] data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getData()intindexOf(byte[] pattern, int from)booleanisEOF()intlastIndexOf(byte[] pattern, int searchFromEnd)Finds the last occurrence ofpatternat or before the current end-of-buffer search window; used to locatestartxrefand the trailing%%EOFnear the end of a file.intlength()intpeek()Looks at the next byte without consuming it, or -1 at end of data.intpeek(int offset)Looksoffsetbytes ahead without consuming, or -1 past the end.intposition()intread()Reads the next byte, or -1 at end of data (does not throw).byte[]readFully(int count)voidseek(long newPosition)voidunread()
-
-
-
Method Detail
-
length
public int length()
-
position
public int position()
-
seek
public void seek(long newPosition)
-
isEOF
public boolean isEOF()
-
read
public int read()
Reads the next byte, or -1 at end of data (does not throw).
-
peek
public int peek()
Looks at the next byte without consuming it, or -1 at end of data.
-
peek
public int peek(int offset)
Looksoffsetbytes ahead without consuming, or -1 past the end.
-
unread
public void unread()
-
readFully
public byte[] readFully(int count)
-
getData
public byte[] getData()
-
lastIndexOf
public int lastIndexOf(byte[] pattern, int searchFromEnd)Finds the last occurrence ofpatternat or before the current end-of-buffer search window; used to locatestartxrefand the trailing%%EOFnear the end of a file.
-
indexOf
public int indexOf(byte[] pattern, int from)
-
-