Author: xor
Date: 2008-10-29 16:37:11 +0000 (Wed, 29 Oct 2008)
New Revision: 23174

Modified:
   trunk/plugins/FMSPlugin/FMSMessage.java
Log:
Add a field for referencing to the parent message, implement more stuff.

Modified: trunk/plugins/FMSPlugin/FMSMessage.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSMessage.java     2008-10-29 16:12:29 UTC (rev 
23173)
+++ trunk/plugins/FMSPlugin/FMSMessage.java     2008-10-29 16:37:11 UTC (rev 
23174)
@@ -21,8 +21,19 @@
  */
 public abstract class FMSMessage extends UpdatableSortedLinkedListItemImpl 
implements IndexableUpdatableSortedLinkedListItem {

-       private final FreenetURI mURI;
+       /**
+        * The URI of this message.
+        */
+       private final FreenetURI mURI;  

+       /**
+        * The URI to which this message is a reply. Null if it is a thread.
+        */
+       private final FreenetURI mParentURI;
+       
+       /**
+        * The boards to which this message was posted, in alphabetical order.
+        */
        private final ArrayList<FMSBoard> mBoards; 

        private final FMSIdentity mAuthor;
@@ -30,40 +41,58 @@
        private final String mTitle;

        /**
-        * The date when the message was written in UTC time.
+        * The date when the message was written in <strong>UTC time</strong>.
         */
        private final Date mDate;

        private final String mText;

+       /**
+        * The attachments of this message, in the order in which they were 
received in the original message.
+        */
        private final ArrayList<FreenetURI> mAttachments;

-       public FMSMessage(FreenetURI newURI, Set<FMSBoard> newBoards, 
FMSIdentity newAuthor, String newTitle, Date newDate, String newText, 
List<FreenetURI> newAttachments) {
+       public FMSMessage(FreenetURI newURI, FreenetURI newParentURI, 
Set<FMSBoard> newBoards, FMSIdentity newAuthor, String newTitle, Date newDate, 
String newText, List<FreenetURI> newAttachments) {
+               if (newURI == null || newBoards == null || newAuthor == null)
+                       throw new IllegalArgumentException();
+               
+               if (newBoards.isEmpty())
+                       throw new IllegalArgumentException("No boards in 
message " + newURI);
+               
+               if (!isTitleValid(newTitle))
+                       throw new IllegalArgumentException("Invalid message 
title in message " + newURI);
+               
+               if (!isTextValid(newText))
+                       throw new IllegalArgumentException("Invalid message 
text in message " + newURI);
+               
                mURI = newURI;
+               mParentURI = newParentURI;
                mBoards = new ArrayList<FMSBoard>(newBoards);
                Collections.sort(mBoards);
                mAuthor = newAuthor;
                mTitle = newTitle;
                mDate = newDate; // TODO: Check out whether Date provides a 
function for getting the timezone and throw an Exception if not UTC.
                mText = newText;
-               mAttachments = new ArrayList<FreenetURI>(newAttachments);
+               mAttachments = newAttachments!=null ? new 
ArrayList<FreenetURI>(newAttachments) : new ArrayList<FreenetURI>();
        }

        /**
         * Get the URI of the message.
-        * @return The URI of the message.
         */
        public FreenetURI getURI() {
                return mURI;
        }

+       /**
+        * Get an iterator of the boards to which this message was posted.
+        * The boards are returned in alphabetical order.
+        */
        public Iterator<FMSBoard> getBoardIterator() {
                return mBoards.iterator();
        }

        /**
         * Get the author of the message.
-        * @return The author of the message.
         */
        public FMSIdentity getAuthor() {
                return mAuthor;
@@ -71,15 +100,13 @@

        /**
         * Get the title of the message.
-        * @return The title of the message.
         */
        public String getTitle() {
                return mTitle;
        }

        /**
-        * Get the date when the message was written.
-        * @return The date when the message was written in UTC time.
+        * Get the date when the message was written in <strong>UTC 
time</strong>.
         */
        public Date getDate() {
                return mDate;
@@ -87,15 +114,13 @@

        /**
         * Get the text of the message.
-        * @return The text of the message.
         */
        public String getText() {
                return mText;
        }

        /**
-        * Get the attachments of the message.
-        * @return The attachments of the message.
+        * Get the attachments of the message, in the order in which they were 
received.
         */
        public ArrayList<FreenetURI> getAttachments() {
                return mAttachments;
@@ -110,7 +135,46 @@
                return mDate.compareTo(m.getDate());
        }

+       /**
+        * Get the index value for IndexableUpdatableSortedLinkedListItem.
+        */
        public Object indexValue() {
                return mURI;
        }
+       
+       /**
+        * Checks whether the title of the message is valid. Validity 
conditions:
+        * - ...
+        */
+       static boolean isTitleValid(String title) {
+               // FIXME: Implement.
+               return true;
+       }
+       
+       /**
+        * Checks whether the text of the message is valid. Validity conditions:
+        * - ...
+        */
+       static boolean isTextValid(String text) {
+               // FIXME: Implement.
+               return true;
+       }
+       
+       /**
+        * Makes the passed title valid in means of <code>isTitleValid()</code>
+        * @see isTitleValid
+        */
+       static String makeTitleValid(String title) {
+               // FIXME: Implement.
+               return title;
+       }
+
+       /**
+        * Makes the passed text valid in means of <code>isTextValid()</code>
+        * @see isTextValid
+        */
+       static String makeTextValid(String text) {
+               // FIXME: Implement.
+               return text;
+       }
 }


Reply via email to