org.objectweb.dream.message
Class BasicMessageType

java.lang.Object
  extended byorg.objectweb.dream.message.BasicMessageType
All Implemented Interfaces:
EmptyStringArray, MessageType
Direct Known Subclasses:
BasicMessageTypeNC

public class BasicMessageType
extends Object
implements MessageType, EmptyStringArray

Basic Implementation of MessageType


Field Summary
protected  String[] chkNames
          The chunk names
protected  Hashtable chunkTypes
          Hashtable associating names and chunk types
static MessageType EMPTY_MESSAGE_TYPE
          A constant designating the empty message type.
protected  LinkedList subMessageTypes
          List of sub message types
protected  MessageType[] subMessageTypesArray
          The sub message types
 
Fields inherited from interface org.objectweb.dream.message.MessageType
EMPTY_MESSAGE_TYPE_ARRAY
 
Fields inherited from interface org.objectweb.dream.util.EmptyStringArray
EMPTY_STRING_ARRAY
 
Constructor Summary
protected BasicMessageType()
          Creates an empty message type.
  BasicMessageType(String[] chkNames, ChunkType[] chkTypes, MessageType[] msgTypes)
          Creates a message type with the specified chunk types and sub message types.
  BasicMessageType(String chkName, ChunkType chkType)
          Creates a message type that contains a chunk type.
  BasicMessageType(String chkName1, ChunkType chkType1, String chkName2, ChunkType chkType2)
          Creates a message type that contains two chunk types.
 
Method Summary
 void addChunkType(String chunkName, ChunkType chunkType)
          Adds a chunk type
 void addSubMessageType(MessageType msgType)
          Adds a sub message type
 String[] getChunkNames()
          Returns an (eventually empty) array containing the chunk's names of messages of this type.
 Iterator getChunkNamesIterator()
          Returns an iterator over the chunk's names of messages of this type.
 ChunkType getChunkType(String name)
          Returns a chunk type of this message type from its name.
 MessageType[] getSubMessageTypes()
          Returns an (eventually empty) array containing the types of the sub messages of messages of this type.
 Iterator getSubMessageTypesIterator()
          Returns an iterator over the types of the sub messages of messages of this type.
 boolean isEmpty()
          Returns true if this message type is empty (ie : does not contains any chunk types and any sub message types)
 boolean isSubTypeOf(MessageType t)
          Returns true if this message type if a sub type of the given message type.
 ChunkType removeChunkType(String name)
          removes a chunk type
 boolean removeSubMessageType(MessageType msgType)
          Removes a sub message type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_MESSAGE_TYPE

public static final MessageType EMPTY_MESSAGE_TYPE
A constant designating the empty message type.


chunkTypes

protected Hashtable chunkTypes
Hashtable associating names and chunk types


subMessageTypes

protected LinkedList subMessageTypes
List of sub message types


chkNames

protected String[] chkNames
The chunk names


subMessageTypesArray

protected MessageType[] subMessageTypesArray
The sub message types

Constructor Detail

BasicMessageType

protected BasicMessageType()
Creates an empty message type. This constructor is protected. To manipulate the empty message type, components should use the EMPTY_MESSAGE_TYPEconstant.


BasicMessageType

public BasicMessageType(String[] chkNames,
                        ChunkType[] chkTypes,
                        MessageType[] msgTypes)
                 throws ChunkAlreadyExistException
Creates a message type with the specified chunk types and sub message types. chkNames array contains the name of chunk types, which are specified in chkTypes array (as a consequence these two arrays must have the same length). Names and types are associated following their order in arrays.

Parameters:
chkNames - array of chunk names can be null.
chkTypes - array of chunk types (ignored if chkNames is null).
msgTypes - array of sub message types can be null.
Throws:
IllegalArgumentException - If chkNames and chkTypes do not have the same length.
ChunkAlreadyExistException - If the same name appears twice in chkNames

BasicMessageType

public BasicMessageType(String chkName,
                        ChunkType chkType)
