mail
Class Mail

java.lang.Object
  extended by mail.Mail
Direct Known Subclasses:
ArriveMail, EncryptedMail, SignedMail, TextMail

public abstract class Mail
extends java.lang.Object

Author:
Arne Müller

Field Summary
protected  java.lang.String id
           
private static java.util.Hashtable<java.lang.String,java.lang.Class<? extends Mail>> mailTypes
           
protected  ID receiver
           
 
Constructor Summary
Mail(ID receiver)
          creates a new Mail.
 
Method Summary
abstract  void build(org.w3c.dom.Element e)
           
abstract  org.w3c.dom.Element buildContent(org.w3c.dom.Document d)
          builds an XML-Element out of this Mail
static Mail buildMail(org.w3c.dom.Element e)
          builds a mail out of an XML-Element
 boolean equals(java.lang.Object o)
          two mails are equal, if and only if their ID and receiver matches
 java.lang.String getID()
           
 ID getReceiver()
          returns the receiver of this mail, this method should never return null
abstract  ID getSender()
          returns the sender of this mail.
 int hashCode()
          the hashcode only depends on the random-id-string generated by creation and the receiver
protected static void registerPackage(java.lang.Class<? extends Mail> c, java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mailTypes

private static java.util.Hashtable<java.lang.String,java.lang.Class<? extends Mail>> mailTypes

receiver

protected ID receiver

id

protected java.lang.String id
Constructor Detail

Mail

public Mail(ID receiver)
creates a new Mail. A receiver has to be specified, because the mail is supposed to arrive is it?

Parameters:
receiver -
Method Detail

getReceiver

public ID getReceiver()
returns the receiver of this mail, this method should never return null

Returns:

getSender

public abstract ID getSender()
returns the sender of this mail. The sender might not be public, so it is possible for this method to return null, if the sender wishes to stay hidden (e.g. by encryption)

Returns:
the sender, or null, if the sender is hidden

getID

public java.lang.String getID()

hashCode

public int hashCode()
the hashcode only depends on the random-id-string generated by creation and the receiver

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
two mails are equal, if and only if their ID and receiver matches

Overrides:
equals in class java.lang.Object

buildContent

public abstract org.w3c.dom.Element buildContent(org.w3c.dom.Document d)
                                          throws MailBuildException
builds an XML-Element out of this Mail

Parameters:
d - the document to place the element into
Returns:
the created XML-element
Throws:
MailBuildException

build

public abstract void build(org.w3c.dom.Element e)
                    throws MailBuildException
Throws:
MailBuildException

buildMail

public static Mail buildMail(org.w3c.dom.Element e)
                      throws MailBuildException
builds a mail out of an XML-Element

Parameters:
e - the XML-Element
Returns:
the created Mail
Throws:
MailBuildException

registerPackage

protected static void registerPackage(java.lang.Class<? extends Mail> c,
                                      java.lang.String name)