de.fu_berlin.ties.demo
Class SampleMails

java.lang.Object
  extended by de.fu_berlin.ties.demo.SampleMails

public class SampleMails
extends Object

This class manages a set of sample spam and nonspam mails. It is initialized from a ZIP file containing the semple mails. The ZIP files must contain two directories named spam and nonspam, all files within these directories are supposed to be sample mails. All messaged are supposed to use the default character set of the current platform.

Version:
$Revision: 1.6 $, $Date: 2006/10/21 16:04:09 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
static String NO_SUBJECT
          Subject generated if a message does not contain a "Subject:" header.
 
Constructor Summary
SampleMails(File sampleFile)
          Creates a new instance.
SampleMails(String sampleFileName)
          Creates a new instance.
 
Method Summary
 String getNonspam(int index)
          Returns the contents of a ham message.
 String getSpam(int index)
          Returns the contents of a spam message.
 int nonspamCount()
          Returns the number of ham messages managed by this instance.
 String[] nonspamSubjects()
          Lists the subjects of all ham mails.
 int spamCount()
          Returns the number of spam messages managed by this instance.
 String[] spamSubjects()
          Lists the subjects of all spam mails.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_SUBJECT

public static final String NO_SUBJECT
Subject generated if a message does not contain a "Subject:" header.

See Also:
Constant Field Values
Constructor Detail

SampleMails

public SampleMails(File sampleFile)
            throws IOException
Creates a new instance.

Parameters:
sampleFile - a ZIP file containing the sample mails
Throws:
IOException - if the file cannot be read or is not a valid ZIP file

SampleMails

public SampleMails(String sampleFileName)
            throws IOException
Creates a new instance.

Parameters:
sampleFileName - the name of a ZIP file containing the sample mails
Throws:
IOException - if the file cannot be read or is not a valid ZIP file
Method Detail

getNonspam

public String getNonspam(int index)
                  throws IndexOutOfBoundsException,
                         IOException
Returns the contents of a ham message.

Parameters:
index - the index of the message to read
Returns:
the contents of the specified message
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >= nonspamCount())
IOException - if an I/O error occurs

getSpam

public String getSpam(int index)
               throws IndexOutOfBoundsException,
                      IOException
Returns the contents of a spam message.

Parameters:
index - the index of the message to read
Returns:
the contents of the specified message
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >= spamCount())
IOException - if an I/O error occurs

nonspamCount

public int nonspamCount()
Returns the number of ham messages managed by this instance.

Returns:
the number of ham messages

nonspamSubjects

public String[] nonspamSubjects()
                         throws IOException
Lists the subjects of all ham mails.

Returns:
an array of length nonspamCount() containing the subjects of all ham mails
Throws:
IOException - if an error occurs while reading from the ZIP file

spamCount

public int spamCount()
Returns the number of spam messages managed by this instance.

Returns:
the number of spam messages

spamSubjects

public String[] spamSubjects()
                      throws IOException
Lists the subjects of all spam mails.

Returns:
an array of length spamCount() containing the subjects of all spam mails
Throws:
IOException - if an error occurs while reading from the ZIP file

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2007 Christian Siefkes. All Rights Reserved.