Creates a message type that contains a chunk type. This constructor is provided for convenience

Parameters:
chkName - the name of the chunk type
chkType - the chunk type

BasicMessageType

public BasicMessageType(String chkName1,
                        ChunkType chkType1,
                        String chkName2,
                        ChunkType chkType2)
                 throws ChunkAlreadyExistException
Creates a message type that contains two chunk types. This constructor is provided for convenience

Parameters:
chkName1 - the name of the first chunk type
chkType1 - the first chunk type
chkName2 - the name of the second chunk type
chkType2 - the second chunk type
Throws:
ChunkAlreadyExistException - if chkname1 and chkName2 are equals
Method Detail

getChunkType

public ChunkType getChunkType(String name)
Description copied from interface: MessageType
Returns a chunk type of this message type from its name.

Specified by:
getChunkType in interface MessageType
Parameters:
name - the name of one of the chunk types returned by MessageType.getChunkNames().
Returns:
a chunk type of this message type from its name or null if no chunk with the specified name can be found.
See Also:
MessageType.getChunkType(java.lang.String)

getChunkNames

public String[] getChunkNames()
Description copied from interface: MessageType
Returns an (eventually empty) array containing the chunk's names of messages of this type.

Specified by:
getChunkNames in interface MessageType
Returns:
an array containing the chunk's names of messages of this type.
See Also:
MessageType.getChunkNames()

getChunkNamesIterator

public Iterator getChunkNamesIterator()
Description copied from interface: MessageType
Returns an iterator over the chunk's names of messages of this type.

Specified by:
getChunkNamesIterator in interface MessageType
Returns:
an iterator over the chunk's names of messages of this type.
See Also:
MessageType.getChunkNamesIterator()

getSubMessageTypes

public MessageType[] getSubMessageTypes()
Description copied from interface: MessageType
Returns an (eventually empty) array containing the types of the sub messages of messages of this type.

Specified by:
getSubMessageTypes in interface MessageType
Returns:
an array containing the types of the sub messages of messages of this type.
See Also:
MessageType.getSubMessageTypes()

getSubMessageTypesIterator

public Iterator getSubMessageTypesIterator()
Description copied from interface: MessageType
Returns an iterator over the types of the sub messages of messages of this type.

Specified by:
getSubMessageTypesIterator in interface MessageType
Returns:
an iterator over the types of the sub messages of messages of this type.
See Also:
MessageType.getSubMessageTypesIterator()

isEmpty

public boolean isEmpty()
Description copied from interface: MessageType
Returns true if this message type is empty (ie : does not contains any chunk types and any sub message types)

Specified by:
isEmpty in interface MessageType
Returns:
true if this message type is empty
See Also:
MessageType.isEmpty()

isSubTypeOf

public boolean isSubTypeOf(MessageType t)
Description copied from interface: MessageType
Returns true if this message type if a sub type of the given message type.

Specified by:
isSubTypeOf in interface MessageType
Parameters:
t - a message type
Returns:
true if this message type if a sub type of the given message type.
See Also:
MessageType.isSubTypeOf(org.objectweb.dream.message.MessageType)

addChunkType

public void addChunkType(String chunkName,
                         ChunkType chunkType)
                  throws ChunkAlreadyExistException
Adds a chunk type

Parameters:
chunkName - the name of the chunk type
chunkType - the chunk type
Throws:
ChunkAlreadyExistException - if this type already contains a chunk type with the specified name

addSubMessageType

public void addSubMessageType(MessageType msgType)
Adds a sub message type

Parameters:
msgType - the message type to add

removeChunkType

public ChunkType removeChunkType(String name)
removes a chunk type

Parameters:
name - the name of the chunk type.
Returns:
the chunk type or null if no chunk type with the specified name exists.

removeSubMessageType

public boolean removeSubMessageType(MessageType msgType)
Removes a sub message type

Parameters:
msgType - the message type to remove
Returns:
true if the specified message type can be removed


Copyright © 2003, 2004 - INRIA Rhone-Alpes - All Rights Reserved.