Updated ServerFactory to allow parsing of tab-deliminated Server Datatable Files (.sdf txt files) to Interchangeable File Format for source control diff viewing instead of using binary files

An IFF is created for the corresponding SDF if: one does not exist or the SDF's modify date is > than the IFF's modify date
This commit is contained in:
Waverunner
2015-07-20 12:42:41 -04:00
parent 9763777731
commit e225aa8727
11 changed files with 454 additions and 10 deletions
+21 -7
View File
@@ -27,21 +27,14 @@
package resources.client_info;
import utilities.ByteUtilities;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* Created by Waverunner on 6/9/2015
*/
public abstract class DataFactory {
// readFile only called if dataMap doesn't contain the file as a key or it's value is null
protected ClientData readFile(String file) {
if (file == null || file.isEmpty()) {
System.err.println("File cannot be null or empty!");
@@ -64,6 +57,27 @@ public abstract class DataFactory {
return clientData;
}
protected File writeFile(SWGFile swgFile, ClientData data) {
if (swgFile == null || data == null) {
System.err.println("File or data objects cannot be null or empty!");
return null;
}
File save = new File(swgFile.getFileName());
data.writeIff(swgFile);
try {
swgFile.save(save);
} catch (IOException e) {
e.printStackTrace();
}
return save;
}
protected abstract ClientData createDataObject(String type);
protected ClientData createDataObject(SWGFile swgFile) {
return createDataObject(swgFile.getType());
}
protected abstract String getFolder();
}