From ae65703e96e8c51880b9995ef5de27890722b275 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Mon, 28 May 2018 18:16:46 +0200 Subject: Takes the property name as a parameter. --- src/hastabel2idp/HastabelResult.java | 1 - src/hastabel2idp/Parameters.java | 49 +++++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/hastabel2idp/HastabelResult.java b/src/hastabel2idp/HastabelResult.java index 7b40e2d..102a229 100644 --- a/src/hastabel2idp/HastabelResult.java +++ b/src/hastabel2idp/HastabelResult.java @@ -43,7 +43,6 @@ public class HastabelResult { add_solution_to_level(predicate, signature); add_solution_to_model(predicate, idp_solution); - level.write(predicate); } private void add_solution_to_level diff --git a/src/hastabel2idp/Parameters.java b/src/hastabel2idp/Parameters.java index a2f72ae..74cc139 100644 --- a/src/hastabel2idp/Parameters.java +++ b/src/hastabel2idp/Parameters.java @@ -3,6 +3,8 @@ package hastabel2idp; import java.util.List; import java.util.ArrayList; +import java.io.File; + public class Parameters { private final List level_files; @@ -12,6 +14,7 @@ public class Parameters private final String idp_exec; private final boolean be_verbose; private final boolean are_valid; + private final String property_name; public static void print_usage () { @@ -19,8 +22,9 @@ public class Parameters ( "HaStABeL to IDP\n" + "USAGE:\n" - + "\tjava -jar hastabel2idp.jar +\n" + + "\tjava -jar hastabel2idp.jar +\n" + "PARAMETERS:\n" + + "\t- \tName of the property.\n" + "\t- \tDirectory in which to write the IDP model.\n" + "\t- \tList of files to be loaded.\n" + "OPTIONS:\n" @@ -31,11 +35,13 @@ public class Parameters + "\t- Model files have a \".mod\" extension.\n" + "\t- Level files have a \".lvl\" extension.\n" + "\t- The files may be given in any order." + + "\t- \".mod\" and \".lvl\" files from are also loaded." ); } public Parameters (final String... args) { + final File output_folder; boolean has_pro_file, has_error, should_be_verbose; String prop_file, idp_file; @@ -44,7 +50,7 @@ public class Parameters should_be_verbose = false; - if (args.length < 2) + if (args.length < 3) { print_usage(); @@ -55,6 +61,8 @@ public class Parameters be_verbose = false; idp_exec = null; + property_name = null; + return; } @@ -62,11 +70,13 @@ public class Parameters has_error = false; idp_file = null; - output_dir = args[0]; + property_name = args[0]; + output_dir = args[1]; if ( - (output_dir.equals("-e") || output_dir.equals("--exec")) + (property_name.equals("-e") || property_name.equals("--exec")) + || (output_dir.equals("-e") || output_dir.equals("--exec")) /* || ... */ ) { @@ -74,7 +84,8 @@ public class Parameters System.err.println ( - "[F] An option was found in lieu of the output file." + "[F] An option was found in lieu of the property name or of the" + + " output directory." ); System.exit(-1); @@ -82,7 +93,10 @@ public class Parameters if ( - output_dir.endsWith(".lvl") + property_name.endsWith(".lvl") + || property_name.endsWith(".mod") + || property_name.endsWith(".pro") + || output_dir.endsWith(".lvl") || output_dir.endsWith(".mod") || output_dir.endsWith(".pro") ) @@ -105,7 +119,7 @@ public class Parameters prop_file = new String(); - for (int i = 1; i < args.length; ++i) + for (int i = 2; i < args.length; ++i) { if (args[i].endsWith(".lvl")) { @@ -158,9 +172,26 @@ public class Parameters } } + output_folder = new File(output_dir); + + for (final File file : output_folder.listFiles()) + { + final String filename; + + filename = file.getName(); + + if (filename.endsWith(".lvl")) + { + level_files.add(output_dir + "/" + filename); + } + else if (filename.endsWith(".mod")) + { + model_files.add(output_dir + "/" + filename); + } + } + idp_exec = idp_file; property_file = prop_file; - if (!has_pro_file) { System.err.println("[E] There was no property file."); @@ -224,7 +255,7 @@ public class Parameters public String get_property_name () { - return "my_property"; + return property_name; } public boolean be_verbose () -- cgit v1.2.3-70-g09d2