亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dbquery.java

?? Jvie論壇的程序
?? JAVA
字號:
/**
 * Copyright (C) 2001 Yasna.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        Yasna.com (http://www.yasna.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Yazd" and "Yasna.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact yazd@yasna.com.
 *
 * 5. Products derived from this software may not be called "Yazd",
 *    nor may "Yazd" appear in their name, without prior written
 *    permission of Yasna.com.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL YASNA.COM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of Yasna.com. For more information
 * on Yasna.com, please see <http://www.yasna.com>.
 */

/**
 * Copyright (C) 2000 CoolServlets.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        CoolServlets.com (http://www.coolservlets.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Jive" and "CoolServlets.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact webmaster@coolservlets.com.
 *
 * 5. Products derived from this software may not be called "Jive",
 *    nor may "Jive" appear in their name, without prior written
 *    permission of CoolServlets.com.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL COOLSERVLETS.COM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CoolServlets.com. For more information
 * on CoolServlets.com, please see <http://www.coolservlets.com>.
 */

package com.Yasna.forum.database;

import java.util.Date;
import java.util.Iterator;
import java.io.IOException;
import java.io.File;

import com.lucene.analysis.*;
import com.lucene.analysis.standard.*;
import com.lucene.document.*;
import com.lucene.store.*;
import com.lucene.search.*;
import com.lucene.queryParser.*;
import com.lucene.index.*;

import com.Yasna.forum.*;

/**
 * Database implementation of the Query interface using Lucene.
 */
public class DbQuery implements com.Yasna.forum.Query {

    /**
     * The query String to use for searching. Set it the empty String by
     * default so that if the user fails to set a query String, there won't
     * be errors.
     */
    private String queryString = "";
    private java.util.Date beforeDate = null;
    private java.util.Date afterDate = null;
    private User user = null;
    private ForumThread thread = null;

    /**
     * The results of the query as an array of message ID's.
     */
    private int [] results = null;

    private Forum forum;
    private DbForumFactory factory;

    /**
     * The maximum number of results to return with a search.
     */
    private static final int MAX_RESULTS_SIZE = 500;

    private static String indexPath = null;
    private static IndexReader reader;
    private static Searcher searcher;
    private static Directory searchDirectory = null;
    private static long indexLastModified;
    private static Analyzer analyzer = new StandardAnalyzer();

    public DbQuery(Forum forum, DbForumFactory factory){
        this.forum = forum;
        this.factory = factory;
    }

    public void setQueryString(String queryString) {
        this.queryString = queryString;
        //reset results
        results = null;
    }

    public String getQueryString() {
        return queryString;
    }

    public void setBeforeDate(java.util.Date beforeDate) {
        this.beforeDate = beforeDate;
        //reset results
        results = null;
    }

    public java.util.Date getBeforeDate() {
        return beforeDate;
    }

    public void setAfterDate(java.util.Date afterDate){
        this.afterDate = afterDate;
        //reset results
        results = null;
    }

    public java.util.Date getAfterDate(){
        return afterDate;
    }

    public User getFilteredUser() {
        return user;
    }

    public void filterOnUser(User user) {
        this.user = user;
        results = null;
    }

    public ForumThread getFilteredThread() {
        return thread;
    }

    public void filterOnThread(ForumThread thread) {
        this.thread = thread;
        results = null;
    }

    public int resultCount() {
        if (results == null) {
            executeQuery();
        }
        return results.length;
    }

    public Iterator results() {
        if (results == null) {
            executeQuery();
        }
        return new DbQueryIterator(results, factory);
    }

    public Iterator results(int startIndex, int numResults){
        if (results == null) {
            executeQuery();
        }
        return new DbQueryIterator(results, factory, startIndex, numResults);
    }

    /**
     * Execute the query and store the results in the results array.
     */
    private void executeQuery() {
        try {
            Searcher searcher = getSearcher();
            if (searcher == null) {
                //Searcher can be null if the index doesn't exist.
                results = new int[0];
                return;
            }

            com.lucene.search.Query bodyQuery =
                QueryParser.parse(queryString, "body", analyzer);

            com.lucene.search.Query subjectQuery =
                QueryParser.parse(queryString, "subject", analyzer);

            String forumID = Integer.toString(forum.getID());

            BooleanQuery comboQuery = new BooleanQuery();
            comboQuery.add(subjectQuery,false,false);
            comboQuery.add(bodyQuery,false,false);

            MultiFilter multiFilter = new MultiFilter(3);

            //Forum filter
            multiFilter.add(new FieldFilter("forumID", forumID));

            //Date filter
            if (beforeDate != null || afterDate != null) {
                if (beforeDate != null && afterDate != null) {
                    multiFilter.add(new DateFilter("creationDate", beforeDate, afterDate));
                }
                else if (beforeDate == null) {
                    multiFilter.add(DateFilter.After("creationDate", afterDate));
                }
                else {
                    multiFilter.add(DateFilter.Before("creationDate", beforeDate));
                }
            }

            //User filter
            if (user != null) {
                String userID = Integer.toString(user.getID());
                multiFilter.add(new FieldFilter("userID", userID));
            }

            //Thread filter
            if (thread != null) {
                String threadID = Integer.toString(thread.getID());
                multiFilter.add(new FieldFilter("threadID", threadID));
            }

            Hits hits = searcher.search(comboQuery, multiFilter);
            //Don't return more search results than the maximum number allowed.
            int numResults = hits.length() < MAX_RESULTS_SIZE ?
                    hits.length() : MAX_RESULTS_SIZE;
            int [] messages = new int[numResults];
            for (int i=0; i<numResults; i++) {
                messages[i] = Integer.parseInt( ((Document)hits.doc(i)).get("messageID") );
            }
            results = messages;
        }
        catch (Exception e) {
            e.printStackTrace();
            results = new int[0];
        }
    }

    /**
     * Returns a Lucene Searcher that can be used to execute queries. Lucene
     * can handle index reading even while updates occur. However, in order
     * for index changes to be reflected in search results, the reader must
     * be re-opened whenever the modifiedDate changes.<p>
     *
     * The location of the index is the "search" subdirectory in [yazdHome]. If
     * yazdHome is not set correctly, this method will fail.
     *
     * @return a Searcher that can be used to execute queries.
     */
    private static Searcher getSearcher() throws IOException {
        if (indexPath == null) {
            //Get path of where search index should be. It should be
            //the search subdirectory of [yazdHome].
            String yazdHome = PropertyManager.getProperty("yazdHome");
            if (yazdHome == null) {
                System.err.println("ERROR: the yazdHome property is not set.");
                throw new IOException("Unable to open index for searching " +
                        "because yazdHome was not set.");
            }
            indexPath =  yazdHome + File.separator + "search";
        }

        if (searcher == null) {
            //Acquire a lock -- analyzer is a convenient object to do this on.
            synchronized(analyzer) {
                if (searcher == null) {
                    if (indexExists(indexPath)) {
                        searchDirectory = new FSDirectory(indexPath, false);
                        reader = IndexReader.open(searchDirectory);
                        indexLastModified = reader.lastModified(searchDirectory);
                        searcher = new IndexSearcher(reader);
                    }
                    //Otherwise, the index doesn't exist, so return null.
                    else {
                        return null;
                    }
                }
            }
        }
        if (reader.lastModified(searchDirectory) > indexLastModified) {
            synchronized (analyzer) {
                if (reader.lastModified(searchDirectory) > indexLastModified) {
                    if (indexExists(indexPath)) {
                        indexLastModified = reader.lastModified(searchDirectory);
                        //We need to close the indexReader because it has changed.
                        //Re-opening it will make changes visible.
                        reader.close();

                        searchDirectory = new FSDirectory(indexPath, false);
                        reader = IndexReader.open(searchDirectory);
                        searcher = new IndexSearcher(reader);
                    }
                    //Otherwise, the index doesn't exist, so return null.
                    else {
                        return null;
                    }
                }
            }
        }
        return searcher;
    }

