📄 threaddao.java
字号:
package org.redsoft.forum.dao;
/**
* Forum's DAO interface
*
* @author Charles Huang
* @since JDK 1.4
* @version 1.0
*/
import org.redsoft.forum.dao.PersistentThread;
import org.redsoft.forum.exception.CategoryNotFoundException;
import org.redsoft.forum.exception.ThreadNotFoundException;
import java.sql.SQLException;
import java.util.Collection;
public interface ThreadDAO{
/**
* Add a new thread to the DB
*/
public PersistentThread addThread( final PersistentThread thread ) throws SQLException;
/**
* Remove a new thread from the DB
*/
public void removeThread( final PersistentThread thread ) throws SQLException;
/**
* Get all the top-level threads under the given category
*
* @param category - The category
* @return Collection - A collection of threads under the given category
*/
public Collection findByCategory( final int category )
throws SQLException,
CategoryNotFoundException;
/**
* Get the top-level threads under the given category from start index
*
* @param category - The category
* @param startIndex - The start index for retrieveing the records
* @param length - The number of records to be tretieved
* @return Collection - A collection of threads under the given category
*/
public Collection findByCategory( final int category,
final int startIndex,
final int length ) throws SQLException,
CategoryNotFoundException;
/**
* Get a thread given a unique id
*
* @return PersistentThread - The corresponding thread
*/
public PersistentThread findByUID( final long id ) throws SQLException,ThreadNotFoundException;
/**
* Get all the children threads given a id of a parent threa
*
* @return Collection - A collection of children threads
*
*/
public Collection findByParnetID( final long parentID ) throws ThreadNotFoundException, SQLException;
/**
* Get all the children threads given a id of a parent threa
*
* @param parentID - The id of a parnt thread
* @param startIndex - The number of row that we start to get the children threads
* @param endIndex - The number of row we end geting the children threads
* @return Collection - A collection of children threads
*
*/
public Collection findByParnetID( final long parentID, final int startIndex, final int endIndex ) throws SQLException;
/**
* Get the top-level threads count under the given category from start index
*
* @param category - The category
* @return int - The top-level threads count under a category
*/
public int findCountByCategory( final int category ) throws SQLException;
/**
* update Thread from DB
*/
public void updateThread( final PersistentThread thread ) throws SQLException, ThreadNotFoundException;
/**
* Update the click count
*/
public void updateClick(long id) throws SQLException;
/**
* Get a list of Threads owned by a given auther
* @param userId - the author's name
* return Collection - a list of Threads
*/
public Collection findByUserId(String userId) throws SQLException;
/**
* Remove a new thread from the DB
*/
public void removeThread( final long threadID ) throws SQLException;
/**
* Find all threads posted later than <code>time</code>
* (compare timestamp field of threads table in db with time)
*
* @param time time in milliseconds
* use System.currentTimeMillis() to get current time
* if time==0, return all threads
* @return all threads found
* @exception exception when querying db
*
*/
public Collection findThreadsPostedLaterThan( long time ) throws SQLException;
}//EOI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -