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

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

?? dbtreewalker.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.sql.*;

import com.Yasna.forum.*;
import com.Yasna.util.*;

/**
 * Database implementation of the TreeWalker interface. This class is relatively
 * inefficient compared to how it will eventually be implemented. However,
 * a schema change is needed before that optimization is needed (represent
 * tree structure directly in schema).
 */
public class DbTreeWalker implements TreeWalker {

    /** DATABASE QUERIES **/
    private static final String GET_CHILD =
        "SELECT yazdMessageTree.childID, yazdMessage.creationDate FROM " +
        "yazdMessageTree, yazdMessage WHERE " +
        "yazdMessageTree.childID=yazdMessage.messageID AND " +
        "yazdMessageTree.parentID=? ORDER BY yazdMessage.creationDate";
    private static final String CHILD_COUNT =
        "SELECT count(*) FROM yazdMessageTree WHERE parentID=?";
    private static final String INDEX_OF_CHILD =
        "SELECT yazdMessageTree.childID, yazdMessage.creationDate " +
        "FROM yazdMessageTree, yazdMessage WHERE yazdMessageTree.childID=yazdMessage.messageID " +
        "AND yazdMessageTree.parentID=? ORDER BY yazdMessage.creationDate";

    private DbForumThread thread;
    private DbForumFactory factory;

    public DbTreeWalker(DbForumThread thread, DbForumFactory factory) {
        this.thread = thread;
        this.factory = factory;
    }

    /**
     * Returns the root of the tree. Returns null only if the tree has no nodes.
     *
     * @returns the root of the tree
     */
    public ForumMessage getRoot() {
        return thread.getRootMessage();
    }

