📄 persistentthread.java
字号:
package org.redsoft.forum.dao;import org.redsoft.forum.util.StringUtils;import org.redsoft.forum.util.Validation;/** * A persistence capable thread object * * @author Charles Huang * @since JDK 1.4 * * @hibernate.class table="threads" */public class PersistentThread{ public static final String TABLE_PERSISTENCE = "threads"; public static final String PROPERTY_TITLE = "title"; public static final String PROPERTY_ID = "id"; public static final String PROPERTY_AUTHOR = "author"; public static final String PROPERTY_CONTENT = "content"; public static final String PROPERTY_TIMESTAMP = "timestamp"; public static final String PROPERTY_CATEGORY = "category"; public static final String PROPERTY_PARENT_ID = "parent_id"; public static final String PROPERTY_LAST_UPDATED ="last_update"; public static final String PROPERTY_REPLY ="reply"; public static final String PROPERTY_REPLIED_THREAD ="replied_thread"; public static final String PROPERTY_CLICK ="click"; public static final String PROPERTY_NOTIFY ="notify"; public static final String PROPERTY_COLUMN_THREAD ="columnThread"; //private static String DATE_FORMAT = "yyyy.MM.dd"; //private SimpleDateFormat format = new SimpleDateFormat( DATE_FORMAT ); // The thread's title String title; // Content of the thread String content; // Author of the thread String author; long id; // Time when this thread was posted long timeStamp; long parent_id = -1; int category; long last_update; transient String lastUpdateString; int reply; long replied_thread; int click; boolean notify = true; boolean columnThread = false; public int getClick() { return click; } public void setClick(int click) { this.click = click; } public PersistentThread() { } public PersistentThread( 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 PersistentThread( final long id, 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.id = id; this.content = content; this.author = author; this.timeStamp = timeStamp; this.category = category; } public PersistentThread( final long id, final String title, final long timeStamp, final int category , final int reply, final int click ){ Validation.validateNotNull( title ); Validation.validateNotNull( content ); Validation.validateNotNull( author ); this.title = title; this.id = id; this.timeStamp = timeStamp; this.category = category; this.reply = reply; this.click = click; } // if it's the top thread public boolean getIsParent() { return (this.parent_id == -1); } public PersistentThread( 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, final boolean notify ){ this( id, title, content, author, timeStamp, parentID, category, lastUpdated, reply, click, repliedThreadID ); this.notify = notify; } public PersistentThread( 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.parent_id = parentID; this.category = category; this.reply = reply; this.last_update = lastUpdated; this.lastUpdateString = StringUtils.formatTimeStamp( last_update ); this.click = click; this.replied_thread = repliedThreadID; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public long getId() { return id; } public void setId(long id) { this.id = id; } public long getTimeStamp() { return timeStamp; } public void setTimeStamp(long timeStamp) { this.timeStamp = timeStamp; } public long getParent_id() { return parent_id; } public void setParent_id(long parent_id) { this.parent_id = parent_id; } public int getCategory() { return category; } public void setCategory(int category) { this.category = category; } public long getLast_update() { return last_update; } public void setLast_update(long last_update) { this.last_update = last_update; this.lastUpdateString = StringUtils.formatTimeStamp( last_update ); } public int getReply() { return reply; } public void setReply(int reply) { this.reply = reply; } public long getReplied_thread() { return replied_thread; } public void setReplied_thread(long replied_thread) { this.replied_thread = replied_thread; } public boolean isNotify() { return notify; } public void setNotify(boolean notify) { this.notify = notify; } public boolean isColumnThread() { return columnThread; } public void setColumnThread(boolean columnThread) { this.columnThread = columnThread; } public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof PersistentThread)) return false; final PersistentThread persistentThread = (PersistentThread) o; if (category != persistentThread.category) return false; if (click != persistentThread.click) return false; if (columnThread != persistentThread.columnThread) return false; if (last_update != persistentThread.last_update) return false; if (notify != persistentThread.notify) return false; if (parent_id != persistentThread.parent_id) return false; if (replied_thread != persistentThread.replied_thread) return false; if (reply != persistentThread.reply) return false; if (timeStamp != persistentThread.timeStamp) return false; if (!author.equals(persistentThread.author)) return false; if (!content.equals(persistentThread.content)) return false; if (!title.equals(persistentThread.title)) return false; return true; } public int hashCode() { int result; result = title.hashCode(); result = 29 * result + content.hashCode(); result = 29 * result + author.hashCode(); result = 29 * result + (int) (timeStamp ^ (timeStamp >>> 32)); result = 29 * result + (int) (parent_id ^ (parent_id >>> 32)); result = 29 * result + category; result = 29 * result + (int) (last_update ^ (last_update >>> 32)); result = 29 * result + reply; result = 29 * result + (int) (replied_thread ^ (replied_thread >>> 32)); result = 29 * result + click; result = 29 * result + (notify ? 1 : 0); result = 29 * result + (columnThread ? 1 : 0); return result; } public String getLastUpdateString() { return lastUpdateString; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -