Interface FreeSlotsHandler

All Known Implementing Classes:
FreeSlotsDynamicLength, FreeSlotsFixedLength

public interface FreeSlotsHandler
Manages free slots of file pieces
Author:
angele
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    allocate(int length)
    allocate a new address and get index of it
    void
    allocate(int index, int length)
    search for a new address for index
    int
    append(int len)
    append a slot of length len at end of file
    void
    clear all used slots
    void
    copy all pages and free slots from freeSlots to this
    void
    free(int index)
    free address at index
    void
    free(long index)
    free address
    long
    getAddress(int index)
    get the file address of slot index
    boolean
    is it valid?
    void
    load slot table from file
    void
    save slot table to file
    void
    set basic file
    void
    setValid(boolean b)
    set valid flag
    int
    number of slots
  • Method Details

    • setFile

      void setFile(RandomAccessToFile file)
      set basic file
      Parameters:
      file -
    • clear

      void clear()
      clear all used slots
    • load

      void load() throws IOException
      load slot table from file
      Throws:
      IOException
    • save

      void save() throws IOException
      save slot table to file
      Throws:
      IOException
    • allocate

      void allocate(int index, int length) throws IOException
      search for a new address for index
      Parameters:
      length - TODO
      index - , index
      length - , length of file piece
      Throws:
      IOException
    • allocate

      int allocate(int length) throws IOException
      allocate a new address and get index of it
      Parameters:
      length - TODO
      length - , length of file piece
      Returns:
      slot index
      Throws:
      IOException
    • free

      void free(int index) throws IOException
      free address at index
      Parameters:
      index -
      Throws:
      IOException
    • free

      void free(long index) throws IOException
      free address
      Parameters:
      index -
      Throws:
      IOException
    • getAddress

      long getAddress(int index)
      get the file address of slot index
      Parameters:
      index -
      Returns:
    • append

      int append(int len) throws IOException
      append a slot of length len at end of file
      Parameters:
      len - , length of slot
      Returns:
      Throws:
      IOException
    • size

      int size()
      number of slots
      Returns:
    • copy

      void copy(FreeSlotsHandler freeSlots)
      copy all pages and free slots from freeSlots to this
      Parameters:
      freeSlots -
    • setValid

      void setValid(boolean b) throws IOException
      set valid flag
      Parameters:
      b -
      Throws:
      IOException
    • isValid

      boolean isValid() throws IOException
      is it valid?
      Returns:
      Throws:
      IOException