Package org.watermint.sourcecolon.org.opensolaris.opengrok.search

Examples of org.watermint.sourcecolon.org.opensolaris.opengrok.search.QueryBuilder


        }
    }

    private String createUrl(boolean menu) {
        StringBuilder url = new StringBuilder(64);
        QueryBuilder qb = getBuilder();
        if (menu) {
            url.append("search?");
        } else {
            Util.appendQuery(url, "sort", order.toString());
        }
        if (qb != null) {
            Util.appendQuery(url, "q", qb.getFreetext());
            Util.appendQuery(url, "defs", qb.getDefs());
            Util.appendQuery(url, "refs", qb.getRefs());
            Util.appendQuery(url, "path", qb.getPath());
        }
        return url.toString();
    }
View Full Code Here


            // No index, no definitions...
            return null;
        }

        try {
            Query q = new QueryBuilder().setPath(path).build();
            try (IndexSearcher searcher = new IndexSearcher(indexReader)) {
                TopDocs top = searcher.search(q, 1);
                if (top.totalHits == 0) {
                    // No hits, no definitions...
                    return null;
View Full Code Here

     *
     * @return a query builder with all relevant fields populated.
     */
    public QueryBuilder getQueryBuilder() {
        if (queryBuilder == null) {
            queryBuilder = new QueryBuilder().setFreetext(req.getParameter("q")).setDefs(req.getParameter("defs")).setRefs(req.getParameter("refs")).setPath(req.getParameter("path"));

            // This is for backward compatibility with links created by OpenGrok
            // 0.8.x and earlier. We used to concatenate the entire query into a
            // single string and send it in the t parameter. If we get such a
            // link, just add it to the freetext field, and we'll get the old
View Full Code Here

            return "";
        }
    }

    public String getCurrentQueryString() {
        QueryBuilder queryBuilder = getQueryBuilder();

        try {
            return queryBuilder.build().toString();
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }
View Full Code Here

    }

    public String getCurrentMatch() {
        ByteArrayOutputStream content = new ByteArrayOutputStream();
        OutputStreamWriter writer = new OutputStreamWriter(content);
        QueryBuilder queryBuilder = getQueryBuilder();

        try {
            Context sourceContext = new Context(queryBuilder.build(), queryBuilder.getQueries());
            sourceContext.getContext(IOUtils.readerWithCharsetDetect(getResourceFile()), writer, req.getContextPath() + Prefix.XREF_P, null, getPath(), null, false, null);
            writer.flush();
            return content.toString();
        } catch (IOException | ParseException e) {
            e.printStackTrace();
View Full Code Here

        }
    }

    private StringBuilder createUrl(SearchHelper sh, boolean menu) {
        StringBuilder url = new StringBuilder(64);
        QueryBuilder qb = sh.builder;
        if (menu) {
            url.append("search?");
        } else {
            Util.appendQuery(url, "sort", sh.order.toString());
        }
        if (qb != null) {
            Util.appendQuery(url, "q", qb.getFreetext());
            Util.appendQuery(url, "defs", qb.getDefs());
            Util.appendQuery(url, "refs", qb.getRefs());
            Util.appendQuery(url, "path", qb.getPath());
        }
        return url;
    }
View Full Code Here

TOP

Related Classes of org.watermint.sourcecolon.org.opensolaris.opengrok.search.QueryBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.