Package org.jitsi.cmd

Class CmdLine

  • All Implemented Interfaces:

    
    public class CmdLine
    
                        

    Utility class for parsing command line arguments that take some value. Arguments can have one of the following formats:

    • "arg=value"
    • "-arg=value"
    • "--arg=value"
    It's also possible to specify required arguments. If any of required arguments is not found ParseException will be thrown by parse.
    Author:

    Pawel Domas

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      CmdLine()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

      • CmdLine

        CmdLine()
    • Method Detail

      • addRequiredArgument

         void addRequiredArgument(String reqArg)

        Adds argument name to the list of required arguments.

        Parameters:
        reqArg - "arg", "-arg" or "--arg" argument name to be added.
      • removeRequiredArgument

         void removeRequiredArgument(String reqArg)

        Removes given argument name from the list of required arguments.

        Parameters:
        reqArg - "arg", "-arg" or "--arg" argument name.
      • parse

         void parse(Array<String> args)

        Parses the array of command line arguments.

        Parameters:
        args - String array which should come from the "main" method.
      • getOptionValue

         String getOptionValue(String opt)

        Returns the value of cmd line argument for given name. null if there was no value or it was empty.

        Parameters:
        opt - the name of command line argument which value we want to get.
      • getOptionValue

         String getOptionValue(String opt, String defaultValue)

        Returns the value of cmd line argument for given name. defaultValue if there was no value or it was empty.

        Parameters:
        opt - the name of command line argument which value we want to get.
        defaultValue - the default value which should be returned if the argument value is missing.
      • getIntOptionValue

         int getIntOptionValue(String opt, int defaultValue)

        Returns int value of cmd line argument for given name. defaultValue if there was no valid value for that argument.

        Parameters:
        opt - the name of command line argument which value we want to get.
        defaultValue - the default value which should be returned if the argument value is missing.