peer2me.message
Class MessagePart

java.lang.Object
  extended by peer2me.message.MessagePart

public class MessagePart
extends java.lang.Object

There are three main types of information that can be stored in a MessagePart: serialized objectBytes, fileObject and primitive variables such as int, double, String etc... Each MessagePart can only contain ONE of these. The MessageParts are stored in a HashMap in Message. All constants in this class must be in the range 400-499

Author:
Kim Saxlund

Field Summary
static int ALLPRIMITIVES
          If this MessagePart contains a one or more primitive values (which is stored as an array of bytes}, the method getMessagePartType() will return this constant.
static int BOOLEAN
          If this MessagePart contains a boolean, the method getMessagePartType() will return this constant
static int CHAR
          If this MessagePart contains a char, the method getMessagePartType() will return this constant
static int CHARS
          If this MessagePart contains an array of chars, the method getMessagePartType() will return this constant
static int DOUBLE
          If this MessagePart contains a double, the method getMessagePartType() will return this constant
static int FILEINFO
          If this MessagePart contains a FileInfo, the method getMessagePartType() will return this constant
static int FILEOBJECT
          If this MessagePart contains a FileObject, the method getMessagePartType() will return this constant
static int FLOAT
          If this MessagePart contains a float, the method getMessagePartType() will return this constant
static int INT
          If this MessagePart contains an int, the method getMessagePartType() will return this constant
static int LONG
          If this MessagePart contains a long, the method getMessagePartType() will return this constant
static int SERIALIZEDOBJECT
          If this MessagePart contains a serialized object (which is stored as an array of bytes), the method getMessagePartType() will return this constant
static int SHORT
          If this MessagePart contains a short, the method getMessagePartType() will return this constant
static int STRING
          If this MessagePart contains a String, the method getMessagePartType() will return this constant
 
Constructor Summary
MessagePart(java.lang.String key, boolean booleanValue)
          Creates a MessagePart that contains a boolean
MessagePart(java.lang.String key, byte[] objectBytes)
          Creates a MessagePart that contains an array of bytes
MessagePart(java.lang.String key, char charValue)
          Creates a MessagePart that contains a char
MessagePart(java.lang.String key, char[] charsValue)
          Creates a MessagePart that contains an array of chars
MessagePart(java.lang.String key, double doubleValue)
          Creates a MessagePart that contains a double
MessagePart(java.lang.String key, FileInfo fileInfo)
          Creates a MessagePart that contains a FileInfo object
MessagePart(java.lang.String key, FileObject fileObject)
          Creates a MessagePart that contains a FileObject
MessagePart(java.lang.String key, float floatValue)
          Creates a MessagePart that contains a float
MessagePart(java.lang.String key, int intValue)
          Creates a MessagePart that contains an int
MessagePart(java.lang.String key, long longValue)
          Creates a MessagePart that contains a long
MessagePart(java.lang.String key, short shortValue)
          Creates a MessagePart that contains a short
MessagePart(java.lang.String key, java.lang.String stringValue)
          Creates a MessagePart that contains a String
 
Method Summary
 boolean getBooleanValue()
          A call to this method persumes that there exists a boolean in this MessagePart.
 char[] getChars()
          A call to this method persumes that there exists an array of chars in this MessagePart.
 char getCharValue()
          A call to this method persumes that there exists a char in this MessagePart.
 double getDoubleValue()
          A call to this method persumes that there exists a double in this MessagePart.
 FileInfo getFileInfo()
          A call to this method persumes that there exists a FileInfo in this MessagePart.
 FileObject getFileObject()
          A call to this method persumes that there exists a FileObject in this MessagePart.
 float getFloatValue()
          A call to this method persumes that there exists a float in this MessagePart.
 int getIntValue()
          A call to this method persumes that there exists a int in this MessagePart.
 java.lang.String getKey()
          Returns the key of this MessagePart
 long getLongValue()
          A call to this method persumes that there exists a long in this MessagePart.
 int getMessagePartType()
          Returns what kind of MessagePart this is.
 byte[] getObjectBytes()
          A call to this method persumes that there exists an array of bytes in this MessagePart.
 short getShortValue()
          A call to this method persumes that there exists a short in this MessagePart.
 java.lang.String getStringValue()
          A call to this method persumes that there exists a String in this MessagePart.
 void setKey(java.lang.String key)
          Sets the key of this MessagePart
 void setMessagePartType(int messagePartType)
          Sets the type of this MessagePart.
 void setObjectBytes(byte[] objectBytes)
          Sets an array of bytes as contents of this MessagePart
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALLPRIMITIVES

public static final int ALLPRIMITIVES
If this MessagePart contains a one or more primitive values (which is stored as an array of bytes}, the method getMessagePartType() will return this constant.

See Also:
Constant Field Values

BOOLEAN

public static final int BOOLEAN
If this MessagePart contains a boolean, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

CHAR

public static final int CHAR
If this MessagePart contains a char, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

CHARS

public static final int CHARS
If this MessagePart contains an array of chars, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
If this MessagePart contains a double, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

FILEINFO

public static final int FILEINFO
If this MessagePart contains a FileInfo, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

FILEOBJECT

public static final int FILEOBJECT
If this MessagePart contains a FileObject, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

FLOAT

public static final int FLOAT
If this MessagePart contains a float, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

INT

public static final int INT
If this MessagePart contains an int, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

LONG

public static final int LONG
If this MessagePart contains a long, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

SERIALIZEDOBJECT

public static final int SERIALIZEDOBJECT
If this MessagePart contains a serialized object (which is stored as an array of bytes), the method getMessagePartType() will return this constant

See Also:
Constant Field Values

SHORT

public static final int SHORT
If this MessagePart contains a short, the method getMessagePartType() will return this constant

