示例#1
0
 /**
  * Adds the names of the database that has been addressed by the argument index. No databases will
  * be added if the argument uses glob syntax.
  *
  * @param db databases
  * @param a argument index
  * @return {@code false} if database cannot be determined due to glob syntax
  */
 protected final boolean databases(final StringList db, final int a) {
   // return true if the addressed database argument does not exists
   if (args.length <= a || args[a] == null) return true;
   final boolean noglob = !args[a].matches(".*[\\?\\*,].*");
   if (noglob) db.add(args[a]);
   return noglob;
 }
示例#2
0
文件: BaseX.java 项目: james-jw/basex
  @Override
  protected final void parseArgs() throws IOException {
    ops = new IntList();
    vals = new StringList();

    final MainParser arg = new MainParser(this);
    while (arg.more()) {
      final char c;
      String v = null;
      if (arg.dash()) {
        c = arg.next();
        if (c == 'd') {
          // activate debug mode
          Prop.debug = true;
        } else if (c == 'b'
            || c == 'c'
            || c == 'C'
            || c == 'i'
            || c == 'I'
            || c == 'o'
            || c == 'q'
            || c == 'r'
            || c == 's'
            || c == 't' && local()) {
          // options followed by a string
          v = arg.string();
        } else if (c == 'D' && local()
            || c == 'u' && local()
            || c == 'R'
            || c == 'v'
            || c == 'V'
            || c == 'w'
            || c == 'x'
            || c == 'X'
            || c == 'z') {
          // options to be toggled
          v = "";
        } else if (!local()) {
          // client options: need to be set before other options
          if (c == 'n') {
            // set server name
            context.soptions.set(StaticOptions.HOST, arg.string());
          } else if (c == 'p') {
            // set server port
            context.soptions.set(StaticOptions.PORT, arg.number());
          } else if (c == 'P') {
            // specify password
            context.soptions.set(StaticOptions.PASSWORD, arg.string());
          } else if (c == 'U') {
            // specify user name
            context.soptions.set(StaticOptions.USER, arg.string());
          } else {
            throw arg.usage();
          }
        } else {
          throw arg.usage();
        }
      } else {
        v = arg.string().trim();
        // interpret as command file if input string ends with command script suffix
        c = v.endsWith(IO.BXSSUFFIX) ? 'c' : 'Q';
      }
      if (v != null) {
        ops.add(c);
        vals.add(v);
      }
    }
  }