message
Class Payload

java.lang.Object
  extended by message.Payload

public class Payload
extends java.lang.Object

Data structure for the "payload" of a message. A Payload consists of two parts: Information about its length (4 byte length header) and the data it contains itself (e. g. data the user wants to send via the cascade or an encrypted message for the cascade's next mix).

Contains a padding mechanism to pad bypassed data to a desired length.

Author:
Karl-Peter Fuchs

Field Summary
private  byte[] bytePayload
          Byte representation of this Payload.
 
Constructor Summary
Payload(byte[] bytePayload)
          Constructs a new Payload with the submitted content ( bytePayload).
 
Method Summary
 byte[] getBytePayload()
          Returns the byte representation of this Payload.
static int getHeaderLength()
          Returns the length of the header used by this class for any Payload (Used to calculate message sizes).
 byte[] getMessage()
          Returns the message embedded in this Payload (without padding).
private  int getMessageLength()
          Returns the length of the message embedded in this Payload (without padding).
 void setMessage(byte[] newMessage, int desiredLength)
          Sets the bytePayload of this Payload to the bypassed value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bytePayload

private byte[] bytePayload
Byte representation of this Payload.

Constructor Detail

Payload

public Payload(byte[] bytePayload)
Constructs a new Payload with the submitted content ( bytePayload).

Parameters:
bytePayload - Byte representation of this Payload.
Method Detail

getBytePayload

public byte[] getBytePayload()
Returns the byte representation of this Payload.

Returns:
Byte representation of this Payload.

getMessageLength

private int getMessageLength()
Returns the length of the message embedded in this Payload (without padding).

Returns:
Length of the embedded message (without padding).

getMessage

public byte[] getMessage()
Returns the message embedded in this Payload (without padding).

Returns:
The message embedded in this Payload (without padding).

setMessage

public void setMessage(byte[] newMessage,
                       int desiredLength)
Sets the bytePayload of this Payload to the bypassed value. Adds padding if necessary.

Parameters:
newMessage - The message to be embedded in this Payload.
desiredLength - The desired length of this Payload.

getHeaderLength

public static int getHeaderLength()
Returns the length of the header used by this class for any Payload (Used to calculate message sizes).

Returns:
The length of the header used by this class.