Search.java revision 5e0ccd8bb84a766f65680b4cc1e43b356d1d78b8
6bdda696b3ea703c47e87fea61017ec655f91d92nd * CDDL HEADER START
6bdda696b3ea703c47e87fea61017ec655f91d92nd * The contents of this file are subject to the terms of the
6bdda696b3ea703c47e87fea61017ec655f91d92nd * Common Development and Distribution License (the "License").
6bdda696b3ea703c47e87fea61017ec655f91d92nd * You may not use this file except in compliance with the License.
6bdda696b3ea703c47e87fea61017ec655f91d92nd * See LICENSE.txt included in this distribution for the specific
6bdda696b3ea703c47e87fea61017ec655f91d92nd * language governing permissions and limitations under the License.
0662ed52e814f8f08ef0e09956413a792584eddffuankg * When distributing Covered Code, include this CDDL HEADER in each
6bdda696b3ea703c47e87fea61017ec655f91d92nd * file and include the License file at LICENSE.txt.
6bdda696b3ea703c47e87fea61017ec655f91d92nd * If applicable, add the following below this CDDL HEADER, with the
6bdda696b3ea703c47e87fea61017ec655f91d92nd * fields enclosed by brackets "[]" replaced with your own identifying
6bdda696b3ea703c47e87fea61017ec655f91d92nd * information: Portions Copyright [yyyy] [name of copyright owner]
6bdda696b3ea703c47e87fea61017ec655f91d92nd * CDDL HEADER END
44f575c8cb19a7a5cd61664a7848be6bc197df02fuankg * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
44f575c8cb19a7a5cd61664a7848be6bc197df02fuankg * Use is subject to license terms.
6bdda696b3ea703c47e87fea61017ec655f91d92ndimport org.opensolaris.opengrok.configuration.RuntimeEnvironment;
6bdda696b3ea703c47e87fea61017ec655f91d92nd * Search and list the matching files
6bdda696b3ea703c47e87fea61017ec655f91d92nd@SuppressWarnings({"PMD.AvoidPrintStackTrace", "PMD.SystemPrintln"})
6bdda696b3ea703c47e87fea61017ec655f91d92ndfinal class Search {
6bdda696b3ea703c47e87fea61017ec655f91d92nd private static final String usage = "USAGE: Search -R <configuration.xml> [-d | -r | -p | -h | -f] 'query string' ..\n" + "\t -R <configuration.xml> Read configuration from the specified file\n" + "\t -d Symbol Definitions\n" + "\t -r Symbol References\n" + "\t -p Path\n" + "\t -h History\n" + "\t -f Full text";
6bdda696b3ea703c47e87fea61017ec655f91d92nd private final static SearchEngine engine = new SearchEngine();
6bdda696b3ea703c47e87fea61017ec655f91d92nd } catch (Exception e) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd return false;
6bdda696b3ea703c47e87fea61017ec655f91d92nd switch (cmd) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd RuntimeEnvironment.getInstance().readConfiguration(new File(getopt.getOptarg()));
6bdda696b3ea703c47e87fea61017ec655f91d92nd } catch (Exception e) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd return false;
6bdda696b3ea703c47e87fea61017ec655f91d92nd if (RuntimeEnvironment.getInstance().getDataRootPath() == null) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd System.err.println("You must specify a configuration file");
6bdda696b3ea703c47e87fea61017ec655f91d92nd return false;
6bdda696b3ea703c47e87fea61017ec655f91d92nd return true;
6bdda696b3ea703c47e87fea61017ec655f91d92nd return false;
6bdda696b3ea703c47e87fea61017ec655f91d92nd return true;
6bdda696b3ea703c47e87fea61017ec655f91d92nd * usage Search index "query" prunepath
6bdda696b3ea703c47e87fea61017ec655f91d92nd boolean success = false;
6bdda696b3ea703c47e87fea61017ec655f91d92nd System.err.println("Your search \"" + engine.getQuery() + "\" did not match any files.");
0662ed52e814f8f08ef0e09956413a792584eddffuankg String root = RuntimeEnvironment.getInstance().getSourceRootPath();
6bdda696b3ea703c47e87fea61017ec655f91d92nd System.out.println(file.getAbsolutePath() + ": [" + hit.getLine() + "]");
6bdda696b3ea703c47e87fea61017ec655f91d92nd private Search() {