jrun.jms.core.message
Class MessageId

java.lang.Object
  |
  +--jrun.jms.core.message.MessageId
All Implemented Interfaces:
java.io.Externalizable, Identifiable, java.io.Serializable

public final class MessageId
extends java.lang.Object
implements java.io.Externalizable, Identifiable

The MessageId is a serializable object that uniquely identifies the object

Version:
$Revision: 1.4 $ $Date: 2001/06/21 20:53:05 $
Author:
Jim Alateras
See Also:
Serialized Form

Field Summary
static java.lang.String PERSISTENT_PREFIX
          The prefix for persistent messages
static java.lang.String PREFIX
          The prefix for transient messages
 
Constructor Summary
MessageId()
          Construct a transient message id
MessageId(int mode)
          Construct a message id based on the delivery mode of the message
MessageId(int mode, long id)
          Construct a message id using the specified mode and identity
MessageId(java.lang.String id)
          Construct a trnasient id with the specified identity.
 
Method Summary
 boolean equals(java.lang.Object object)
           
static java.lang.String generatePersistentId(long Id)
          Generate a persistent message id from the specified long
 long getId()
          Return the identity of the object as a long
 java.lang.String getIdAsString()
          Return the identity of the object as a string
static java.lang.String getNull()
          Return the 'null' JMSMessageID.
 int hashCode()
           
 boolean isPersistent()
          Check if the message id corresponds to a persistent message.
 void readExternal(java.io.ObjectInput in)
           
static long stringToLong(java.lang.String messageId)
          Convert a JMSMessageID to its long value
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PREFIX

public static final java.lang.String PREFIX
The prefix for transient messages

PERSISTENT_PREFIX

public static final java.lang.String PERSISTENT_PREFIX
The prefix for persistent messages
Constructor Detail

MessageId

public MessageId(int mode)
Construct a message id based on the delivery mode of the message
Parameters:
mode - - delivery mode

MessageId

public MessageId()
Construct a transient message id

MessageId

public MessageId(java.lang.String id)
          throws javax.jms.JMSException
Construct a trnasient id with the specified identity. If the identity does not start with the specified prefix then throw the JMSException
Parameters:
id - - the message identity
JMSException - - thrown if format is invalid

MessageId

public MessageId(int mode,
                 long id)
Construct a message id using the specified mode and identity
Parameters:
mode - - delivery mode
id - - message id as a long
Method Detail

isPersistent

public boolean isPersistent()
Check if the message id corresponds to a persistent message.
Returns:
boolean - true if it does

getId

public long getId()
Description copied from interface: Identifiable
Return the identity of the object as a long
Specified by:
getId in interface Identifiable
Following copied from interface: jrun.jms.core.Identifiable
Returns:
long - the object identity

getIdAsString

public java.lang.String getIdAsString()
Description copied from interface: Identifiable
Return the identity of the object as a string
Specified by:
getIdAsString in interface Identifiable
Following copied from interface: jrun.jms.core.Identifiable
Returns:
String - the identity

hashCode

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

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable

toString

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

equals

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

getNull

public static java.lang.String getNull()
Return the 'null' JMSMessageID. This is the first Id recognised by OpenJMS, but not assigned to messages.
Returns:
String the 'null' message Id

generatePersistentId

public static java.lang.String generatePersistentId(long Id)
Generate a persistent message id from the specified long
Parameters:
Id - numeric representation of the Id
Returns:
String the generated JMSMessageID

stringToLong

public static long stringToLong(java.lang.String messageId)
Convert a JMSMessageID to its long value
Parameters:
messageId - JMSMessageID to convert
Returns:
long value of the JMSMessageID


Copyright � 2002 Macromedia Corporation. All Rights Reserved.