Java 类org.apache.lucene.util.CommandLineUtil 实例源码

项目:NYBC    文件:IndexUpgrader.java   
/** Main method to run {code IndexUpgrader} from the
 *  command-line. */
@SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException {
  String path = null;
  boolean deletePriorCommits = false;
  PrintStream out = null;
  String dirImpl = null;
  int i = 0;
  while (i<args.length) {
    String arg = args[i];
    if ("-delete-prior-commits".equals(arg)) {
      deletePriorCommits = true;
    } else if ("-verbose".equals(arg)) {
      out = System.out;
    } else if (path == null) {
      path = arg;
    } else if ("-dir-impl".equals(arg)) {
      if (i == args.length - 1) {
        System.out.println("ERROR: missing value for -dir-impl option");
        System.exit(1);
      }
      i++;
      dirImpl = args[i];
    }else {
      printUsage();
    }
    i++;
  }
  if (path == null) {
    printUsage();
  }

  Directory dir = null;
  if (dirImpl == null) {
    dir = FSDirectory.open(new File(path));
  } else {
    dir = CommandLineUtil.newFSDirectory(dirImpl, new File(path));
  }
  new IndexUpgrader(dir, Version.LUCENE_CURRENT, out, deletePriorCommits).upgrade();
}
项目:read-open-source-code    文件:IndexUpgrader.java   
static IndexUpgrader parseArgs(String[] args) throws IOException {
  String path = null;
  boolean deletePriorCommits = false;
  PrintStream out = null;
  String dirImpl = null;
  int i = 0;
  while (i<args.length) {
    String arg = args[i];
    if ("-delete-prior-commits".equals(arg)) {
      deletePriorCommits = true;
    } else if ("-verbose".equals(arg)) {
      out = System.out;
    } else if ("-dir-impl".equals(arg)) {
      if (i == args.length - 1) {
        System.out.println("ERROR: missing value for -dir-impl option");
        System.exit(1);
      }
      i++;
      dirImpl = args[i];
    } else if (path == null) {
      path = arg;
    }else {
      printUsage();
    }
    i++;
  }
  if (path == null) {
    printUsage();
  }

  Directory dir = null;
  if (dirImpl == null) {
    dir = FSDirectory.open(new File(path));
  } else {
    dir = CommandLineUtil.newFSDirectory(dirImpl, new File(path));
  }
  return new IndexUpgrader(dir, Version.LUCENE_CURRENT, out, deletePriorCommits);
}
项目:read-open-source-code    文件:IndexUpgrader.java   
static IndexUpgrader parseArgs(String[] args) throws IOException {
  String path = null;
  boolean deletePriorCommits = false;
  PrintStream out = null;
  String dirImpl = null;
  int i = 0;
  while (i<args.length) {
    String arg = args[i];
    if ("-delete-prior-commits".equals(arg)) {
      deletePriorCommits = true;
    } else if ("-verbose".equals(arg)) {
      out = System.out;
    } else if ("-dir-impl".equals(arg)) {
      if (i == args.length - 1) {
        System.out.println("ERROR: missing value for -dir-impl option");
        System.exit(1);
      }
      i++;
      dirImpl = args[i];
    } else if (path == null) {
      path = arg;
    }else {
      printUsage();
    }
    i++;
  }
  if (path == null) {
    printUsage();
  }

  Directory dir = null;
  if (dirImpl == null) {
    dir = FSDirectory.open(new File(path));
  } else {
    dir = CommandLineUtil.newFSDirectory(dirImpl, new File(path));
  }
  return new IndexUpgrader(dir, Version.LUCENE_CURRENT, out, deletePriorCommits);
}
项目:Maskana-Gestor-de-Conocimiento    文件:IndexUpgrader.java   
static IndexUpgrader parseArgs(String[] args) throws IOException {
  String path = null;
  boolean deletePriorCommits = false;
  PrintStream out = null;
  String dirImpl = null;
  int i = 0;
  while (i<args.length) {
    String arg = args[i];
    if ("-delete-prior-commits".equals(arg)) {
      deletePriorCommits = true;
    } else if ("-verbose".equals(arg)) {
      out = System.out;
    } else if ("-dir-impl".equals(arg)) {
      if (i == args.length - 1) {
        System.out.println("ERROR: missing value for -dir-impl option");
        System.exit(1);
      }
      i++;
      dirImpl = args[i];
    } else if (path == null) {
      path = arg;
    }else {
      printUsage();
    }
    i++;
  }
  if (path == null) {
    printUsage();
  }

  Directory dir = null;
  if (dirImpl == null) {
    dir = FSDirectory.open(new File(path));
  } else {
    dir = CommandLineUtil.newFSDirectory(dirImpl, new File(path));
  }
  return new IndexUpgrader(dir, Version.LUCENE_CURRENT, out, deletePriorCommits);
}