gcsImplementations.spreadGcs
Class SpreadGcsMessage

java.lang.Object
  extended by gcs.GcsMessage
      extended by gcsImplementations.spreadGcs.SpreadGcsMessage

public class SpreadGcsMessage
extends GcsMessage

Spread back-end implementation of the GcsMessage.

Author:
tkob
See Also:
GcsMessage

Constructor Summary
SpreadGcsMessage()
           
 
Method Summary
 void addGroup(GcsGroup group)
          Adds group to the list of addressees of this message.
 void addGroup(java.lang.String group)
          Adds group of name group to the list of addressees of this message.
 void addGroups(GcsGroup[] groups)
          Adds all groups in array groups to the list of addressees of this message.
 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.
 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.
 byte[] getData()
          Returns the payload as an array of bytes.
 java.util.Vector getDigest()
          Returns a vector of objects set as a payload with GcsMessage.digest(Serializable) method.
 boolean getEndianMismatch()
          Returns true if there is an endian mismatch between computer which sent the message, and computer which received it.
 GcsGroup[] getGroups()
          Returns an array of GcsGroup objects representing addresses of this message.
 GcsMembershipInfo getMembershipInfo()
          Returns membership information for this message if this is a membership message (the GcsMessage.isMembership() method returns true).
 java.lang.Object getObject()
          Returns message payload as an object.
 GcsGroup getSender()
          Returns the message sender's private group.
 int getServiceType()
          Returns an integer value representing the message's service type.
 short getType()
          This method returns the message type.
 boolean isAgreed()
          Returns true if the message is of agreed guarantee.
 boolean isCausal()
          Returns true if the message is of causal guarantee.
 boolean isFifo()
          Returns true if the message is of fifo guarantee.
 boolean isIncoming()
          Returns true if this is an incoming message.
 boolean isMembership()
          Returns true if this is a membership message.
 boolean isOutgoing()
          Returns true if this is an outgoing message.
 boolean isRegular()
          Returns true if the message is of regular guarantee.
 boolean isReject()
          Returns true if the message was rejected.
 boolean isReliable()
          Returns true if the message is of reliable guarantee.
 boolean isSafe()
          Returns true if the message is of safe guarantee.
 boolean isSelfDiscard()
          Returns true if this is a self-discard message.
 boolean isUnreliable()
          Returns true if the message is of reliable guarantee.
 void setAgreed()
          Sets the message's guarantee to agreed.
 void setCausal()
          Sets the message's guarantee to causal.
 void setData(byte[] data)
          Sets data as the message's payload.
 void setFifo()
          Sets the message's guarantee to fifo.
 void setObject(java.io.Serializable object)
          Sets given as argument object as a payload for this message.
 void setReliable()
          Sets the message's guarantee to reliable.
 void setSafe()
          Sets the message's guarantee to safe.
 void setSelfDiscard(boolean selfDiscard)
          Used to set the self-discard flag for this method.
 void setServiceType(int serviceType)
          Sets the service type for this message.
 void setType(short type)
          Returns the message's type.
 void setUnreliable()
          Sets the message's guarantee to safe.
 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

SpreadGcsMessage

public SpreadGcsMessage()
Method Detail

addGroup

public void addGroup(GcsGroup group)
Description copied from class: GcsMessage
Adds group to the list of addressees of this message. List of addresses can be retrieved with GcsMessage.getGroups().

Specified by:
addGroup in class GcsMessage
Parameters:
group - group to be added to the list of addressees
See Also:
GcsMessage.getGroups()

addGroup

public void addGroup(java.lang.String group)
Description copied from class: GcsMessage
Adds group of name group to the list of addressees of this message. List of addresses can be retrieved with GcsMessage.getGroups().

Specified by:
addGroup in class GcsMessage
Parameters:
group - name of group to be added to the list of addresses

addGroups

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

Specified by:
addGroups in class GcsMessage
Parameters:
groups - array of groups to be added to the list of addressees of this message

addGroups

public void addGroups(java.lang.String[] groups)
Description copied from class: GcsMessage
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 GcsMessage.getGroups().

Specified by:
addGroups in class GcsMessage
Parameters:
groups - array of names of groups to be added to the list of addressees of this message

digest

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