    /**
     * Returns the child of parent at index index in the parent's child array.
     * This should not return null if index is a valid index for parent (that
     * is index >= 0 && index < getChildCount(parent)).
     *
     * @param parent the parent message.
     * @param index the index of the child.
     * @returns the child of parent at index.
     */
    public ForumMessage getChild(ForumMessage parent, int index) {
        ForumMessage message = null;
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(GET_CHILD);
            pstmt.setInt(1, parent.getID());
            ResultSet rs = pstmt.executeQuery();
            while (rs.next() && index > 0) {
                index--;
            }
            if (index == 0) {
                int messageID = rs.getInt(1);
                message = thread.getMessage(messageID);
            }
        }
        catch (Exception e) {
            System.err.println("Error in DbMessageTreeWalker:getChild("
                + index + ")-" + e);
            e.printStackTrace();
        }
        finally {
            try {  pstmt.close(); }
            catch (Exception e) { e.printStackTrace(); }
            try {  con.close();   }
            catch (Exception e) { e.printStackTrace(); }
        }
        return message;
    }

    /**
     * Returns the number of children of parent. Returns 0 if the node is a
     * leaf or if it has no children.
     *
     * @param parent a node in the tree, obtained from this data source.
     * @returns the number of children of the node parent.
     */
    public int getChildCount(ForumMessage parent) {
        int childCount = 0;
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(CHILD_COUNT);
            pstmt.setInt(1, parent.getID());
            ResultSet rs = pstmt.executeQuery();
            rs.next();
            childCount = rs.getInt(1);
        }
        catch (Exception e) {
            System.err.println("Error in DbTreeWalker:getChildCount()-"
                + e);
            e.printStackTrace();
        }
        finally {
            try {  pstmt.close(); }
            catch (Exception e) { e.printStackTrace(); }
            try {  con.close();   }
            catch (Exception e) { e.printStackTrace(); }
        }
        return childCount;
    }

    /**
     * Returns the total number of recursive children of a parent. Returns 0
     * if there are no children. This method is not intended to aid in
     * navigation of a Thread but is included as an added utility.
     */
    public int getRecursiveChildCount(ForumMessage parent) {
        int numChildren = 0;
        int num = getChildCount(parent);
        numChildren += num;
        for (int i=0; i<num; i++) {
            ForumMessage child = getChild(parent,i);
            if (child != null) {
                numChildren += getRecursiveChildCount(child);
            }
        }
        return numChildren;
    }

    /**
     * Returns the index of child in parent.
     */
    public int getIndexOfChild(ForumMessage parent, ForumMessage child) {
        int index = 0;
        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(INDEX_OF_CHILD);
            pstmt.setInt(1, parent.getID());
            rs = pstmt.executeQuery();
            while (rs.next()) {
                if (rs.getInt(1) == child.getID()) {
                    break;
                }
                index++;
            }
        }
        catch (Exception e) {
            System.err.println("Error in DbTreeWalker:getIndexOfChild()-" + e);
        }
        finally {
            try {  pstmt.close(); }
            catch (Exception e) { e.printStackTrace(); }
            try {  con.close();   }
            catch (Exception e) { e.printStackTrace(); }
        }
        return index;
    }

    /**
     * Returns true if node is a leaf. A node is a leaf when it has no children
     * messages.
     *
     * @param node a node in the tree, obtained from this data source
     * @returns true if node is a leaf
     */
    public boolean isLeaf(ForumMessage node) {
        return (getChildCount(node) == 0);
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99国产精品久久| 欧美性猛交xxxx黑人交| 在线亚洲人成电影网站色www| 精品日韩99亚洲| 亚洲欧洲综合另类| 国产一区二区免费视频| 91一区一区三区| 亚洲美女视频在线观看| 成人av综合在线| **欧美大码日韩| 国产91精品露脸国语对白| 欧美日韩1区2区| 韩国女主播成人在线| 粉嫩高潮美女一区二区三区| 欧美久久久久久久久中文字幕| 国产99久久久久| 国产精品美女久久久久av爽李琼| 91免费观看视频在线| 亚洲午夜电影网| 欧美日韩综合在线| 亚洲一区二区三区三| 欧美日韩黄视频| 久久99国产乱子伦精品免费| 精品国产一区二区三区av性色| 欧美韩日一区二区三区| 国内精品国产成人国产三级粉色 | 欧美理论在线播放| 欧美高清在线视频| 一区二区不卡在线播放 | 91久久精品午夜一区二区| 亚洲视频在线一区二区| 亚洲精品v日韩精品| 69堂精品视频| 亚洲一区二区高清| 久久综合久久综合久久| 亚洲韩国精品一区| 91麻豆福利精品推荐| 欧美激情一区在线观看| 在线视频国内自拍亚洲视频| 蜜桃久久av一区| 亚洲男女毛片无遮挡| 欧美激情在线一区二区三区| 欧美videos大乳护士334| 91看片淫黄大片一级| 波多野结衣欧美| 国产成人av资源| 国产成人在线色| 国产成人av在线影院| 懂色av一区二区三区免费看| 韩国精品一区二区| 韩国精品主播一区二区在线观看| 色婷婷综合激情| 色婷婷综合视频在线观看| 波多野结衣91| 欧美一区二区三区喷汁尤物| 欧美一区二区三区影视| 国产白丝精品91爽爽久久 | 欧美大度的电影原声| 91偷拍与自偷拍精品| 久久成人免费网| 成人app网站| 日韩国产在线观看| 久久精品亚洲乱码伦伦中文| 51精品秘密在线观看| 色综合天天综合网天天看片| 国产成人av一区| 美女在线视频一区| 日韩av在线发布| 国产真实精品久久二三区| 久88久久88久久久| 精品影视av免费| 成人国产免费视频| 精品1区2区3区| 欧美α欧美αv大片| 亚洲国产精品av| 亚洲成人1区2区| 国产酒店精品激情| 91丨porny丨户外露出| 97久久精品人人澡人人爽| 欧美精品在线观看一区二区| 精品久久人人做人人爱| 亚洲一二三四久久| 国产一区二区视频在线播放| 欧美日韩免费视频| 亚洲国产岛国毛片在线| 美女mm1313爽爽久久久蜜臀| 99久久亚洲一区二区三区青草| 成人高清av在线| 久久久久久久久久久电影| 亚洲人快播电影网| 成人av在线一区二区三区| 日韩欧美你懂的| 五月天精品一区二区三区| 99精品欧美一区二区三区综合在线| 91精品国产一区二区三区| 亚洲免费观看在线观看| 丁香激情综合国产| 国产欧美日韩三区| 国产suv精品一区二区6| 久久网这里都是精品| 久久精品久久久精品美女| 91精品欧美一区二区三区综合在 | 国产一区 二区| 精品剧情v国产在线观看在线| 日韩在线a电影| 日韩一区二区精品| 精品一区二区免费看| 日韩一区二区电影在线| 日本中文字幕一区| 欧美精品一区二区三区在线| 日韩国产一二三区| 精品国产免费视频| 99久久婷婷国产综合精品| 亚洲精品五月天| 3atv一区二区三区| 捆绑紧缚一区二区三区视频| 国产欧美精品一区aⅴ影院| eeuss鲁片一区二区三区在线观看| 亚洲一区电影777| 日韩视频不卡中文| av爱爱亚洲一区| 免费欧美在线视频| 亚洲日本在线天堂| 欧美成人a视频| 欧美视频你懂的| 国产经典欧美精品| 日韩国产欧美视频| 国产精品蜜臀在线观看| 日韩午夜中文字幕| 在线视频欧美精品| eeuss鲁片一区二区三区在线观看| 天天做天天摸天天爽国产一区| 国产欧美日韩亚州综合| 91精品欧美久久久久久动漫| 色婷婷激情一区二区三区| 国产曰批免费观看久久久| 亚洲a一区二区| 国产精品白丝在线| 久久精品视频在线免费观看| 欧美日韩精品久久久| 欧美性xxxxx极品少妇| 不卡的电视剧免费网站有什么| 美女视频黄久久| 欧美aaaaaa午夜精品| 偷拍自拍另类欧美| 香蕉成人伊视频在线观看| 一区二区在线观看视频在线观看| 久久久久久久久久电影| 欧美一区中文字幕| 欧美精品 日韩| 欧美嫩在线观看| 欧美日本国产视频| 91精品欧美一区二区三区综合在| 欧美日韩大陆一区二区| 精品视频一区三区九区| 欧美日韩三级在线| 欧美美女直播网站| 欧美一区二区视频在线观看| 欧美一区二区三区色| 精品国产乱码久久久久久久| 久久综合视频网| 亚洲视频网在线直播| 亚洲一区二区三区三| 久久精品国产成人一区二区三区| 韩国av一区二区三区| 色老汉av一区二区三区| 欧美日韩在线直播| 精品国产网站在线观看| 亚洲日本在线视频观看| 免费成人在线播放| 91视视频在线观看入口直接观看www | 欧美在线影院一区二区| 日韩欧美123| 亚洲欧洲成人自拍| 日本成人超碰在线观看| 91小视频免费观看| 精品欧美一区二区三区精品久久| 中文字幕在线一区二区三区| 日韩在线一区二区三区| 成人黄色小视频| 亚洲精品一区二区精华| 夜夜嗨av一区二区三区四季av | 91成人免费在线| 久久精品视频在线看| 麻豆精品国产传媒mv男同| 色噜噜久久综合| 中文字幕制服丝袜成人av| 国模一区二区三区白浆| 欧美日韩日日骚| 一级精品视频在线观看宜春院| 国产久卡久卡久卡久卡视频精品| 91精品国产综合久久久蜜臀粉嫩 | 午夜一区二区三区在线观看| 久久综合九色综合欧美98| 亚洲夂夂婷婷色拍ww47 | 久久精品网站免费观看| 麻豆91小视频| 日韩一区二区影院| 久久精品国产精品青草| 欧美精品一区二区久久婷婷|