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

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

?? dbquery.java

?? 這是學習Java必須讀懂兩套源代碼
?? 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一区二区三区免费野_久草精品视频
日本欧美一区二区三区乱码| 91丨porny丨国产入口| 日本系列欧美系列| 亚洲国产中文字幕| 亚洲成人高清在线| 亚洲成av人片www| 日本vs亚洲vs韩国一区三区二区| 日韩和欧美一区二区三区| 日韩黄色在线观看| 久久99国产精品久久| 国产中文字幕精品| 国产精品1区2区3区| 成人免费高清在线| 91蜜桃网址入口| 欧美亚洲尤物久久| 91精品国产一区二区三区香蕉| 欧美一区二区高清| 精品久久久久久亚洲综合网| 久久免费看少妇高潮| 亚洲国产精品精华液2区45| 国产精品视频第一区| 亚洲免费观看在线观看| 午夜伦理一区二区| 六月婷婷色综合| 国产**成人网毛片九色| 96av麻豆蜜桃一区二区| 欧美三级日韩三级国产三级| 日韩欧美激情在线| 国产精品久久毛片| 亚洲一区二区偷拍精品| 蜜桃精品在线观看| 国产91精品免费| 色av成人天堂桃色av| 欧美猛男男办公室激情| 久久理论电影网| 亚洲免费观看高清完整| 免费国产亚洲视频| 成人精品国产免费网站| 欧美三级电影精品| 久久综合国产精品| 一区二区高清免费观看影视大全 | 亚洲国产你懂的| 麻豆国产欧美一区二区三区| 成人高清伦理免费影院在线观看| 在线观看av一区| 精品国产网站在线观看| 亚洲天堂中文字幕| 免费欧美高清视频| 色综合天天做天天爱| 欧美一区二区视频免费观看| 国产精品国产三级国产aⅴ无密码| 婷婷开心激情综合| 成人app软件下载大全免费| 91 com成人网| 国产精品日日摸夜夜摸av| 天天综合色天天综合| 成人夜色视频网站在线观看| 666欧美在线视频| 国产精品天天看| 日韩不卡一二三区| 91香蕉国产在线观看软件| 精品理论电影在线| 亚洲一区二区三区四区的| 国产呦精品一区二区三区网站| 欧美吞精做爰啪啪高潮| 欧美精品一区二区三区蜜臀| 午夜影院久久久| 99热在这里有精品免费| 久久综合色天天久久综合图片| 亚洲成精国产精品女| 一本色道久久综合亚洲精品按摩| 精品国产乱码久久久久久浪潮 | 亚洲一区二区三区视频在线播放| 国产精品系列在线观看| 欧美另类z0zxhd电影| 亚洲色图一区二区三区| 丁香六月久久综合狠狠色| 日韩视频免费直播| 亚洲国产精品久久艾草纯爱| av日韩在线网站| 国产色产综合色产在线视频| 久久超级碰视频| 欧美肥胖老妇做爰| 亚洲国产精品久久久久婷婷884| 99久久国产免费看| 国产精品午夜春色av| 国产成人综合网站| 日韩欧美的一区| 日本美女视频一区二区| 欧美日韩一区二区三区视频| 亚洲色欲色欲www| 99久久国产综合精品麻豆| 欧美极品xxx| 高清日韩电视剧大全免费| 久久这里只有精品首页| 国产曰批免费观看久久久| 精品区一区二区| 国产在线不卡一区| 久久青草国产手机看片福利盒子 | 不卡一二三区首页| 国产精品久久久久久久久晋中| 国产精一区二区三区| 久久精品日产第一区二区三区高清版| 经典三级一区二区| 2022国产精品视频| 国产原创一区二区三区| 久久九九久精品国产免费直播| 国产在线播放一区二区三区| 久久精品夜色噜噜亚洲aⅴ| 国产精品一区久久久久| 日本一区二区免费在线观看视频| 国产不卡视频在线播放| 综合婷婷亚洲小说| 色婷婷综合激情| 亚洲成人一区二区| 91精品国产91综合久久蜜臀| 男男gaygay亚洲| 精品久久久久久最新网址| 高清国产一区二区三区| 亚洲欧美区自拍先锋| 欧美无砖专区一中文字| 欧美a级理论片| 久久午夜电影网| 99国产精品久久| 午夜伊人狠狠久久| 精品日韩99亚洲| 9色porny自拍视频一区二区| 亚洲精品国产无套在线观| 欧美精品久久久久久久多人混战| 日本亚洲欧美天堂免费| 国产色婷婷亚洲99精品小说| 色狠狠综合天天综合综合| 亚洲不卡在线观看| 久久久五月婷婷| 91小视频免费观看| 日韩av电影免费观看高清完整版 | 亚洲大尺度视频在线观看| 欧美另类久久久品| 国产精品一级片在线观看| 亚洲人123区| 日韩欧美国产1| 99精品国产一区二区三区不卡| 午夜精品爽啪视频| 久久久久久久综合狠狠综合| 色哟哟在线观看一区二区三区| 日韩高清欧美激情| 久久久三级国产网站| 欧美亚洲另类激情小说| 精品亚洲国产成人av制服丝袜| 亚洲欧洲三级电影| 91精品国产综合久久精品app | 不卡欧美aaaaa| 日韩精品色哟哟| 国产精品久久精品日日| 欧美一区二区三区免费在线看 | 欧美精品一二三区| 国产福利91精品| 视频一区中文字幕国产| 国产精品久久久久久久久久免费看 | 日韩制服丝袜先锋影音| 国产精品日日摸夜夜摸av| 欧美一区日本一区韩国一区| 成人黄色一级视频| 日本女人一区二区三区| 亚洲精品一二三区| 久久九九99视频| 91精品综合久久久久久| 色综合久久久网| 国内精品在线播放| 三级一区在线视频先锋 | 亚洲免费资源在线播放| 久久嫩草精品久久久久| 欧美精品第一页| 成人丝袜高跟foot| 麻豆久久一区二区| 亚洲国产一区二区三区| 中文字幕一区二区在线播放| 日韩精品一区二区三区视频在线观看 | 一区二区在线观看不卡| 久久久久99精品国产片| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲精品自拍动漫在线| 亚洲国产高清在线| 精品久久国产字幕高潮| 宅男在线国产精品| 欧美日韩卡一卡二| 色域天天综合网| 成人app网站| 成人伦理片在线| 国产成人综合在线播放| 精品亚洲成av人在线观看| 秋霞影院一区二区| 日韩黄色片在线观看| 午夜成人在线视频| 亚洲一区二区视频| 亚洲自拍偷拍av| 一区二区三区四区视频精品免费 | 亚洲欧美视频在线观看视频| 欧美极品aⅴ影院| 国产精品卡一卡二卡三|