gcs
Class GcsMessage

java.lang.Object
  extended by gcs.GcsMessage
Direct Known Subclasses:
SpreadGcsMessage

public abstract class GcsMessage
extends java.lang.Object

GcsMessage provides an abstraction for a message, both

Outgoing message should have specified:

Author:
tkob

Constructor Summary
protected GcsMessage()
          Default constructor creates an empty message.
 
Method Summary
abstract  void addGroup(GcsGroup group)
          Adds group to the list of addressees of this message.
abstract  void addGroup(java.lang.String group)
          Adds group of name group to the list of addressees of this message.
abstract  void addGroups(GcsGroup[] groups)
          Adds all groups in array groups to the list of addressees of this message.
abstract  void addGroups(java.lang.String[] groups)
          Adds all groups which names are stored in the groups array to the list of addressees of this message.
abstract  void digest(java.io.Serializable object)
          Calling this method causes the object specified as the argument to be added to the payload list of this message.
abstract  byte[] getData()
          Returns the payload as an array of bytes.
abstract  java.util.Vector getDigest()
          Returns a vector of objects set as a payload with digest(Serializable) method.
abstract  boolean getEndianMismatch()
          Returns true if there is an endian mismatch between computer which sent the message, and computer which received it.
abstract  GcsGroup[] getGroups()
          Returns an array of GcsGroup objects representing addresses of this message.
abstract  GcsMembershipInfo getMembershipInfo()
          Returns membership information for this message if this is a membership message (the isMembership() method returns true).
abstract  java.lang.Object getObject()
          Returns message payload as an object.
abstract  GcsGroup getSender()
          Returns the message sender's private group.
abstract  int getServiceType()
          Returns an integer value representing the message's service type.
abstract  short getType()
          This method returns the message type.
abstract  boolean isAgreed()
          Returns true if the message is of agreed guarantee.
abstract  boolean isCausal()
          Returns true if the message is of causal guarantee.
abstract  boolean isFifo()
          Returns true if the message is of fifo guarantee.
abstract  boolean isIncoming()
          Returns true if this is an incoming message.
abstract  boolean isMembership()
          Returns true if this is a membership message.
abstract  boolean isOutgoing()
          Returns true if this is an outgoing message.
abstract  boolean isRegular()
          Returns true if the message is of regular guarantee.
abstract  boolean isReject()
          Returns true if the message was rejected.
abstract  boolean isReliable()
          Returns true if the message is of reliable guarantee.
abstract  boolean isSafe()
          Returns true if the message is of safe guarantee.
abstract  boolean isSelfDiscard()
          Returns true if this is a self-discard message.
abstract  boolean isUnreliable()
          Returns true if the message is of reliable guarantee.
abstract  void setAgreed()
          Sets the message's guarantee to agreed.
abstract  void setCausal()
          Sets the message's guarantee to causal.
abstract  void setData(byte[] data)
          Sets data as the message's payload.
abstract  void setFifo()
          Sets the message's guarantee to fifo.
abstract  void setObject(java.io.Serializable object)
          Sets given as argument object as a payload for this message.
abstract  void setReliable()
          Sets the message's guarantee to reliable.
abstract  void setSafe()
          Sets the message's guarantee to safe.
abstract  void setSelfDiscard(boolean selfDiscard)
          Used to set the self-discard flag for this method.
abstract  void setServiceType(int serviceType)
          Sets the service type for this message.
abstract  void setType(short type)
          Returns the message's type.
abstract  void setUnreliable()
          Sets the message's guarantee to safe.
abstract  org.jdom.Element toXml()
          Returns the XML representation of this message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GcsMessage

protected GcsMessage()
Default constructor creates an empty message.

Method Detail

addGroup

public abstract void addGroup(GcsGroup group)
Adds group to the list of addressees of this message. List of addresses can be retrieved with getGroups().

Parameters:
group - group to be added to the list of addressees
See Also:
getGroups()

addGroup

public abstract void addGroup(java.lang.String group)
Adds group of name group to the list of addressees of this message. List of addresses can be retrieved with getGroups().

Parameters:
group - name of group to be added to the list of addresses

addGroups

public abstract void addGroups(GcsGroup[] groups)
Adds all groups in array groups to the list of addressees of this message. List of addresses can be retrieved with getGroups().

Parameters:
groups - array of groups to be added to the list of addressees of this message

addGroups

public abstract void addGroups(java.lang.String[] groups)
Adds all groups which names are stored in the groups array to the list of addressees of this message. List of addresses can be retrieved with getGroups().

Parameters:
groups - array of names of groups to be added to the list of addressees of this message

digest

public abstract void digest(java.io.Serializable object)
                     throws GcsException
Calling this method causes the object specified as the argument to be added to the payload list of this message. All previously set with setData(byte[]) or setObject(Serializable) objects will be removed.

Parameters:
object - object to be added
Throws:
GcsException - if problem were encountered during reading the object
See Also:
getDigest()

getData

public abstract byte[] getData()
Returns the payload as an array of bytes. If the data was set using digest(Serializable) or setObject(Serializable) methods, getDigest() and getObject() ought to be used, respectively.

Returns:
payload
See Also:
setData(byte[])

getDigest

public abstract java.util.Vector getDigest()
                                    throws GcsException
Returns a vector of objects set as a payload with digest(Serializable) method.

Returns:
payload as a vector of objects
Throws:
GcsException - if errors were encountered during reading the objects
See Also:
digest(Serializable)

getEndianMismatch

public abstract boolean getEndianMismatch()
Returns true if there is an endian mismatch between computer which sent the message, and computer which received it.

Returns:
true if there is an endian mismatch between sender's computer and receiver's computer, false otherwise

getGroups

public abstract GcsGroup[] getGroups()
Returns an array of GcsGroup objects representing addresses of this message.

Returns:
list of addresses of this message

getMembershipInfo

public abstract GcsMembershipInfo getMembershipInfo()
Returns membership information for this message if this is a membership message (the isMembership() method returns true).

Returns:
membership information for this message

getObject

public abstract java.lang.Object getObject()
                                    throws GcsException
Returns message payload as an object. This is complementary method to the setObject(Serializable).

Returns:
payload as an object
Throws:
GcsException - if difficulties were encountered during reading the message
See Also:
setObject(Serializable)

getSender

public abstract GcsGroup getSender()
Returns the message sender's private group.

Returns:
message sender's private group

getServiceType

public abstract int getServiceType()
Returns an integer value representing the message's service type.

Returns:
an integer value representing the message's service type

getType

public abstract short getType()
This method returns the message type. Sometimes labeling a message with an additional value can be useful. Setting the message type can be accomplished with setType(short) .

Returns:
the message's type
See Also:
setType(short)

isAgreed

public abstract boolean isAgreed()
Returns true if the message is of agreed guarantee.

Returns:
true if the message is of agreed guarantee, false otherwise
See Also:
setAgreed()

isCausal

public abstract boolean isCausal()
Returns true if the message is of causal guarantee.

Returns:
true if the message is of causal guarantee, false otherwise
See Also:
setCausal()

isFifo

public abstract boolean isFifo()
Returns true if the message is of fifo guarantee.

Returns:
true if the message is of fifo guarantee, false otherwise
See Also:
setFifo()

isIncoming

public abstract boolean isIncoming()
Returns true if this is an incoming message.

Returns:
true if this is an incoming message, false otherwise

isMembership

public abstract boolean isMembership()
Returns true if this is a membership message.

Returns:
true if this is a membership message, false otherwise

isOutgoing

public abstract boolean isOutgoing()
Returns true if this is an outgoing message.

Returns:
true if this is an outgoing message, false otherwise

isRegular

public abstract boolean isRegular()
Returns true if the message is of regular guarantee.

Returns:
true if the message is of regular guarantee, false otherwise

isReject

public abstract boolean isReject()
Returns true if the message was rejected.

Returns:
true if the message was rejected, false otherwise

isReliable

public abstract boolean isReliable()
Returns true if the message is of reliable guarantee.

Returns:
true if the message is of agreed guarantee, false otherwise
See Also:
setReliable()

isSafe

public abstract boolean isSafe()
Returns true if the message is of safe guarantee.

Returns:
true if the message is of safe guarantee, false otherwise
See Also:
setSafe()

isSelfDiscard

public abstract boolean isSelfDiscard()
Returns true if this is a self-discard message. The self-discard flag can be set with setSelfDiscard(boolean) .

Returns:
true if this is a self-discard message, false otherwise
See Also:
setSelfDiscard(boolean)

isUnreliable

public abstract boolean isUnreliable()
Returns true if the message is of reliable guarantee.

Returns:
true if the message is of agreed guarantee, false otherwise
See Also:
setUnreliable()

setAgreed

public abstract void setAgreed()
Sets the message's guarantee to agreed.

See Also:
isAgreed()

setCausal

public abstract void setCausal()
Sets the message's guarantee to causal.

See Also:
isCausal()

setData

public abstract void setData(byte[] data)
Sets data as the message's payload. The data can be retrieved with getData() .

Parameters:
data - data to be set as a payload for this message
See Also:
getData()

setFifo

public abstract void setFifo()
Sets the message's guarantee to fifo.

See Also:
isFifo()

setObject

public abstract void setObject(java.io.Serializable object)
                        throws GcsException
Sets given as argument object as a payload for this message. The object can be retrieved with getObject().

Parameters:
object - object to be set as a payload for this message
Throws:
GcsException - if problems were encountered during reading the object
See Also:
getObject()

setReliable

public abstract void setReliable()
Sets the message's guarantee to reliable.

See Also:
isReliable()

setSafe

public abstract void setSafe()
Sets the message's guarantee to safe.

See Also:
isSafe()

setSelfDiscard

public abstract void setSelfDiscard(boolean selfDiscard)
Used to set the self-discard flag for this method. If the flag is set, this message will not be received by the sender of this message after calling the GcsConnection.multicast(GcsMessage) .

Parameters:
selfDiscard - determines if the message should self-discard or not
See Also:
isSelfDiscard()

setServiceType

public abstract void setServiceType(int serviceType)
Sets the service type for this message. The service type can be retrieved with getServiceType() .

Parameters:
serviceType - the service type for this message
See Also:
getServiceType()

setType

public abstract void setType(short type)
Returns the message's type. Sometimes labeling a message with an additional value can be useful. To check the message's type, getType() method should be called.

Parameters:
type - value which the message should be labeled with
See Also:
getType()

setUnreliable

public abstract void setUnreliable()
Sets the message's guarantee to safe.

See Also:
isSafe()

toXml

public abstract org.jdom.Element toXml()
Returns the XML representation of this message.

Returns:
the XML representation of this message