| com.Yasna.forum.ForumThread
All known Subclasses: com.Yasna.forum.database.DbForumThread, com.Yasna.forum.ForumThreadProxy,
ForumThread | public interface ForumThread (Code) | | A ForumThread is a container for a hierarchy of ForumMessages.
Intimately tied to the concept of a ForumThread is a root message. A
root message must be supplied when creating a thread. Subsequently, all
further messages posted to the thread are children of the root message.
To get a handle on a ForumThread object, the getThread method
should be called from a Forum object. To create a thread, createThread
from a Forum object should be used. After creating a thread, you must
attach it to a Forum by calling addThread from a Forum object.
To delete a ForumThread, call the deleteThread method from the
Forum object that the thread is attached to.
There are two options for navigating through the messages of a thread.
- A TreeWalker -- this provides a hierarchical view of the messages in
in the thread. For most skins, this will be the most appropriate
navigation method.
- An Iterator -- this provides a flat view of the messages in the thread.
Since the message structure is not really flat, a field to sort by
must be provided. This view of thread is useful for skins that want
to provide functionality such as listing all the messages in the order
they were created, etc.
Because a root message must be passed in when creating a thread, you must
first create that message before creating the thread. The following code
snippet demonstrates:
//Assume that a forum object and user object are already defined.
ForumMessage rootMessage = myForum.createMessage(myUser);
rootMessage.setSubject("A subject");
rootMessage.setBody("A body");
ForumThread myThread = myForum.createThread(rootMessage);
|
Method Summary | |
public void | addMessage(ForumMessage parentMessage, ForumMessage newMessage) Adds a new message to the thread. | public void | addReadCount() This method adds one to the read count.
This should have been implemented at the database level, but due to caching it couldn't.
Also it couldn't be added at the getThread level, since the ForumIterator uses the factory to get the thread
for the list of the threads. | public void | deleteMessage(ForumMessage message) Deletes a message from the thread. | public Date | getCreationDate() Returns the Date that the thread was created. | public Forum | getForum() Returns the parent Forum of the thread. | public int | getID() Returns the unique id of the thread. | public ForumMessage | getMessage(int messageID) Returns a message from the thread based on its id. | public int | getMessageCount() Returns the number of messages in the thread. | public Date | getModifiedDate() Returns the Date that the thread was last modified. | public String | getName() Returns the name of the thread (which is the subject of the root message). | public int | getReadCount() Returns the number of times this thread has been read. | public ForumMessage | getRootMessage() Returns the root message of a thread. | public ThreadType | getThreadType() | public boolean | hasPermission(int type) Returns true if the handle on the object has the permission specified.
A list of possible permissions can be found in the ForumPermissions
class. | public boolean | isApproved() Returns whether the thread was approved. | public boolean | isClosed() | public boolean | isSticky() | public Iterator | messages() Return an Iterator for all the messages in a thread. | public Iterator | messages(int startIndex, int numResults) Return an Iterator for all the messages in a thread. | public void | moveMessage(ForumMessage message, ForumThread newThread, ForumMessage parentMessage) Moves a message from one thread to another. | public void | setApprovment(boolean approved) Used by moderators to approved a thread in moderated forum. | public void | setClosed(boolean param) | public void | setCreationDate(Date creationDate) Sets the creation date of the thread. | public void | setModifiedDate(Date modifiedDate) Sets the date the thread was last modified. | public void | setSticky(boolean param) | public TreeWalker | treeWalker() Returns a TreeWalker for the entire thread. |
addMessage | public void addMessage(ForumMessage parentMessage, ForumMessage newMessage) throws UnauthorizedException(Code) | | Adds a new message to the thread.
Parameters: parentMessage - some message in the thread that will be parent Parameters: newMessage - message to add to the thread under the parent |
addReadCount | public void addReadCount()(Code) | | This method adds one to the read count.
This should have been implemented at the database level, but due to caching it couldn't.
Also it couldn't be added at the getThread level, since the ForumIterator uses the factory to get the thread
for the list of the threads. Therefore it would create an inacurate count.
You manually have to add the count in the skin to return an accurate count.
|
deleteMessage | public void deleteMessage(ForumMessage message) throws UnauthorizedException(Code) | | Deletes a message from the thread. Throws an IllegalArgumentException
if the message is not in the thread. If the message is deleted, it
should be entirely erased from the Forum system. Therefore, the
behavior is unspecified if a message object is first removed from a
thread and then added to another (this action not recommended).
throws: IllegalArgumentException - if the message does not belong to thethread. throws: UnauthorizedException - if does not have ADMIN permissions. |
getCreationDate | public Date getCreationDate()(Code) | | Returns the Date that the thread was created.
|
getForum | public Forum getForum()(Code) | | Returns the parent Forum of the thread.
|
getID | public int getID()(Code) | | Returns the unique id of the thread.
|
getMessageCount | public int getMessageCount()(Code) | | Returns the number of messages in the thread. This includes the root
message. So, to find the number of replies to the root message,
subtract one from the answer of this method.
|
getModifiedDate | public Date getModifiedDate()(Code) | | Returns the Date that the thread was last modified. In other words, the
date of the most recent message in the thread.
|
getName | public String getName()(Code) | | Returns the name of the thread (which is the subject of the root message).
This is a convenience method that is equivalent to
getRootMessage().getSubject() .
the name of the thread, which is the subject of the root message. |
getReadCount | public int getReadCount()(Code) | | Returns the number of times this thread has been read.
We also manually add the count each time the message is read from the cache,
so we have an accurate count of the times the thread has been read.
|
getRootMessage | public ForumMessage getRootMessage()(Code) | | Returns the root message of a thread. The root message is a special
first message that is intimately tied to the thread for most forumViews.
All other messages in the thread are children of the root message.
|
hasPermission | public boolean hasPermission(int type)(Code) | | Returns true if the handle on the object has the permission specified.
A list of possible permissions can be found in the ForumPermissions
class. Certain methods of this class are restricted to certain
permissions as specified in the method comments.
See Also: ForumPermissions |
isApproved | public boolean isApproved()(Code) | | Returns whether the thread was approved. When forum is not modereted
this method always will return true;
true if the thread was approved. |
isClosed | public boolean isClosed()(Code) | | |
isSticky | public boolean isSticky()(Code) | | |
messages | public Iterator messages()(Code) | | Return an Iterator for all the messages in a thread.
|
messages | public Iterator messages(int startIndex, int numResults)(Code) | | Return an Iterator for all the messages in a thread. The startIndex
and numResults restrict the number of results returned, which is useful
for multi-page HTML navigation.
Parameters: startIndex - the index you'd like to start the iterator at. Parameters: numResuls - the max number of results iterator will hold. |
moveMessage | public void moveMessage(ForumMessage message, ForumThread newThread, ForumMessage parentMessage) throws UnauthorizedException, IllegalArgumentException(Code) | | Moves a message from one thread to another. The message will become
a child of parentMessage in newThread
For this to work, message must exist in the thread that
this method is invoked on, parentMessage must be in
newThread , and the user calling this method must have
ADMIN permissions for the forum this method is invoked on and the forum
that newThread belongs to.
The main purpose of this method is to allow admins to move non-topical
messages into a more appropriate thread.
Parameters: message - the message to move to another thread. Parameters: newThread - the thread to move the message to. Parameters: parentMessage - the message under newThread that message should become a child of. throws: UnauthorizedException - if does not have ADMIN permissions for thethis forum and the forum that newThread belongs to. throws: IllegalArgumentException - if message does not belongto the thread that this method is invoked on, or parentMessage does not belong to newThread . |
setApprovment | public void setApprovment(boolean approved) throws UnauthorizedException(Code) | | Used by moderators to approved a thread in moderated forum.
Parameters: approved - when true this thread will be visible for all. throws: UnauthorizedException - if does not have ADMIN permissions. |
setCreationDate | public void setCreationDate(Date creationDate) throws UnauthorizedException(Code) | | Sets the creation date of the thread. In most cases, the creation date
will default to when the thread was entered into the system. However,
the creation date needs to be set manually when importing data.
In other words, skin authors should ignore this method since it only
intended for system maintenance.
Parameters: creationDate - the date the thread was created. throws: UnauthorizedException - if does not have ADMIN permissions. |
setModifiedDate | public void setModifiedDate(Date modifiedDate) throws UnauthorizedException(Code) | | Sets the date the thread was last modified. In most cases, last modifed
will default to when the thread data was last changed. However,
the last modified date needs to be set manually when importing data.
In other words, skin authors should ignore this method since it only
intended for system maintenance.
Parameters: modifiedDate - the date the thread was modified. throws: UnauthorizedException - if does not have ADMIN permissions. |
treeWalker | public TreeWalker treeWalker()(Code) | | Returns a TreeWalker for the entire thread. A TreeWalker is used
to navigate through the tree of messages in a hierarchical manner.
|
|
|