예제 #1
0
  private void fillSettings(CvsRootParser root, Settings settings) {
    String[] hostAndPort = root.HOST.split(":");

    settings.setHost(hostAndPort[0]);

    if (hostAndPort.length > 1) {
      settings.setPort(Integer.parseInt(hostAndPort[1]));
    } else if (root.PORT != null) {
      try {
        settings.setPort(Integer.parseInt(root.PORT));
      } catch (NumberFormatException e) {
        settings.setHost(hostAndPort[0]);
      }
    } else {
      settings.setHost(hostAndPort[0]);
    }

    String repository = root.REPOSITORY;
    if (StringUtil.startsWithChar(repository, ':')) repository = repository.substring(1);

    settings.setRepository(repository);

    String[] userAndPassword = root.USER_NAME.split(":");

    settings.setUser(userAndPassword[0]);

    if (root.PROXY_HOST != null) {
      settings.setUseProxy(root.PROXY_HOST, root.PROXY_PORT);
    }
  }
예제 #2
0
  public static Settings parse(String[] args) {
    Settings settings = new Settings();
    for (String arg : args) {
      String unit = arg.trim();

      if (!unit.startsWith("-")) continue;

      if (unit.equalsIgnoreCase("-help")) {
        help();
        System.exit(0);
      }

      String[] paramValue = unit.split("=");
      String param = paramValue[0].trim();
      String value = paramValue[1].trim();

      if ("-host".equalsIgnoreCase(param)) {
        settings.setHost(value);
      } else if ("-port".equalsIgnoreCase(param)) {
        settings.setPort(Integer.parseInt(value));
      } else if ("-workerThreads".equalsIgnoreCase(param)) {
        settings.setWorkerThreads(Integer.parseInt(value));
      } else if ("-selectorThreads".equalsIgnoreCase(param)) {
        settings.setSelectorThreads(Integer.parseInt(value));
      } else if ("-useLeaderFollower".equalsIgnoreCase(param)) {
        settings.setUseLeaderFollower(Boolean.valueOf(value));
      } else if ("-binary".equalsIgnoreCase(param)) {
        settings.setBinary(Boolean.valueOf(value));
      } else if ("-chunked".equalsIgnoreCase(param)) {
        settings.setChunked(Boolean.valueOf(value));
      }
    }

    return settings;
  }