Commit ff3be132 authored by Jonathan Shahen's avatar Jonathan Shahen

Better support for custom file extensions

parent 37d0d9e4
......@@ -19,6 +19,7 @@ import mohawk.converter.logging.MohawkTiming;
import mohawk.converter.to.asaptime.ConvertToASAPTimeNSA;
import mohawk.converter.to.mohawk.ConvertToMohawk;
import mohawk.converter.to.tred.ConvertToTRule;
import mohawk.global.FileExtensions;
import mohawk.global.pieces.MohawkT;
import org.apache.commons.cli.BasicParser;
......@@ -45,6 +46,7 @@ public class ConverterInstance {
// Helpers
public SpecHelper specHelper = new SpecHelper();
public MohawkTiming timing = new MohawkTiming();
public FileExtensions fileExt = new FileExtensions();
public int run(String[] args) {
try {
......@@ -100,7 +102,7 @@ public class ConverterInstance {
/* Timing */timing.startTimer("convertToRanise (" + i + ")");
ConvertToASAPTimeNSA toRanise = new ConvertToASAPTimeNSA();
String raniseStr = toRanise.convert(m, specFile, true);
toRanise.convert(m, specFile, true);
if (toRanise.lastError == null) {
logger.info("[SUCCESS] Successfully converted to Ranise's Input Format");
......
......@@ -8,9 +8,11 @@ import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import mohawk.global.FileExtensions;
import mohawk.global.pieces.MohawkT;
public class ConvertTo {
public FileExtensions fileExt = new FileExtensions(); // allows for custom file extensions
public String convertedStr = null;
public String lastError = null;
......
......@@ -170,7 +170,7 @@ public class ConvertToASAPTimeNSA extends ConvertTo {
@Override
public String getFileExtenstion() {
return ".ranise";
return fileExt.ASAPTime_NSA;
}
}
......@@ -51,7 +51,7 @@ public class ConvertToASAPTimeSA extends ConvertTo {
@Override
public String getFileExtenstion() {
return ".ranise";
return fileExt.ASAPTime_SA;
}
}
......@@ -15,11 +15,6 @@ import org.stringtemplate.v4.ST;
public class ConvertToMohawk extends ConvertTo {
public static final Logger logger = Logger.getLogger("mohawk-converter");
@Override
public String getFileExtenstion() {
return ".mohawk";
}
@Override
public String convert(MohawkT m, File f, Boolean writeToFile) {
try {
......@@ -54,4 +49,9 @@ public class ConvertToMohawk extends ConvertTo {
return convertedStr;
}
@Override
public String getFileExtenstion() {
return fileExt.Mohawk;
}
}
......@@ -81,6 +81,6 @@ public class ConvertToTRole extends ConvertTo {
@Override
public String getFileExtenstion() {
return ".uzun";
return fileExt.TRole;
}
}
......@@ -81,6 +81,6 @@ public class ConvertToTRule extends ConvertTo {
@Override
public String getFileExtenstion() {
return ".uzun";
return fileExt.TRule;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment