Sub-Term Mapping Tools

CmdLine with Config Option

I. Description

This class extends the CmdLine (basic) class to provide basic function of interactive interface for command line tool and read information from a configuration file. By default, this class can take 0 or 1 arguments:
  • 0 argument: use the specified default config file in classpath
  • 1 argument: config file

The following steps are needed to use this class:

  • make YourClass as a sub-class of CmdLineConfig
    import gov.nih.nlm.nls.stmt.CmdLine.*;
    import gov.nih.nlm.nls.stmt.Lib.*;
    public class YourClass extends CmdLineConfig
  • instantiate YourClass and call Run(args) method in the main method
    YourClass yourClass = new YourClass();
    yourClass.Run(args);
  • override following methods
    • protected void InitLocalObjs()
      => instantiate local data members
    • protected void SetToolInfo()
      => set tool info, such as promptStr, tool name, version, config file, etc.
    • protected void CloseLocalObjs()
      => clean up local data members
    • protected void ProcessLine(String line)
      => how to process the input line

II. Main Algorithm


public void Run(String[] args)
=> Same as CmdLine

protected boolean PreProcess(String[] args)

  • PreProcess: init data members
  • Override protected method:
    • check args: <configFile>, if true:
      • SetToolInfo( );
        => protected method and must be override in YourClass
      • SetValues( );
        • Set all data members by default
      • If (runFlag_ == true)
        • InitLocalObjs( );
          => protected method and must be override in YourClass

protected void Process()
=> Same as CmdLine

protected void PostProcess()
=> Same as CmdLine

protected void HelpMenu()

  • Print out help menu
  • Override protected method

III. Abstract Methods

  • protected abstract void InitLocalObjs();
    => instantiate local data members in the subclass
  • protected abstract void SetToolInfo();
    => Set tool info (data members from CmdLine), such as tool anme, version, config file, prompt Str, etc.
  • protected abstract void ProcessLine(String line);
    => algorithm of how to process the input (line)
  • protected abstract void CloseLocalObjs();
    => Close (clean up) local data members in the subclass