Class RandomAccessBuffer


  • public final class RandomAccessBuffer
    extends java.lang.Object
    Minimal 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()  
      int indexOf​(byte[] pattern, int from)  
      boolean isEOF()  
      int lastIndexOf​(byte[] pattern, int searchFromEnd)
      Finds the last occurrence of pattern at or before the current end-of-buffer search window; used to locate startxref and the trailing %%EOF near the end of a file.
      int length()  
      int peek()
      Looks at the next byte without consuming it, or -1 at end of data.
      int peek​(int offset)
      Looks offset bytes ahead without consuming, or -1 past the end.
      int position()  
      int read()
      Reads the next byte, or -1 at end of data (does not throw).
      byte[] readFully​(int count)  
      void seek​(long newPosition)  
      void unread()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RandomAccessBuffer

        public RandomAccessBuffer​(byte[] data)
    • 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)
        Looks offset bytes 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 of pattern at or before the current end-of-buffer search window; used to locate startxref and the trailing %%EOF near the end of a file.
      • indexOf

        public int indexOf​(byte[] pattern,
                           int from)