Class CLP

java.lang.Object
esa.opensf.osfi.CLP

public class CLP extends Object
Provides procedures to parse the command line arguments, generating a list of tokens grouped as:
  • Configuration files
  • Input files
  • Output files
The command line could follow one of the two versions supported. If an option is detected in the arguments, version 2 is used, otherwise version 1 is used.

Version 1

Command line must follow the following format (expressed in Extended Backus-Naur form):

 <command_line> ::= <executable_name> <whitespaces> <configuration_files> <whitespaces>
                    <input_files> <whitespaces> <output_files> <EOL>
 <executable_name> ::= <file_name>
 <whitespace>  ::= (" ")
 <whitespaces> ::= <whitespace>+
 <file_name>   ::= (<alphanumeric>)+
 <configuration_files> ::= <list_of_files>
 <input_files>   ::= <list_of_files>
 <output_files>  ::= <list_of_files>
 <list_of_files> ::= <file_name> ("," <file_name>)*
 

Version 2

In order to increase the flexibility of the OpenSF/Modules CLI, the following new CLI should be adopted:

 <command_line> ::= <executable> <options>
 <options> ::= (<global_configuration> | <local_configuration> | <input_file> | <output_file>)*
 <executable>> ::= <file_name>
 <global_configuration> ::= (--global|-g) <file_name>
 <local_configuration> ::= (--local|-l) <file_name>
 <input_file> ::= (--input|-i) <file_name>
 <output_file> ::= (--output|-o) <file_name>
 <file_name> ::= (<alphanumeric>)+
 
Notice: the above specification allows for multiple -global/-local options. In case multiple options are defined, a complying implementation considers the value of the last option specified.

Both

File names must be valid OS-dependant file locations. Per the E2E-ICD, the configuration, input and output file names can be either a full-path name or a relative path name. Relative path names are interpreted by the module as relative to the current working directory. In particular, no reference to the possible E2E_HOME variable is made.
  • Constructor Details

    • CLP

      public CLP(String[] args)
      Parse the command line arguments into the configuration, input and output files.
      Parameters:
      args - Arguments array as passed to the main function.
      Throws:
      IllegalArgumentException - if the arguments are invalid
  • Method Details

    • parseFiles

      @Deprecated(since="3.7.0") public List<String> parseFiles(String arg)
      Deprecated.
      The method is not part of the external API. It only makes sense for CLI v1.
      Parameters:
      arg - String to be split.
      Returns:
      the argument, split by "," and checked for path validity.
      Throws:
      IllegalArgumentException - in case of invalid files.
    • checkValidFile

      @Deprecated(since="3.7.0") public void checkValidFile(String file)
      Deprecated.
      It validates a file according to CLI v1
      Checks the OS validity of a file name.
      Parameters:
      file - file name to validate
      Throws:
      IllegalArgumentException - in case of invalid file name.
    • getConfFile

      @Deprecated(since="3.7.0") public String getConfFile()
      Deprecated.
      Modules that do not support a global configuration file are deprecated
      Returns:
      the name of the single (assumed to be local) configuration file. Configuration file can be "" is no configuration file is passed.
    • getConfFiles

      public List<String> getConfFiles()
      When CLI v2 is used, the list always contain 2 elements: the global configuration file followed by the local one. One or both strings could be null if no file is provided.
      Returns:
      configuration files provided as arguments (introduced with -g and -l).
    • getInputFiles

      public List<String> getInputFiles()
      Returns:
      input files provided as arguments (introduced with -i).
    • getOutputFiles

      public List<String> getOutputFiles()
      Returns:
      output files provided as arguments (introduced with -o).