Specified by:
digest in class GcsMessage
Parameters:
object - object to be added
Throws:
GcsException - if problem were encountered during reading the object
See Also:
GcsMessage.getDigest()

getData

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

Specified by:
getData in class GcsMessage
Returns:
payload
See Also:
GcsMessage.setData(byte[])

getDigest

public java.util.Vector getDigest()
                           throws GcsException
Description copied from class: GcsMessage
Returns a vector of objects set as a payload with GcsMessage.digest(Serializable) method.

Specified by:
getDigest in class GcsMessage
Returns:
payload as a vector of objects
Throws:
GcsException - if errors were encountered during reading the objects
See Also:
GcsMessage.digest(Serializable)

getEndianMismatch

public boolean getEndianMismatch()
Description copied from class: GcsMessage
Returns true if there is an endian mismatch between computer which sent the message, and computer which received it.

Specified by:
getEndianMismatch in class GcsMessage
Returns:
true if there is an endian mismatch between sender's computer and receiver's computer, false otherwise

getGroups

public GcsGroup[] getGroups()
Description copied from class: GcsMessage
Returns an array of GcsGroup objects representing addresses of this message.

Specified by:
getGroups in class GcsMessage
Returns:
list of addresses of this message

getMembershipInfo

public GcsMembershipInfo getMembershipInfo()
Description copied from class: GcsMessage
Returns membership information for this message if this is a membership message (the GcsMessage.isMembership() method returns true).

Specified by:
getMembershipInfo in class GcsMessage
Returns:
membership information for this message

getObject

public java.lang.Object getObject()
                           throws GcsException
Description copied from class: GcsMessage
Returns message payload as an object. This is complementary method to the GcsMessage.setObject(Serializable).

Specified by:
getObject in class GcsMessage
Returns:
payload as an object
Throws:
GcsException - if difficulties were encountered during reading the message
See Also:
GcsMessage.setObject(Serializable)

getSender

public GcsGroup getSender()
Description copied from class: GcsMessage
Returns the message sender's private group.

Specified by:
getSender in class GcsMessage
Returns:
message sender's private group

getServiceType

public int getServiceType()
Description copied from class: GcsMessage
Returns an integer value representing the message's service type.

Specified by:
getServiceType in class GcsMessage
Returns:
an integer value representing the message's service type

getType

public short getType()
Description copied from class: GcsMessage
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 GcsMessage.setType(short) .

Specified by:
getType in class GcsMessage
Returns:
the message's type
See Also:
GcsMessage.setType(short)

isAgreed

public boolean isAgreed()
Description copied from class: GcsMessage
Returns true if the message is of agreed guarantee.

Specified by:
isAgreed in class GcsMessage
Returns:
true if the message is of agreed guarantee, false otherwise
See Also:
GcsMessage.setAgreed()

isCausal

public boolean isCausal()
Description copied from class: GcsMessage
Returns true if the message is of causal guarantee.

Specified by:
isCausal in class GcsMessage
Returns:
true if the message is of causal guarantee, false otherwise
See Also:
GcsMessage.setCausal()

isFifo

public boolean isFifo()
Description copied from class: GcsMessage
Returns true if the message is of fifo guarantee.

Specified by:
isFifo in class GcsMessage
Returns:
true if the message is of fifo guarantee, false otherwise
See Also:
GcsMessage.setFifo()

isIncoming

public boolean isIncoming()
Description copied from class: GcsMessage
Returns true if this is an incoming message.

Specified by:
isIncoming in class GcsMessage
Returns:
true if this is an incoming message, false otherwise

isMembership

public boolean isMembership()
Description copied from class: GcsMessage
Returns true if this is a membership message.

Specified by:
isMembership in class GcsMessage
Returns:
true if this is a membership message, false otherwise

isOutgoing

public boolean isOutgoing()
Description copied from class: GcsMessage
Returns true if this is an outgoing message.

Specified by:
isOutgoing in class GcsMessage
Returns:
true if this is an outgoing message, false otherwise

isReject

public boolean isReject()
Description copied from class: GcsMessage
Returns true if the message was rejected.

Specified by:
isReject in class GcsMessage
Returns:
true if the message was rejected, false otherwise

isRegular

public boolean isRegular()
Description copied from class: GcsMessage
Returns true if the message is of regular guarantee.

