📄 thread.java
字号:
package org.redsoft.forum.web;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* This object that represents a thread(post) in db
*
* @author Charles Huang
* @since JDK 1.4
*/
import org.redsoft.forum.util.Validation;
public class Thread{
private static String DATE_FORMAT = "yyyy.MM.dd";
private SimpleDateFormat format = new SimpleDateFormat( DATE_FORMAT );
// The thread's title
private String title;
// Content of the thread
private String content;
// Author of the thread
private String author;
private long id;
// Time when this thread was posted
private long timeStamp;
private long parentID = -1;
private int category;
private long lastUpdated;
private int reply;
private long repliedThreadID;
private int click;
private boolean notify = true;
public int getClick() {
return click;
}
public Thread( final String title,
final String content,
final boolean notify ){
Validation.validateNotNull( title );
Validation.validateNotNull( content );
this.title = title;
this.content = content;
this.notify = notify;
}
public Thread( final String title,
final String content,
final String author,
final long timeStamp,
final int category ){
Validation.validateNotNull( title );
Validation.validateNotNull( content );
Validation.validateNotNull( author );
this.title = title;
this.content = content;
this.author = author;
this.timeStamp = timeStamp;
this.category = category;
}
public Thread( final String title,
final String content,
final String author,
final long timeStamp,
final long parentID,
final int category ){
Validation.validateNotNull( title );
Validation.validateNotNull( content );
Validation.validateNotNull( author );
this.title = title;
this.content = content;
this.author = author;
this.timeStamp = timeStamp;
this.parentID = parentID;
this.category = category;
}
// if it's the top thread
public boolean getIsParent() {
return (this.parentID == -1);
}
public Thread( final long id,
final String title,
final String content,
final String author,
final long timeStamp,
final long parentID,
final int category,
final long lastUpdated,
final int reply,
final int click,
final long repliedThreadID){
Validation.validateNotNull( title );
Validation.validateNotNull( content );
Validation.validateNotNull( author );
this.id = id;
this.title = title;
this.content = content;
this.author = author;
this.timeStamp = timeStamp;
this.parentID = parentID;
this.category = category;
this.reply = reply;
this.lastUpdated = lastUpdated;
this.click = click;
this.repliedThreadID = repliedThreadID;
}
/**
* Return the parent id
*
* @return long - The parent id
*/
public long getParentID(){
return parentID;
}
/**
* Return the thread id
*/
public long getID(){
return id;
}
/**
* Return the category
*
* @return int - The category this thread is under
*/
public int getCategory(){
return category;
}
/**
* Get the title
*
* @return
*/
public String getTitle(){
return this.title;
}
/**
* Get the content
*
* @return String - The content of the thread
*/
public String getContent(){
return this.content;
}
/**
* Get the author
*
* @return String - The author of the thread
*/
public String getAuthor(){
return this.author;
}
/**
* Get the timeStamp
*
* @return long - The posted time of the thread
*/
public String getTimeStamp(){
return format.format( new Date( this.timeStamp ) );
}
/**
* Get the last updated of the last reply for the thead
*
* @return long - The last updated timestamp of the last thread of this thread
*/
public String getLastUpdated(){
return format.format( new Date( this.lastUpdated ) );
}
/**
* Gets the quantity of the reply threads
*
* @return int - Quantity of the reply threads
*/
public int getReply(){
return this.reply;
}
/**
* Return the replied thread id
*/
public long getRepliedThreadID(){
return repliedThreadID;
}
/**
* Set the notify flag
*
* @param notify - The notify flag
*/
public void setNotify( boolean notify ){
this.notify = notify;
}
/**
* Return notification flag
*/
public boolean getNotify(){
return this.notify;
}
}//EOC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -