Interface FileProtocol

All Known Implementing Classes:
PF1, PF2, PF3, ProjectFile

public interface FileProtocol
FileProtocol defines the methods required for reading and writing files using a custom protocol.
  • Method Details

    • getProtocolHeader

      String getProtocolHeader()
      Gets the protocol header string that uniquely identifies this specific file protocol.
      Returns:
      The protocol header.
    • getProtocolVersion

      int getProtocolVersion()
      Gets the version number of the protocol.
      Returns:
      The protocol version.
    • getExtension

      String getExtension()
      The protocol's extension
      Returns:
      The protocol's extension
    • convertibleToHigher

      Set<ProjectFile.PF> convertibleToHigher()
      Returns a set of FileProtocol instances to which this protocol can be converted (upgraded). These are typically newer versions of the protocol.
      Returns:
      A set of higher version protocols this protocol can convert to.
    • convertibleFromLower

      Set<ProjectFile.PF> convertibleFromLower()
      Returns a set of FileProtocol instances from which this protocol can be converted (downgraded or upgraded from). These are typically older versions of the protocol that can be read and converted into this protocol.
      Returns:
      A set of lower version protocols that can be converted to this protocol.
    • readFile

      <T extends ArrayList> T readFile(String path, String name, Spinner throbber) throws Exception
      Reads a file from the specified path and returns its content as an object of type T. This should be a direct inverse of the corresponding writeFile(String, String, ArrayList) method.
      Type Parameters:
      T - The type of the object to be returned.
      Parameters:
      path - The path to the file to be read.
      name - The name of the file to be read.
      throbber - The Spinner instance
      Returns:
      The content of the file as an object of type T.
      Throws:
      Exception
    • writeFile

      <T extends ArrayList> void writeFile(String path, String name, T data)
      Writes the provided data to a file at the specified path. This should be a direct inverse of the corresponding readFile(String, String, Spinner) method.
      Type Parameters:
      T - The type of the data to be written, which must extend ArrayList.
      Parameters:
      path - The path to the file to be written.
      data - The data to be written to the file.
    • getHeaderWriter

      Consumer<DataOutputStream> getHeaderWriter()
      Gets a Consumer that writes the protocol-specific header information to a DataOutputStream.
      Returns:
      A Consumer that writes the header.
    • getHeaderReader

      BiConsumer<DataInputStream,Integer> getHeaderReader() throws IOException
      Gets a Consumer that reads the protocol-specific header information from a DataInputStream.
      Returns:
      A Consumer that reads the header.
      Throws:
      IOException - If an I/O error occurs.