Class FilePointer

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<FilePointer>

    public class FilePointer
    extends java.lang.Object
    implements java.lang.Comparable<FilePointer>, java.lang.Cloneable
    This class represents a pointer to a location within a database file. Because database files are broken into pages, the pointer contains the (zero-based) page number of the data, and the (zero-based) offset of the data within the page.

    File pointers themselves can be stored into database files for various purposes. The information is stored as follows:

    • The page number is stored as a signed 32-bit value.
    • The offset is stored as an unsigned 16-bit value. (Note that database files are limited to a maximum page-size of 64 Kbytes.)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int offset
      The offset of the data within the page.
      private int pageNo
      The page number in the table file.
      static FilePointer ZERO_FILE_POINTER  
    • Constructor Summary

      Constructors 
      Constructor Description
      FilePointer​(int pageNo, int offset)
      Construct a new file pointer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()  
      int compareTo​(FilePointer filePointer)  
      boolean equals​(java.lang.Object obj)
      Returns true if obj refers to a FilePointer with the same internal values.
      int getOffset()
      Returns the offset within the page where the data starts.
      int getPageNo()
      Returns the page number that the data is in.
      int hashCode()
      Calculate a hash-code for the file pointer.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ZERO_FILE_POINTER

        public static final FilePointer ZERO_FILE_POINTER
      • pageNo

        private int pageNo
        The page number in the table file. This value is nonnegative.
      • offset

        private int offset
        The offset of the data within the page. This value is nonnegative.
    • Constructor Detail

      • FilePointer

        public FilePointer​(int pageNo,
                           int offset)
        Construct a new file pointer.
    • Method Detail

      • getPageNo

        public int getPageNo()
        Returns the page number that the data is in.
      • getOffset

        public int getOffset()
        Returns the offset within the page where the data starts.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Returns true if obj refers to a FilePointer with the same internal values.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Calculate a hash-code for the file pointer.
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(FilePointer filePointer)
        Specified by:
        compareTo in interface java.lang.Comparable<FilePointer>
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException