= Reordered CSV and processed
This commit is contained in:
@@ -43,7 +43,14 @@ public abstract class BaseLocFile implements IConfigSection
|
||||
{
|
||||
for(ConfigItem item : pairs)
|
||||
{
|
||||
localized.put(item.key, item.value);
|
||||
if(item.value.trim().length() <= 0)
|
||||
{
|
||||
localized.put(item.key, item.key);
|
||||
}
|
||||
else
|
||||
{
|
||||
localized.put(item.key, item.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +169,7 @@ public abstract class BaseLocFile implements IConfigSection
|
||||
@Override
|
||||
public void consume(List<ConfigItem> pairs)
|
||||
{
|
||||
GlobalLog.log("Ok nice!");
|
||||
localized.clear();
|
||||
buildLocalized(pairs);
|
||||
scrapeAll();
|
||||
@@ -171,10 +179,20 @@ public abstract class BaseLocFile implements IConfigSection
|
||||
public List<ConfigItem> produce()
|
||||
{
|
||||
List<ConfigItem> items = new Vector<ConfigItem>();
|
||||
|
||||
for(Entry<String, String> entry : localized.entrySet())
|
||||
|
||||
for(Entry<String, String> keyValuePair : localized.entrySet())
|
||||
{
|
||||
items.add(new ConfigItem(headerName, entry.getKey(), entry.getValue()));
|
||||
String key = keyValuePair.getKey();
|
||||
String value = keyValuePair.getValue();
|
||||
|
||||
if(key.equalsIgnoreCase(value))
|
||||
{
|
||||
items.add(new ConfigItem(headerName, key, ""));
|
||||
}
|
||||
else
|
||||
{
|
||||
items.add(new ConfigItem(headerName, key, value));
|
||||
}
|
||||
}
|
||||
|
||||
items.sort((item1, item2) -> item1.key.compareToIgnoreCase(item2.key));
|
||||
|
||||
+13
-2
@@ -22,11 +22,14 @@ public class ConfigCSV
|
||||
// Variables
|
||||
private final String path;
|
||||
private List<ConfigItem> fileContents;
|
||||
private List<IConfigSection> sections;
|
||||
|
||||
// Constructor
|
||||
public ConfigCSV(List<IConfigSection> sections, String path)
|
||||
{
|
||||
this.path = path;
|
||||
this.sections = sections;
|
||||
|
||||
fileContents = new Vector<ConfigItem>();
|
||||
|
||||
read(path);
|
||||
@@ -115,15 +118,23 @@ public class ConfigCSV
|
||||
List<String[]> toWrite = new Vector<String[]>();
|
||||
toWrite.add(ConfigItem.header);
|
||||
|
||||
for(ConfigItem item : fileContents)
|
||||
for(IConfigSection section : sections)
|
||||
{
|
||||
toWrite.add(item.getAll());
|
||||
List<ConfigItem> items = section.produce();
|
||||
|
||||
for(ConfigItem item : items)
|
||||
{
|
||||
toWrite.add(item.getAll());
|
||||
}
|
||||
}
|
||||
|
||||
Writer writer = Files.newBufferedWriter(Paths.get(path));
|
||||
|
||||
CSVWriter csvWriter = makeWriter(writer);
|
||||
csvWriter.writeAll(toWrite);
|
||||
csvWriter.flush();
|
||||
csvWriter.close();
|
||||
|
||||
writer.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
|
||||
Reference in New Issue
Block a user