webfunds.sox
Class MailItem

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.sox.MailItem

public class MailItem
extends Encodable

This class holds an item of mail. A Mail item is different from other objects here because it is first and foremost a byte array, not an object. This precedence is imposed due to the need to sign the correct data so the SOX server can remove the mail.

See Also:
Serialized Form

Field Summary
protected  byte[] buf
          The mail packet as it is passed over the net, and signed for.
protected  byte[] msg
          The mail item consists of a version, a type and a message.
static int RECEIPT
          Mail Type numbers.
protected  int type
           
 int version
           
static int VERSION
           
 
Constructor Summary
MailItem()
          Empty mail item - will not save, must set the contents.
MailItem(byte[] data)
          Recover from byte array and, in this case only, set the byte array.
MailItem(java.io.InputStream is)
           
MailItem(int type, byte[] msg)
           
MailItem(int type, Encodable obj)
           
 
Method Summary
 void decode(java.io.InputStream is)
          Careful of this conversion - as we are coding the mail item into an array, the on-the-wire format is not the same as the passed around internal mail item.
 void encode(java.io.OutputStream os)
           
 boolean equals(java.lang.Object object)
           
static MailItem example()
          A life-like example for tests.
 byte[] getMail()
          the full Mail with headers is the signed component
 MailId getMailId()
          this is the hash of the MailItem that represents the signature
 byte[] getMessage()
          the Message component is to be recovered according to Type
 int getType()
           
 int hashCode()
           
 void init(byte[] oldBuf)
           
 boolean isReceipt()
           
static void main(java.lang.String[] args)
           
 void setMsg(int type, byte[] b)
           
 void setMsg(int type, Encodable obj)
           
 java.lang.String toString()
           
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, readByteArray, readCertificate, readProperties, readString, writeByteArray, writeCertificate, writeProperties, writeString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final int VERSION

version

public int version

RECEIPT

public static final int RECEIPT
Mail Type numbers. 0-99 reserved for SOX. (was 0-111) 100-110 deliberately unallocated as experimental block. (was 112-127) 111-143 Systemics application stuff. (was 128-143) 144... Higher for application level numbers. (Realigned to make the unallocated block the same as OpenPGP numbers.)

buf

protected byte[] buf
The mail packet as it is passed over the net, and signed for. This might be a MailItem, or it might be a Receipt, or it might even be a Receipt within a MailItem :(

msg

protected byte[] msg
The mail item consists of a version, a type and a message.

type

protected int type
Constructor Detail

MailItem

public MailItem()
Empty mail item - will not save, must set the contents.

MailItem

public MailItem(int type,
                Encodable obj)
         throws SOXPacketException

MailItem

public MailItem(int type,
                byte[] msg)
         throws SOXPacketException

MailItem

public MailItem(byte[] data)
         throws SOXPacketException
Recover from byte array and, in this case only, set the byte array. To make it compatible, we don't fiddle with these, but this does result in a redundant byte[] --> Stream --> byte[].

MailItem

public MailItem(java.io.InputStream is)
         throws java.io.IOException,
                SOXPacketException
Method Detail

isReceipt

public boolean isReceipt()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getMail

public byte[] getMail()
the full Mail with headers is the signed component

getMessage

public byte[] getMessage()
the Message component is to be recovered according to Type

getType

public int getType()

getMailId

public MailId getMailId()
this is the hash of the MailItem that represents the signature

setMsg

public void setMsg(int type,
                   byte[] b)
            throws SOXPacketException

setMsg

public void setMsg(int type,
                   Encodable obj)
            throws SOXPacketException

init

public void init(byte[] oldBuf)
          throws SOXPacketException

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Overrides:
encode in class Encodable

decode

public void decode(java.io.InputStream is)
            throws SOXPacketException
Careful of this conversion - as we are coding the mail item into an array, the on-the-wire format is not the same as the passed around internal mail item. A conversion is needed at the boundary.
Overrides:
decode in class Encodable

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

example

public static MailItem example()
A life-like example for tests.

main

public static void main(java.lang.String[] args)