Class StringArrayOptionHandler


  • public class StringArrayOptionHandler
    extends OptionHandler<java.lang.String>

    An OptionHandler for greedily mapping a list of tokens into a collection of Strings (such as String[], List<String>, etc.).

    How it works:

    Example for parameter -s, which is type String[]:

    
     java -jar aaa.jar -s banan hruska jablko
     java -jar aaa.jar -s banan "hruska jablko"
     java -jar aaa.jar -s "banan hruska jablko"
     java -jar aaa.jar -s banan hruska jablko -l 4 -r
     java -jar aaa.jar -t 222 -s banan hruska jablko -r
     

    All of them result in a single string array that contains three tokens: banan, hruska, and jablko.

    This OptionHandler scans for parameter which begins with -. If found, it will stop.

    Author:
    PlainText,LuVar
    • Constructor Detail

    • Method Detail

      • getDefaultMetaVariable

        public java.lang.String getDefaultMetaVariable()
        Returns "STRING[]".
        Specified by:
        getDefaultMetaVariable in class OptionHandler<java.lang.String>
        Returns:
        return "STRING[]";
      • parseArguments

        public int parseArguments​(Parameters params)
                           throws CmdLineException
        Tries to parse String[] argument from Parameters.
        Specified by:
        parseArguments in class OptionHandler<java.lang.String>
        Parameters:
        params - The rest of the arguments. This method can use this object to access the arguments of the option if necessary. The object is valid only during the method call.
        Returns:
        The number of arguments consumed. (For example, returns 0 if this option doesn't take any parameters.)
        Throws:
        CmdLineException