| org.nemesis.forum.ForumThread
All known Subclasses: org.nemesis.forum.impl.DbForumThread, org.nemesis.forum.proxy.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);
|
addMessage | public void addMessage(Message parentMessage, Message newMessage)(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 |
deleteMessage | public void deleteMessage(Message 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.
|
getMessage | public Message getMessage(int messageID) throws ForumMessageNotFoundException(Code) | | Returns a message from the thread based on its id.
Parameters: messageID - the ID of the message to get from 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.
|
getMessageCount | public int getMessageCount(boolean approved)(Code) | | author: dlaurent author: Returns the number of messages in the forum. author: approved or not |
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. |
getRootMessage | public Message 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) | | return true if the message is approved
|
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. |
messages | public Iterator messages(boolean approved)(Code) | | Return an Iterator for all the messages in a thread.
|
messages | public Iterator messages(boolean approved, 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(Message message, ForumThread newThread, Message 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 . |
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.
|
treeWalker | public TreeWalker treeWalker(boolean approved)(Code) | | Returns a TreeWalker for the entire thread. A TreeWalker is used
to navigate through the tree of approved or not messages in a hierarchical manner.
|
|
|