See Also:
Constant Field Values

STRING

public static final int STRING
If this MessagePart contains a String, the method getMessagePartType() will return this constant

See Also:
Constant Field Values
Constructor Detail

MessagePart

public MessagePart(java.lang.String key,
                   FileInfo fileInfo)
Creates a MessagePart that contains a FileInfo object

Parameters:
key - The key that identifies this MessagePart
fileInfo - Sets a FileInfo object as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   FileObject fileObject)
Creates a MessagePart that contains a FileObject

Parameters:
key - The key that identifies this MessagePart
fileObject - Sets a FileObject object as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   int intValue)
Creates a MessagePart that contains an int

Parameters:
key - The key that identifies this MessagePart
intValue - Sets an int as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   double doubleValue)
Creates a MessagePart that contains a double

Parameters:
key - The key that identifies this MessagePart
doubleValue - Sets a double as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   float floatValue)
Creates a MessagePart that contains a float

Parameters:
key - The key that identifies this MessagePart
floatValue - Sets a float as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   short shortValue)
Creates a MessagePart that contains a short

Parameters:
key - The key that identifies this MessagePart
shortValue - Sets a short as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   java.lang.String stringValue)
Creates a MessagePart that contains a String

Parameters:
key - The key that identifies this MessagePart
stringValue - Sets a String as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   boolean booleanValue)
Creates a MessagePart that contains a boolean

Parameters:
key - The key that identifies this MessagePart
booleanValue - Sets a boolean as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   char charValue)
Creates a MessagePart that contains a char

Parameters:
key - The key that identifies this MessagePart
charValue - Sets a char as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   long longValue)
Creates a MessagePart that contains a long

Parameters:
key - The key that identifies this MessagePart
longValue - Sets a long as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   char[] charsValue)
Creates a MessagePart that contains an array of chars

Parameters:
key - The key that identifies this MessagePart
charsValue - Sets a char as contents of this part

MessagePart

public MessagePart(java.lang.String key,
                   byte[] objectBytes)
Creates a MessagePart that contains an array of bytes

Parameters:
key - The key that identifies this MessagePart
objectBytes - Sets a byte array as contents of this part
Method Detail

setKey

public void setKey(java.lang.String key)
Sets the key of this MessagePart

Parameters:
key - The key that identifies this MessagePart

getKey

public java.lang.String getKey()
Returns the key of this MessagePart

Returns:
The key of this MessagePart

getObjectBytes

public byte[] getObjectBytes()
A call to this method persumes that there exists an array of bytes in this MessagePart.
Returns an array of bytes that is attached to this MessagePart

Returns:
An array of bytes

setObjectBytes

public void setObjectBytes(byte[] objectBytes)
Sets an array of bytes as contents of this MessagePart

Parameters:
objectBytes - The array of bytes. This is either the bytes of a serialized object, or primitive value(s) stored in an array of bytes.

getMessagePartType

public int getMessagePartType()
Returns what kind of MessagePart this is. The values returned are one of the following: ALLPRIMITIVES, BOOLEAN, CHARS, DOUBLE, FILEINFO, FILEOBJECT, FLOAT, INT, LONG, SHORT, SERIALIZEDOBJECT or STRING.

Returns:
An constant that identifies this MessagePart

setMessagePartType

public void setMessagePartType(int messagePartType)
Sets the type of this MessagePart.

Parameters:
messagePartType - Must be one of the following: ALLPRIMITIVES, BOOLEAN, CHARS, DOUBLE, FILEINFO, FILEOBJECT, FLOAT, INT, LONG, SHORT, SERIALIZEDOBJECT or STRING.

getBooleanValue

public boolean getBooleanValue()
A call to this method persumes that there exists a boolean in this MessagePart.
Returns a boolean that is attached to this MessagePart

Returns:
The boolean attached to this MessagePart

getChars

public char[] getChars()
A call to this method persumes that there exists an array of chars in this MessagePart.
Returns an array of chars that is attached to this MessagePart

Returns:
The array of chars attached to this MessagePart

getCharValue

public char getCharValue()
A call to this method persumes that there exists a char in this MessagePart.
Returns a char that is attached to this MessagePart

Returns:
The char attached to this MessagePart

getDoubleValue

public double getDoubleValue()
A call to this method persumes that there exists a double in this MessagePart.
Returns a double that is attached to this MessagePart

Returns:
The double attached to this MessagePart

getFloatValue

public float getFloatValue()
A call to this method persumes that there exists a float in this MessagePart.
Returns a float that is attached to this MessagePart

Returns:
The float attached to this MessagePart

getIntValue

public int getIntValue()
A call to this method persumes that there exists a int in this MessagePart.
Returns a int that is attached to this MessagePart

Returns:
The int attached to this MessagePart

getLongValue

public long getLongValue()
A call to this method persumes that there exists a long in this MessagePart.
Returns a long that is attached to this MessagePart

Returns:
The long attached to this MessagePart

getShortValue

public short getShortValue()
A call to this method persumes that there exists a short in this MessagePart.
Returns a short that is attached to this MessagePart

Returns:
The short attached to this MessagePart

getStringValue

public java.lang.String getStringValue()
A call to this method persumes that there exists a String in this MessagePart.
Returns a String that is attached to this MessagePart

Returns:
The String attached to this MessagePart

getFileObject

public FileObject getFileObject()
A call to this method persumes that there exists a FileObject in this MessagePart.
Returns a FileObject that is attached to this MessagePart

Returns:
The FileObject attached to this MessagePart

getFileInfo

public FileInfo getFileInfo()
A call to this method persumes that there exists a FileInfo in this MessagePart.
Returns a FileInfo that is attached to this MessagePart

Returns:
The FileInfo attached to this MessagePart