Skip to content

Commit

Permalink
Make DataDump backwards compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Feb 8, 2025
1 parent 91d1f60 commit 69636b9
Showing 1 changed file with 60 additions and 4 deletions.
64 changes: 60 additions & 4 deletions src/main/java/fi/dy/masa/malilib/data/DataDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -338,7 +339,7 @@ private String getFormattedLineASCII(Row row)
if (values.length == 1 && this.columns > 1)
{
int space = this.totalWidth + (Math.max(this.columns - 1, 0) * 3);
String fmt = null;
String fmt;
boolean isCenter = false;

if (this.centerTitle)
Expand Down Expand Up @@ -497,14 +498,69 @@ protected List<String> getFormattedData(List<String> lines)

public List<String> getLines()
{
List<String> lines = new ArrayList<String>();
List<String> lines = new ArrayList<>();

this.generateFormatStrings();
this.getFormattedData(lines);

return lines;
}

@Deprecated
@Nullable
public static File dumpDataToFile(File dir, String fileNameBase, List<String> lines, Format format)
{
Path dirPath = Paths.get(dir.toURI());
Path out;

if (format == Format.CSV)
{
out = dumpDataToFile(dirPath, fileNameBase + "-csv", ".csv", lines);
}
else
{
out = dumpDataToFile(dirPath, fileNameBase, ".txt", lines);
}

if (out != null)
{
return out.toFile();
}

return null;
}

@Deprecated
@Nullable
public static File dumpDataToFile(File dir, String fileNameBase, List<String> lines)
{
Path dirPath = Paths.get(dir.toURI());
Path out = dumpDataToFile(dirPath, fileNameBase, ".txt", lines);

if (out != null)
{
return out.toFile();
}

return null;
}

@Deprecated
@Nullable
public static File dumpDataToFile(File dir, String fileNameBase, String fileNameExtension, List<String> lines)
{
Path dirPath = Paths.get(dir.toURI());

Path out = dumpDataToFile(dirPath, fileNameBase, fileNameExtension, lines);

if (out != null)
{
return out.toFile();
}

return null;
}

@Nullable
public static Path dumpDataToFile(Path dir, String fileNameBase, List<String> lines, Format format)
{
Expand Down Expand Up @@ -655,12 +711,12 @@ else if (d1 > d2)
public enum Alignment
{
LEFT,
RIGHT;
RIGHT
}

public enum Format
{
ASCII,
CSV;
CSV
}
}

0 comments on commit 69636b9

Please sign in to comment.