JAL-629 Tests for FileUtils. Tidying counter substitutions. Fixing PAE opening.
[jalview.git] / src / jalview / bin / argparser / ArgParser.java
index ff238da..f3306d6 100644 (file)
@@ -50,18 +50,24 @@ public class ArgParser
   // the counter added to the default linked id prefix
   private int defaultLinkedIdCounter = 0;
 
-  // the linked id prefix used for --opennew files
-  protected static final String OPENNEWLINKEDIDPREFIX = "OPENNEW:";
+  // the substitution string used to use the defaultLinkedIdCounter
+  private static final String DEFAULTLINKEDIDCOUNTER = "{}";
 
   // the counter added to the default linked id prefix
   private int opennewLinkedIdCounter = 0;
 
+  // the linked id prefix used for --opennew files
+  protected static final String OPENNEWLINKEDIDPREFIX = "OPENNEW:";
+
+  // the counter used for {n} substitutions
+  private int linkedIdAutoCounter = 0;
+
   // the linked id substitution string used to increment the idCounter (and use
   // the incremented value)
-  private static final String INCREMENTAUTOCOUNTERLINKEDID = "{++n}";
+  private static final String INCREMENTLINKEDIDAUTOCOUNTER = "{++n}";
 
   // the linked id substitution string used to use the idCounter
-  private static final String AUTOCOUNTERLINKEDID = "{n}";
+  private static final String LINKEDIDAUTOCOUNTER = "{n}";
 
   // the linked id substitution string used to use the base filename of --open
   // or --opennew
@@ -82,8 +88,6 @@ public class ArgParser
   // --argfile name
   private static final String ARGFILEDIRNAME = "{argfiledirname}";
 
-  private int linkedIdAutoCounter = 0;
-
   // flag to say whether {n} subtitutions in output filenames should be made.
   // Turn on and off with --subs and --nosubs
   private boolean substitutions = false;
@@ -369,21 +373,21 @@ public class ArgParser
                       + arg);
             }
           }
-          else if (linkedId.contains(AUTOCOUNTERLINKEDID))
+          else if (linkedId.contains(LINKEDIDAUTOCOUNTER))
           {
             // turn {n} to the autoCounter
             autoCounterString = Integer.toString(linkedIdAutoCounter);
-            linkedId = linkedId.replace(AUTOCOUNTERLINKEDID,
+            linkedId = linkedId.replace(LINKEDIDAUTOCOUNTER,
                     autoCounterString);
             usingAutoCounterLinkedId = true;
             Console.debug(
                     "Changing linkedId to '" + linkedId + "' from " + arg);
           }
-          else if (linkedId.contains(INCREMENTAUTOCOUNTERLINKEDID))
+          else if (linkedId.contains(INCREMENTLINKEDIDAUTOCOUNTER))
           {
             // turn {++n} to the incremented autoCounter
             autoCounterString = Integer.toString(++linkedIdAutoCounter);
-            linkedId = linkedId.replace(INCREMENTAUTOCOUNTERLINKEDID,
+            linkedId = linkedId.replace(INCREMENTLINKEDIDAUTOCOUNTER,
                     autoCounterString);
             usingAutoCounterLinkedId = true;
             Console.debug(
@@ -494,14 +498,15 @@ public class ArgParser
       subvals = "";
       rest = val;
     }
-    if (rest.contains(AUTOCOUNTERLINKEDID))
-      rest = rest.replace(AUTOCOUNTERLINKEDID,
+    if (rest.contains(LINKEDIDAUTOCOUNTER))
+      rest = rest.replace(LINKEDIDAUTOCOUNTER,
               String.valueOf(linkedIdAutoCounter));
-    if (rest.contains(INCREMENTAUTOCOUNTERLINKEDID))
-      rest = rest.replace(INCREMENTAUTOCOUNTERLINKEDID,
+    if (rest.contains(INCREMENTLINKEDIDAUTOCOUNTER))
+      rest = rest.replace(INCREMENTLINKEDIDAUTOCOUNTER,
               String.valueOf(++linkedIdAutoCounter));
-    if (rest.contains("{}"))
-      rest = rest.replace("{}", String.valueOf(defaultLinkedIdCounter));
+    if (rest.contains(DEFAULTLINKEDIDCOUNTER))
+      rest = rest.replace(DEFAULTLINKEDIDCOUNTER,
+              String.valueOf(defaultLinkedIdCounter));
     ArgValuesMap avm = linkedArgs.get(linkedId);
     if (avm != null)
     {