*/
public class Post {
+ /** The Sone this post belongs to. */
+ private final Sone sone;
+
/** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
private final long time;
/**
* Creates a new post.
*
+ * @param sone
+ * The Sone this post belongs to
* @param time
* The time of the post (in milliseconds since Jan 1, 1970 UTC)
* @param text
* The text of the post
*/
- public Post(long time, String text) {
+ public Post(Sone sone, long time, String text) {
+ this.sone = sone;
this.time = time;
this.text = text;
}
/**
+ * Returns the Sone this post belongs to.
+ *
+ * @return The Sone of this post
+ */
+ public Sone getSone() {
+ return sone;
+ }
+
+ /**
* Returns the time of the post.
*
* @return The time of the post (in milliseconds since Jan 1, 1970 UTC)
}
/**
- * Adds the given post to this Sone.
+ * Adds a post with the given text to this Sone.
*
- * @param post
- * The post to add
+ * @param text
+ * The text to post
*/
- public synchronized void addPost(Post post) {
+ public synchronized void addPost(String text) {
+ Post post = new Post(this, System.currentTimeMillis(), text);
if (posts.add(post)) {
modificationCounter++;
}
super.processTemplate(request, template);
String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
if (text.length() != 0) {
- Post post = new Post(System.currentTimeMillis(), text);
- getCurrentSone(request.getToadletContext()).addPost(post);
+ getCurrentSone(request.getToadletContext()).addPost(text);
throw new RedirectException("index.html");
}
template.set("errorTextEmpty", true);