Logo Search packages:      
Sourcecode: jlha-utils version File versions  Download package

boolean org::jlhafrontend::Opts::setOpts ( String  optstr  )  [inline]

set the command-line opts to handle This method parses the user-input options. Results can be retrived by other getX methods.

Parameters:
optstr command-line opts
Returns:
valid opt or not

Definition at line 259 of file Opts.java.

References CMD_ADD, CMD_DELETE, CMD_EXTRACT, CMD_LIST, CMD_PRINTSTDOUT, CMD_RECONSTRUCT, CMD_TEST, CMD_UPDATE, CMD_VERBOSELIST, and mylogger.

Referenced by main(), Opts(), and org::jlhafrontend::JLHAFrontEnd::start().

                                           {
      int i;
      boolean ret;
      String regex1 = "[-]{0,1}(a|x|e|l|v|u|d|m|c|p|t)(?:(q\\d*)|(v)|(n)|(f)|(o\\d*)|(d)|(i)|(z)|(g)|(0|1|2)|(e)|(y)|(t))*(w[=].*){0,1}";
      Pattern pat_p;
      Matcher mat_p;
      String mat_str;

      pat_p = Pattern.compile(regex1);
      mat_p = pat_p.matcher(optstr);
      ret = mat_p.matches();

      if (ret) {
          for (i=0 ; i<=mat_p.groupCount() ; i++) {
            mat_str = mat_p.group(i);
            if (mat_str==null) continue;
            mylogger.log(Level.FINEST,Integer.toString(i)+": "+mat_str);
            switch (i) {
            case 1:
                if (mat_str.compareTo("a")==0) {
                  cmd = CMD_ADD;
                } else if (mat_str.compareTo("e")==0) {
                  cmd = CMD_EXTRACT;
                } else if (mat_str.compareTo("x")==0) {
                  cmd = CMD_EXTRACT;
                } else if (mat_str.compareTo("l")==0) {
                  cmd = CMD_LIST;
                } else if (mat_str.compareTo("v")==0) {
                  cmd = CMD_VERBOSELIST;
                } else if (mat_str.compareTo("u")==0) {
                  cmd = CMD_UPDATE;
                } else if (mat_str.compareTo("d")==0) {
                  cmd = CMD_DELETE;
                } else if (mat_str.compareTo("c")==0) {
                  cmd = CMD_RECONSTRUCT;
                } else if (mat_str.compareTo("p")==0) {
                  cmd = CMD_PRINTSTDOUT;
                } else if (mat_str.compareTo("t")==0) {
                  cmd = CMD_TEST;
                } else if (mat_str.compareTo("m")==0) {
                    cmd = CMD_ADD;
                    deleteFiles=true;
                    }
                break;
            case 2:
                try {
                  if (mat_str.charAt(0) == 'q') {
                      if (mat_str.length()>1) {
                        quiet=Integer.parseInt(mat_str.substring(1));
                      } else {
                        quiet++;
                      }
                  }
                } catch (Exception e) {
                  
                }
                break;
            case 3:
                if (mat_str.compareTo("v")==0) {
                  verbose = true;
                }
                break;
            case 4:
                if (mat_str.compareTo("n")==0) {
                  notExecute=true;
                }
                break;
                case 5:
                    if (mat_str.compareTo("f")==0) {
                        force = true;
                    }
                    break;
            case 6:
                try {
                  if (mat_str.charAt(0) == 'o') {
                      if (mat_str.length()>1) {
                        compressionMethod=Integer.parseInt(mat_str.substring(1));
                      }
                  }
                } catch (Exception e) {
                  
                }
                break;
            case 7:
                if (mat_str.compareTo("d")==0) {
                  deleteFiles=true;
                }
                break;
            case 8:
                if (mat_str.compareTo("i")==0) {
                  ignorePath=true;
                }
                break;
            case 9:
                if (mat_str.compareTo("z")==0) {
                  fileNotCompress=true;
                }
                break;
            case 10:
                if (mat_str.compareTo("g")==0) {
                  genericFormat=true;
                }
                break;
            case 11:
                if (mat_str.compareTo("0")==0) {
                  headerLevel=0;
                } else if (mat_str.compareTo("1")==0) {
                  headerLevel=1;
                } else if (mat_str.compareTo("2")==0) {
                  headerLevel=2;
                }
                break;
            case 12:
                if (mat_str.compareTo("e")==0) {
                  eucMode = true;
                }
                break;
            case 13:
                if (mat_str.compareTo("y")==0) {
                  try {
                      Locale.setDefault(Locale.JAPAN);
                  } catch (Exception e) {
                      mylogger.warning("Set locale to Japan error: "+e.toString());
                  }
                }
                break;
            case 14:
                if (mat_str.compareTo("t")==0) {
                  textMode = true;
                }
                break;
            case 15:
                try {
                  if (mat_str.charAt(0) == 'w' && mat_str.charAt(1)== '=') {
                      if (mat_str.length()>2) {
                        specifyExtractDirectory=mat_str.substring(2);
                      }
                  }
                } catch (Exception e) {
                  
                }
                break;
            default:
                break;
            }
          }
      } else {
          mylogger.log(Level.INFO,"Not match");
      }

      return ret;
    }


Generated by  Doxygen 1.6.0   Back to index