Package com.j3d.storage.files.protocol
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 Summary
Modifier and TypeMethodDescriptionReturns a set ofFileProtocolinstances from which this protocol can be converted (downgraded or upgraded from).Returns a set ofFileProtocolinstances to which this protocol can be converted (upgraded).The protocol's extensionGets a Consumer that reads the protocol-specific header information from a DataInputStream.Gets a Consumer that writes the protocol-specific header information to a DataOutputStream.Gets the protocol header string that uniquely identifies this specific file protocol.intGets the version number of the protocol.<T extends ArrayList>
TReads a file from the specified path and returns its content as an object of type T.<T extends ArrayList>
voidWrites the provided data to a file at the specified path.
-
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 ofFileProtocolinstances 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 ofFileProtocolinstances 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
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 correspondingwriteFile(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
Writes the provided data to a file at the specified path. This should be a direct inverse of the correspondingreadFile(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
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.
-