From 943d92989c49c5381fbb8b2dc848587536d04524 Mon Sep 17 00:00:00 2001 From: James Procter Date: Tue, 6 Jun 2023 17:58:18 +0100 Subject: [PATCH] JAL-1551 formatting and javadoc for ArgParser rather than // comments --- src/jalview/bin/argparser/ArgParser.java | 164 ++++++++++++++++++++---------- 1 file changed, 109 insertions(+), 55 deletions(-) diff --git a/src/jalview/bin/argparser/ArgParser.java b/src/jalview/bin/argparser/ArgParser.java index f08e678..b32baf5 100644 --- a/src/jalview/bin/argparser/ArgParser.java +++ b/src/jalview/bin/argparser/ArgParser.java @@ -52,77 +52,111 @@ public class ArgParser protected static final String NEGATESTRING = "no"; - // the default linked id prefix used for no id (not even square braces) + /** + * the default linked id prefix used for no id (ie when not even square braces + * are provided) + */ protected static final String DEFAULTLINKEDIDPREFIX = "JALVIEW:"; - // the linkedId string used to match all linkedIds seen so far + /** + * the linkedId string used to match all linkedIds seen so far + */ protected static final String MATCHALLLINKEDIDS = "*"; - // the linkedId string used to match all of the last --open'ed linkedIds + /** + * the linkedId string used to match all of the last --open'ed linkedIds + */ protected static final String MATCHOPENEDLINKEDIDS = "open*"; - // the counter added to the default linked id prefix + /** + * the counter added to the default linked id prefix + */ private int defaultLinkedIdCounter = 0; - // the substitution string used to use the defaultLinkedIdCounter + /** + * the substitution string used to use the defaultLinkedIdCounter + */ private static final String DEFAULTLINKEDIDCOUNTER = "{}"; - // the counter added to the default linked id prefix. NOW using - // linkedIdAutoCounter - // private int openLinkedIdCounter = 0; - - // the linked id prefix used for --open files. NOW the same as DEFAULT + /** + * the linked id prefix used for --open files. NOW the same as DEFAULT + */ protected static final String OPENLINKEDIDPREFIX = DEFAULTLINKEDIDPREFIX; - // the counter used for {n} substitutions + /** + * 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) + /** + * the linked id substitution string used to increment the idCounter (and use + * the incremented value) + */ private static final String INCREMENTLINKEDIDAUTOCOUNTER = "{++n}"; - // the linked id substitution string used to use the idCounter + /** + * the linked id substitution string used to use the idCounter + */ private static final String LINKEDIDAUTOCOUNTER = "{n}"; - // the linked id substitution string used to use the filename extension of - // --append - // or --open + /** + * the linked id substitution string used to use the filename extension of + * --append or --open + */ private static final String LINKEDIDEXTENSION = "{extension}"; - // the linked id substitution string used to use the base filename of --append - // or --open + /** + * the linked id substitution string used to use the base filename of --append + */ + /** or --open */ private static final String LINKEDIDBASENAME = "{basename}"; - // the linked id substitution string used to use the dir path of --append - // or --open + /** + * the linked id substitution string used to use the dir path of --append or + * --open + */ private static final String LINKEDIDDIRNAME = "{dirname}"; - // the current argfile + /** + * the current argfile + */ private String argFile = null; - // the linked id substitution string used to use the dir path of the latest - // --argfile name + /** + * the linked id substitution string used to use the dir path of the latest + */ + /** --argfile name */ private static final String ARGFILEBASENAME = "{argfilebasename}"; - // the linked id substitution string used to use the dir path of the latest - // --argfile name + /** + * the linked id substitution string used to use the dir path of the latest + * --argfile name + */ private static final String ARGFILEDIRNAME = "{argfiledirname}"; - // flag to say whether {n} subtitutions in output filenames should be made. - // Turn on and off with --substitutions and --nosubstitutions - // Start with it on + /** + * flag to say whether {n} subtitutions in output filenames should be made. + * Turn on and off with --substitutions and --nosubstitutions Start with it on + */ private boolean substitutions = true; - // flag to say whether the default linkedId is the current default linked id - // or ALL linkedIds + /** + * flag to say whether the default linkedId is the current default linked id + * + * or ALL linkedIds + */ private boolean allLinkedIds = false; - // flag to say whether the default linkedId is the current default linked id - // or OPENED linkedIds + /** + * flag to say whether the default linkedId is the current default linked id + * or OPENED linkedIds + */ private boolean openedLinkedIds = false; - // flag to say whether the structure arguments should be applied to all - // structures with this linked id + /** + * flag to say whether the structure arguments should be applied to all + * structures with this linked id + */ private boolean allStructures = false; protected static final Map argMap; @@ -464,7 +498,8 @@ public class ArgParser val = LINKEDIDDIRNAME + File.separator + LINKEDIDBASENAME + val.substring(MATCHALLLINKEDIDS.length()); } - else if (a.hasOption(Opt.OUTPUTFILE) && a.hasOption(Opt.ALLOWALL) + else if (a.hasOption(Opt.OUTPUTFILE) + && a.hasOption(Opt.ALLOWALL) && val.startsWith(MATCHOPENEDLINKEDIDS)) { // --output=open*.ext is shorthand for --opened --output @@ -902,15 +937,19 @@ public class ArgParser FIRST, BEFORE, AFTER } - // get from following Arg of type a or subval of same name (lowercase) + /** + * get from following Arg of type a or subval of same name (lowercase) + */ public static String getValueFromSubValOrArg(ArgValuesMap avm, ArgValue av, Arg a, SubVals sv) { return getFromSubValArgOrPref(avm, av, a, sv, null, null, null); } - // get from following Arg of type a or subval key or preference pref or - // default def + /** + * get from following Arg of type a or subval key or preference pref or + * default def + */ public static String getFromSubValArgOrPref(ArgValuesMap avm, ArgValue av, Arg a, SubVals sv, String key, String pref, String def) { @@ -918,8 +957,10 @@ public class ArgParser def); } - // get from following(AFTER), first occurence of (FIRST) or previous (BEFORE) - // Arg of type a or subval key or preference pref or default def + /** + * get from following(AFTER), first occurence of (FIRST) or previous (BEFORE) + * Arg of type a or subval key or preference pref or default def + */ public static String getFromSubValArgOrPref(ArgValuesMap avm, Arg a, Position pos, ArgValue av, SubVals sv, String key, String pref, String def) @@ -1048,7 +1089,9 @@ public class ArgParser // the following methods look for the "*" linkedId and add the argvalue to all // linkedId ArgValues if it does. - // This version inserts the subvals sv into all created values + /** + * This version inserts the subvals sv into all created values + */ private void addValue(String linkedId, Type type, ArgValues avs, SubVals sv, String v, int argIndex, boolean doSubs) { @@ -1096,21 +1139,32 @@ public class ArgParser doSubs); } - /* + /** * The following operations look for the "*" and "open*" linkedIds and add the - * argvalue to all appropriate linkedId ArgValues if it does. - * If subvals are supplied, they are inserted into all new set values. + * argvalue to all appropriate linkedId ArgValues if it does. If subvals are + * supplied, they are inserted into all new set values. * - * @param op The ArgParser.Op operation - * @param linkedId The String linkedId from the ArgValuesMap - * @param type The Arg.Type to attach to this ArgValue - * @param avs The ArgValues for this linkedId - * @param sv Use these SubVals on the ArgValue - * @param merge Merge the SubVals with any existing on the value. False will replace unless sv is null - * @param v The value of the ArgValue (may contain subvals). - * @param b The boolean value of the ArgValue. - * @param argIndex The argIndex for the ArgValue. - * @param doSubs Whether to perform substitutions on the subvals and value. + * @param op + * The ArgParser.Op operation + * @param linkedId + * The String linkedId from the ArgValuesMap + * @param type + * The Arg.Type to attach to this ArgValue + * @param avs + * The ArgValues for this linkedId + * @param sv + * Use these SubVals on the ArgValue + * @param merge + * Merge the SubVals with any existing on the value. False will + * replace unless sv is null + * @param v + * The value of the ArgValue (may contain subvals). + * @param b + * The boolean value of the ArgValue. + * @param argIndex + * The argIndex for the ArgValue. + * @param doSubs + * Whether to perform substitutions on the subvals and value. */ private void argValueOperation(Op op, String linkedId, Type type, ArgValues avs, SubVals sv, boolean merge, String v, boolean b, -- 1.7.10.2