Specified by:
isRegular in class GcsMessage
Returns:
true if the message is of regular guarantee, false otherwise

isReliable

public boolean isReliable()
Description copied from class: GcsMessage
Returns true if the message is of reliable guarantee.

Specified by:
isReliable in class GcsMessage
Returns:
true if the message is of agreed guarantee, false otherwise
See Also:
GcsMessage.setReliable()

isSafe

public boolean isSafe()
Description copied from class: GcsMessage
Returns true if the message is of safe guarantee.

Specified by:
isSafe in class GcsMessage
Returns:
true if the message is of safe guarantee, false otherwise
See Also:
GcsMessage.setSafe()

isSelfDiscard

public boolean isSelfDiscard()
Description copied from class: GcsMessage
Returns true if this is a self-discard message. The self-discard flag can be set with GcsMessage.setSelfDiscard(boolean) .

Specified by:
isSelfDiscard in class GcsMessage
Returns:
true if this is a self-discard message, false otherwise
See Also:
GcsMessage.setSelfDiscard(boolean)

isUnreliable

public boolean isUnreliable()
Description copied from class: GcsMessage
Returns true if the message is of reliable guarantee.

Specified by:
isUnreliable in class GcsMessage
Returns:
true if the message is of agreed guarantee, false otherwise
See Also:
GcsMessage.setUnreliable()

setAgreed

public void setAgreed()
Description copied from class: GcsMessage
Sets the message's guarantee to agreed.

Specified by:
setAgreed in class GcsMessage
See Also:
GcsMessage.isAgreed()

setCausal

public void setCausal()
Description copied from class: GcsMessage
Sets the message's guarantee to causal.

Specified by:
setCausal in class GcsMessage
See Also:
GcsMessage.isCausal()

setData

public void setData(byte[] data)
Description copied from class: GcsMessage
Sets data as the message's payload. The data can be retrieved with GcsMessage.getData() .

Specified by:
setData in class GcsMessage
Parameters:
data - data to be set as a payload for this message
See Also:
GcsMessage.getData()

setFifo

public void setFifo()
Description copied from class: GcsMessage
Sets the message's guarantee to fifo.

Specified by:
setFifo in class GcsMessage
See Also:
GcsMessage.isFifo()

setObject

public void setObject(java.io.Serializable object)
               throws GcsException
Description copied from class: GcsMessage
Sets given as argument object as a payload for this message. The object can be retrieved with GcsMessage.getObject().

Specified by:
setObject in class GcsMessage
Parameters:
object - object to be set as a payload for this message
Throws:
GcsException - if problems were encountered during reading the object
See Also:
GcsMessage.getObject()

setReliable

public void setReliable()
Description copied from class: GcsMessage
Sets the message's guarantee to reliable.

Specified by:
setReliable in class GcsMessage
See Also:
GcsMessage.isReliable()

setSafe

public void setSafe()
Description copied from class: GcsMessage
Sets the message's guarantee to safe.

Specified by:
setSafe in class GcsMessage
See Also:
GcsMessage.isSafe()

setSelfDiscard

public void setSelfDiscard(boolean selfDiscard)
Description copied from class: GcsMessage
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) .

Specified by:
setSelfDiscard in class GcsMessage
Parameters:
selfDiscard - determines if the message should self-discard or not
See Also:
GcsMessage.isSelfDiscard()

setServiceType

public void setServiceType(int serviceType)
Description copied from class: GcsMessage
Sets the service type for this message. The service type can be retrieved with GcsMessage.getServiceType() .

Specified by:
setServiceType in class GcsMessage
Parameters:
serviceType - the service type for this message
See Also:
GcsMessage.getServiceType()

setType

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

Specified by:
setType in class GcsMessage
Parameters:
type - value which the message should be labeled with
See Also:
GcsMessage.getType()

setUnreliable

public void setUnreliable()
Description copied from class: GcsMessage
Sets the message's guarantee to safe.

Specified by:
setUnreliable in class GcsMessage
See Also:
GcsMessage.isSafe()

toXml

public org.jdom.Element toXml()
Description copied from class: GcsMessage
Returns the XML representation of this message.

Specified by:
toXml in class GcsMessage
Returns:
the XML representation of this message