multiverse.msgsys
Class MessageType

java.lang.Object
  extended by multiverse.msgsys.MessageType
All Implemented Interfaces:
Serializable, Marshallable

public class MessageType
extends Object
implements Serializable, Marshallable

Message type object. Message types have a name and a number. The message number is assigned when the MessageType is added to a MessageCatalog.

Applications should declare static MessageType instances using intern(java.lang.String) and reuse that object. For example:

public static MessageType MSG_TYPE_SKY_FALLING = MessageType.intern("me.SKY_FALLING");
It is suggested that the MessageType string name be derived from the program identifier. Multiverse reserves all names beginning with "mv.".

See Also:
Serialized Form

Field Summary
protected static Map<String,MessageType> internedMsgTypes
           
protected  Integer msgTypeNumber
           
protected  String msgTypeString
           
private static long serialVersionUID
           
 
Constructor Summary
  MessageType()
          No argument constructor is needed for marshalling.
protected MessageType(String msgTypeString)
           
 
Method Summary
 int getMsgTypeNumber()
          Get message type number.
 String getMsgTypeString()
          Get message type name.
static MessageType intern(String typeName)
          Get singleton MessageType instance for a message type name.
 void marshalObject(MVByteBuffer buf)
          Internal use only.
private  void readObject(ObjectInputStream in)
           
static MessageType readObjectUtility(ObjectInputStream in)
          Internal use only.
private  Object readResolve()
           
 void setMsgTypeNumber(int msgTypeNumber)
          Set message type number.
 String toString()
           
 Object unmarshalObject(MVByteBuffer buf)
          Internal use only.
private  void writeObject(ObjectOutputStream out)
           
static void writeObjectUtility(ObjectOutputStream out, MessageType type)
          Internal use only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

internedMsgTypes

protected static Map<String,MessageType> internedMsgTypes

msgTypeString

protected transient String msgTypeString

msgTypeNumber

protected transient Integer msgTypeNumber

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

MessageType

public MessageType()
No argument constructor is needed for marshalling.


MessageType

protected MessageType(String msgTypeString)
Method Detail

getMsgTypeNumber

public int getMsgTypeNumber()
Get message type number.


setMsgTypeNumber

public void setMsgTypeNumber(int msgTypeNumber)
Set message type number. Applications should add the MessageType to a MessageCatalog to assign a number.


getMsgTypeString

public String getMsgTypeString()
Get message type name.


intern

public static MessageType intern(String typeName)
Get singleton MessageType instance for a message type name.


toString

public String toString()
Overrides:
toString in class Object

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Throws:
IOException
ClassNotFoundException

readObjectUtility

public static MessageType readObjectUtility(ObjectInputStream in)
                                     throws IOException,
                                            ClassNotFoundException
Internal use only.

Throws:
IOException
ClassNotFoundException

readResolve

private Object readResolve()
                    throws ObjectStreamException
Throws:
ObjectStreamException

writeObject

private void writeObject(ObjectOutputStream out)
                  throws IOException,
                         ClassNotFoundException
Throws:
IOException
ClassNotFoundException

writeObjectUtility

public static void writeObjectUtility(ObjectOutputStream out,
                                      MessageType type)
                               throws IOException,
                                      ClassNotFoundException
Internal use only.

Throws:
IOException
ClassNotFoundException

marshalObject

public void marshalObject(MVByteBuffer buf)
Internal use only.

Specified by:
marshalObject in interface Marshallable
Parameters:
buf - The byte buffer

unmarshalObject

public Object unmarshalObject(MVByteBuffer buf)
Internal use only.

Specified by:
unmarshalObject in interface Marshallable