    /**
     * Returns true if the search index exists at the specified path.
     *
     * @param indexPath the path to check for the search index at.
     */
    private static boolean indexExists(String indexPath) {
        //Lucene always creates a file called "segments" -- if it exists, we
        //assume that the search index exists.
        File segments = new File(indexPath + File.separator + "segments");
        return segments.exists();
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99re成人精品视频| 久久综合国产精品| 欧美mv和日韩mv的网站| 国产精品动漫网站| 日本成人超碰在线观看| 91美女片黄在线观看91美女| 91精品国产入口在线| 亚洲欧美日韩国产一区二区三区| 日韩黄色小视频| 91九色最新地址| 国产目拍亚洲精品99久久精品| 亚洲影视资源网| 91啪九色porn原创视频在线观看| 日韩精品最新网址| 亚洲成人激情社区| 色狠狠桃花综合| 国产精品免费视频网站| 久久不见久久见免费视频1| 欧美日韩亚洲高清一区二区| 亚洲男女毛片无遮挡| 成人精品国产福利| 国产欧美一区二区在线| 激情久久五月天| 日韩一区二区中文字幕| 午夜欧美2019年伦理 | 亚洲欧洲精品一区二区精品久久久| 日本成人中文字幕| 337p亚洲精品色噜噜噜| 天堂va蜜桃一区二区三区 | 亚洲精品免费一二三区| 成人精品高清在线| 国产精品午夜在线| 成人性色生活片免费看爆迷你毛片| 久久这里只有精品视频网| 老司机免费视频一区二区三区| 欧美一区二区三区四区久久 | 欧美日韩在线直播| 一区二区三区四区国产精品| 99精品偷自拍| 亚洲综合丝袜美腿| 欧美日韩在线电影| 麻豆国产精品777777在线| 日韩欧美一区中文| 国产美女视频一区| 中文字幕在线观看一区| 色综合夜色一区| 亚洲不卡av一区二区三区| 欧美日韩国产区一| 久久91精品国产91久久小草| 国产日韩欧美a| 色哟哟精品一区| 婷婷中文字幕一区三区| 日韩精品一区二区三区在线| 国产成人精品免费网站| 亚洲日本电影在线| 欧美日韩一本到| 国产制服丝袜一区| 亚洲三级小视频| 欧美一区二区精品在线| 国产91清纯白嫩初高中在线观看| 亚洲视频电影在线| 日韩一区二区三区电影在线观看| 国产suv精品一区二区三区| 亚洲免费在线观看| 精品国产露脸精彩对白| 99精品视频一区| 久久99精品久久久久久| 亚洲嫩草精品久久| 欧美成人vr18sexvr| 99久久国产综合精品麻豆| 日韩va亚洲va欧美va久久| 国产精品美女视频| 日韩午夜精品视频| 91在线视频观看| 久久99国产精品久久99| 亚洲国产一区二区三区| 久久久久久一级片| 欧美精品成人一区二区三区四区| 国产成人免费网站| 日韩成人伦理电影在线观看| 中文字幕一区不卡| 欧美大黄免费观看| 欧美日韩一区不卡| 99久久亚洲一区二区三区青草| 麻豆精品精品国产自在97香蕉| 亚洲欧美日韩综合aⅴ视频| 久久影音资源网| 在线播放国产精品二区一二区四区 | 精品一区二区日韩| 婷婷成人综合网| 亚洲欧美激情小说另类| 国产日韩欧美高清| 精品国产一区二区三区四区四| 欧美一a一片一级一片| 成人免费看黄yyy456| 国产一区二区视频在线| 日产精品久久久久久久性色| 亚洲视频你懂的| 国产精品乱码一区二区三区软件| 日韩一区二区三免费高清| 91激情五月电影| 91啪九色porn原创视频在线观看| 国产一区二区在线观看免费| 奇米影视一区二区三区小说| 日本网站在线观看一区二区三区| 伊人婷婷欧美激情| 亚洲人成精品久久久久久| 中文字幕+乱码+中文字幕一区| 久久综合久久鬼色中文字| 精品国产免费久久| 欧美精品一区二区精品网| 欧美成人video| 精品国产露脸精彩对白| 精品国产自在久精品国产| 欧美www视频| 精品乱人伦一区二区三区| 精品久久久久久久久久久久包黑料 | 99视频在线观看一区三区| 国产成人精品免费在线| 粉嫩嫩av羞羞动漫久久久 | 国产精品麻豆久久久| 国产欧美精品一区二区三区四区| 久久久久久久久久久久久女国产乱 | 一区二区三区成人| 亚洲一二三级电影| 视频一区二区三区在线| 日韩在线观看一区二区| 蜜桃av一区二区三区电影| 青青草国产成人av片免费| 久久不见久久见中文字幕免费| 国内外精品视频| 波多野结衣欧美| 一本久久综合亚洲鲁鲁五月天| 色94色欧美sute亚洲线路一久| 欧美日韩成人激情| 精品国产乱码久久| 亚洲丝袜精品丝袜在线| 亚洲高清不卡在线| 精品影视av免费| 99久久综合狠狠综合久久| 欧美中文字幕不卡| 日韩精品一区在线| 国产精品网站在线| 亚洲午夜在线电影| 国产一区二区中文字幕| youjizz国产精品| 欧美一三区三区四区免费在线看| 久久久久国产一区二区三区四区| 亚洲精品老司机| 美女免费视频一区| 91丝袜呻吟高潮美腿白嫩在线观看| 欧美精品777| 国产丝袜在线精品| 午夜欧美电影在线观看| 国产成人免费av在线| 欧美性猛交xxxxxxxx| 精品国偷自产国产一区| 一区二区三区国产豹纹内裤在线| 久久国产精品99精品国产| 99久久婷婷国产综合精品电影| 91精品国产综合久久福利| 中文字幕亚洲在| 精品亚洲成a人在线观看| 色综合中文字幕国产 | 日韩欧美激情在线| 亚洲精品国久久99热| 国产一区二区在线看| 欧美探花视频资源| 中文天堂在线一区| 久久精品国内一区二区三区 | 成人av小说网| 欧美一级夜夜爽| 亚洲免费大片在线观看| 国产精品69久久久久水密桃| 777亚洲妇女| 亚洲国产精品久久一线不卡| 成人精品gif动图一区| 2020国产精品自拍| 日韩av一二三| 欧亚一区二区三区| 亚洲欧美国产77777| 99亚偷拍自图区亚洲| 久久精品视频在线看| 久久69国产一区二区蜜臀| 欧美日韩不卡在线| 亚洲一级在线观看| 欧美曰成人黄网| 亚洲精品v日韩精品| 91女神在线视频| 国产精品久久久久影视| 成人免费毛片嘿嘿连载视频| 国产日产欧产精品推荐色 | 国产欧美日本一区视频| 国产综合色精品一区二区三区| 日韩一区二区三区视频| 人人狠狠综合久久亚洲| 91精品国产免费| 老汉av免费一区二区三区| 日韩视频不卡中文| 韩国成人福利片在线播放|