Package hlcd.exporter
Class CodeObjectIO
java.lang.Object
hlcd.exporter.CodeObjectIO
Exports the code found to file as a persistent object (
.bin file).
Unlike CodeExporter, this will automatically override the file if it
already exists because it doesn't use a timestamp.
//minimal example to execute this class:
public static void main(String[] args) {
System.out.println("Running CodeObjectIO...");
byte n = 7;
byte k = 4;
byte d = 3;
byte base = 4;
boolean printPathToConsole = true;
CodeParameters cp = new CodeParameters(n, k, d, base);
CodeValidatorParameters cvp = new CodeValidatorParameters();
CodeExporterParameters cep = new CodeExporterParameters();
Code code = new Code(cp, cvp);
code.startEngine();
CodeObjectIO co = new CodeObjectIO(
code, //the code object to export
Paths.DEFAULT_PATH, //path to write to
"0", //the id of the generator matrix
printPathToConsole //should print the path of the file
);
System.out.println("The generator matrix of the code to be written:");
code.printGeneratorMatrix(true, Style.DECIMAL, true);
co.writeCodeObject();
Code c2 = co.readCodeObject();
System.out.println("The generator matrix of the code read:");
code.printGeneratorMatrix(true, Style.DECIMAL, true);
System.out.println("CodeObjectIO completed.");
}- Since:
- 1.8
- Version:
- 1.0 (January 24th, 2022)
- Author:
- Maysara Al Jumaily
-
Constructor Summary
ConstructorsConstructorDescriptionCodeObjectIO(Code code, String filepath, String id, boolean printPathToConsole)Initializes the Code object I/O based on the parameters specified. -
Method Summary
Modifier and TypeMethodDescriptionReads the.binfile that was previously written.voidWrites the code object that was passed in the constructor.
-
Constructor Details
-
CodeObjectIO
Initializes the Code object I/O based on the parameters specified. Requires the filepath as well as the code found in order to write it as a persistent object.- Parameters:
filepath- the filepath to write the.binfile incode- the code to write as a persistent objectid- the id of the code instance (can be left as"0")printPathToConsole- should the file paths generated be printed to console
-
-
Method Details
-
writeCodeObject
public void writeCodeObject()Writes the code object that was passed in the constructor. -
readCodeObject
Reads the.binfile that was previously written.TODO: This is not a complete method to use when running the program. It needs to be appropriately implemented so that it reads specified filename in a specific folder. Maybe pass the filepath as well as the filename here.
- Returns:
- the code object that was read
-