Class DefaultCommandLine

  • All Implemented Interfaces:
    CommandLine

    public class DefaultCommandLine
    extends java.lang.Object
    implements CommandLine
    Implementation of the CommandLine interface.
    Since:
    2.0
    • Constructor Detail

      • DefaultCommandLine

        public DefaultCommandLine()
    • Method Detail

      • addDeclaredOption

        public void addDeclaredOption​(java.lang.String name,
                                      Option option)
      • addUndeclaredOption

        public void addUndeclaredOption​(java.lang.String option)
      • addUndeclaredOption

        public void addUndeclaredOption​(java.lang.String option,
                                        java.lang.Object value)
      • addDeclaredOption

        public void addDeclaredOption​(java.lang.String name,
                                      Option option,
                                      java.lang.Object value)
      • parseNew

        public CommandLine parseNew​(java.lang.String[] args)
        Description copied from interface: CommandLine
        Parses a new CommandLine instance that combines this instance with the given arguments
        Specified by:
        parseNew in interface CommandLine
        Parameters:
        args - The arguments
        Returns:
        A new CommandLine instance
      • setEnvironment

        public void setEnvironment​(java.lang.String environment)
      • setCommand

        public void setCommand​(java.lang.String name)
        Specified by:
        setCommand in interface CommandLine
      • getEnvironment

        public java.lang.String getEnvironment()
        Specified by:
        getEnvironment in interface CommandLine
        Returns:
        The environment specified
      • isEnvironmentSet

        public boolean isEnvironmentSet()
        Specified by:
        isEnvironmentSet in interface CommandLine
        Returns:
        Whether the environment is user specified
      • setCommandName

        public void setCommandName​(java.lang.String cmd)
      • getCommandName

        public java.lang.String getCommandName()
        Specified by:
        getCommandName in interface CommandLine
        Returns:
        The command name specified
      • addRemainingArg

        public void addRemainingArg​(java.lang.String arg)
      • getRemainingArgs

        public java.util.List<java.lang.String> getRemainingArgs()
        Specified by:
        getRemainingArgs in interface CommandLine
        Returns:
        The remaining arguments after the command name
      • getRemainingArgsArray

        public java.lang.String[] getRemainingArgsArray()
        Specified by:
        getRemainingArgsArray in interface CommandLine
        Returns:
        The remaining arguments as an array
      • getSystemProperties

        public java.util.Properties getSystemProperties()
        Specified by:
        getSystemProperties in interface CommandLine
        Returns:
        The system properties specified
      • hasOption

        public boolean hasOption​(java.lang.String name)
        Specified by:
        hasOption in interface CommandLine
        Parameters:
        name - The name of the option
        Returns:
        Whether the given option is specified
      • optionValue

        public java.lang.Object optionValue​(java.lang.String name)
        Description copied from interface: CommandLine
        The value of an option
        Specified by:
        optionValue in interface CommandLine
        Parameters:
        name - The option
        Returns:
        The value
      • lastOption

        public java.util.Map.Entry<java.lang.String,​java.lang.Object> lastOption()
        Specified by:
        lastOption in interface CommandLine
        Returns:
        The last specified option
      • getRemainingArgsString

        public java.lang.String getRemainingArgsString()
        Specified by:
        getRemainingArgsString in interface CommandLine
        Returns:
        The remaining args as one big string
      • getRemainingArgsWithOptionsString

        public java.lang.String getRemainingArgsWithOptionsString()
        Specified by:
        getRemainingArgsWithOptionsString in interface CommandLine
        Returns:
        The remaining args as one big string without undeclared options
      • getRemainingArgsLineSeparated

        public java.lang.String getRemainingArgsLineSeparated()
        Specified by:
        getRemainingArgsLineSeparated in interface CommandLine
        Returns:
        The remaining args separated by the line separator char
      • getUndeclaredOptions

        public java.util.Map<java.lang.String,​java.lang.Object> getUndeclaredOptions()
        Specified by:
        getUndeclaredOptions in interface CommandLine
      • addSystemProperty

        public void addSystemProperty​(java.lang.String name,
                                      java.lang.String value)
      • setRawArguments

        public void setRawArguments​(java.lang.String[] args)