Goals

jocundmail
Class JMBoxUtil

java.lang.Object
  extended by jocundmail.JMBoxUtil

public class JMBoxUtil
extends java.lang.Object

JMBoxUtil is a utility for the method of mail storage wherever mail is stored.

It provides a virtual representation of a mailbox, where all the messages are indexed from 0 to getMessageCount() - 1.

Version:
0.1.0
Author:
J.J. Sestrich
Goals:
1.0.0 First release version - More specifics to come.
Todo:
Progress:
(5/27/07) A basic implementation is here. At the moment it supports 1 folder, and the root of the folder contains the 0 folder/file

Constructor Summary
JMBoxUtil(java.lang.String rootdir)
          Constructs a JMBoxUtil with a root directory supplied.
 
Method Summary
 void addMessage(byte[] msg)
          Writes a new message in at the end of the virtual list.
 void addMessage(java.lang.String msg)
          Writes a new message in at the end of the virtual list.
 void decreaseDepth()
          Since messages are stored in a tree fashion.
 java.io.File getMessageByIndex(int i)
           
 int getMessageCount()
           
 java.io.File getNewMessage()
           
 void increaseDepth()
          Since messages are stored in a tree fashion.
static void main(java.lang.String[] args)
          Test function for testing this class
 void removeMessageByIndex(int i)
          Remove the message referred to by this index.
 void writeMessageByIndex(int i, byte[] msg)
          Writes a message into the message represented by given index.
 void writeMessageByIndex(int i, java.lang.String msg)
          Writes a message into the message represented by given index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMBoxUtil

public JMBoxUtil(java.lang.String rootdir)
          throws java.io.FileNotFoundException
Constructs a JMBoxUtil with a root directory supplied.

Parameters:
rootdir - String representing the root directory of the mailbox
Throws:
java.io.FileNotFoundException - If the root directory specified DNE
Method Detail

getMessageCount

public int getMessageCount()
Returns:
The number of messages in the mailbox

getMessageByIndex

public java.io.File getMessageByIndex(int i)
Parameters:
i - Index of message to be retrieved
Returns:
The message represented at the index given

getNewMessage

public java.io.File getNewMessage()
Returns:
A file which represents the next message at the end of the virtual list (index [getMessageCount()]). Also increases the message count by 1.

increaseDepth

public void increaseDepth()
Since messages are stored in a tree fashion. If the maxiumum size of the tree is reached, the depth of the tree must be increased with this function. It should be automated for you, so this should not be called without specific reason to do so.


decreaseDepth

public void decreaseDepth()
Since messages are stored in a tree fashion. If the tree can be stored with a smaller depth, this function can be used to reduce the depth of the tree. It should be automated for you, so this should not be called without specific reason to do so.


addMessage

public void addMessage(java.lang.String msg)
Writes a new message in at the end of the virtual list.

Parameters:
msg - The message in String form to be written to the new message

addMessage

public void addMessage(byte[] msg)
Writes a new message in at the end of the virtual list.

Parameters:
msg - The message in byte[] form to be written to the new message

writeMessageByIndex

public void writeMessageByIndex(int i,
                                java.lang.String msg)
Writes a message into the message represented by given index. Index can be of range 0 to getMessageCount(). So you could add a file by specifying the index 1 past the end of the virtual list. (Use addMessage to do this.)

Parameters:
i - Index of message
msg - Message in String form

writeMessageByIndex

public void writeMessageByIndex(int i,
                                byte[] msg)
Writes a message into the message represented by given index. Index can be of range 0 to getMessageCount(). So you could add a file by specifying the index 1 past the end of the virtual list. (Use addMessage to do this.)

Parameters:
i - Index of message
msg - Message in byte[] form

removeMessageByIndex

public void removeMessageByIndex(int i)
Remove the message referred to by this index. This causes the rest of the list to be shifted down.

Parameters:
i - Valid message index of the message to be removed

main

public static void main(java.lang.String[] args)
Test function for testing this class


SourceForge.net Logo