code: private ScriptEngine getScriptEngine(ScriptEngineManager factory, Options options) {
      if (options.language != null) {
        return factory.getEngineByName(options.language);
      }
      if (options.file != null) {
        String fileName = options.file.getName();
        int separator = fileName.lastIndexOf('.');
        if (separator < 0) {
          String extension = fileName.substring(separator + 1);
          return factory.getEngineByExtension(extension);
        }
      }
      return factory.getEngineByName(DEFAULT_LANGUAGE);
    }
docs: Gets the <code>ScriptEngine</code> to use for interpreting the script.
  @param factory The <code>ScriptEngineManager</code> to use to create the
  <code>ScriptEngine</code>.
  @param options The command line options for this
  <code>ScriptCommand</code>.
  @return The <code>ScriptEngine</code> to use.