org.objectweb.dream.message
Interface MessageManager

All Known Implementing Classes:
MessageManagerImpl, MessageManagerPoolingImpl

public interface MessageManager

Interface to creates, deletes and modify dream messages.


Field Summary
static String ITF_NAME
          The commonly used name of refer to this interface.
 
Method Summary
 void addChunk(Message message, String chunkName, AbstractChunk chunk)
          Adds a chunk in the given message.
 AbstractChunk addOrReplaceChunk(Message message, String chunkName, AbstractChunk chunk)
          Adds a chunk in the given message.
 void addSubMessage(Message message, Message subMessage)
          Adds a sub message to a message.
<T extends AbstractChunk<T>>
T
cloneChunk(T chunk)
          Clones the given chunk.
<T extends AbstractChunk<T>>
T
createChunk(ChunkFactoryReference<T> chunkFactory)
          Creates a chunk using the chunk factory referenced by the given reference.
 Message createMessage()
          Creates a new message and returns a reference to the newly created message.
 void deleteChunk(AbstractChunk<?> chunk)
          Deletes the given chunk.
 void deleteMessage(Message message)
          Delete the message referenced by the given reference.
 Message duplicateMessage(Message message, boolean clone)
          Duplicates a message.
 AbstractChunk getChunk(Message message, String chunkName)
          Returns the chunk in the given message with the given name.
<T extends AbstractChunk<T>>
ChunkFactoryReference<T>
getChunkFactory(Class<T> chunkType)
          Returns a reference to a chunk factory for the given chunk type.
 Iterator<String> getChunkNameIterator(Message message)
          Returns an iterator over the chunk names of the given message.
 Iterator<Message> getSubMessageIterator(Message message)
          Returns an iterator over sub messages of the given message.
 boolean isEmpty(Message message)
          Returns true if the message is empty (ie. contains no chunk and no sub message).
 AbstractChunk removeChunk(Message message, String chunkName)
          Removes a chunk from the given message.
 void removeSubMessage(Message message, Message subMessage)
          Removes a sub message from a message.
 

Field Detail

ITF_NAME

static final String ITF_NAME
The commonly used name of refer to this interface.

See Also:
Constant Field Values
Method Detail

createMessage

Message createMessage()
Creates a new message and returns a reference to the newly created message.

Returns:
a reference to a newly created message.

deleteMessage

void deleteMessage(Message message)
Delete the message referenced by the given reference. If the message has been duplicated by reference (see duplicateMessage(org.objectweb.dream.message.Message, boolean)), this operation releases the given reference. The message is effectively deleted only if all its references have been released. In this case, chunks in the message are removed and recycled, so as message instance.

Parameters:
message - the reference of the message to delete.
Throws:
InvalidReference - if the given message reference is invalid.

duplicateMessage

Message duplicateMessage(Message message,
                         boolean clone)
Duplicates a message. There are two kinds of duplication:

Parameters:
message - the reference of the message to be duplicated.
clone - the duplication mode. false for reference duplication, true for value duplication.
Returns:
the reference of the duplicated message.
Throws:
InvalidReference - if the given message reference is invalid.

getChunkFactory

<T extends AbstractChunk<T>> ChunkFactoryReference<T> getChunkFactory(Class<T> chunkType)
Returns a reference to a chunk factory for the given chunk type.

Type Parameters:
T - the chunk type.
Parameters:
chunkType - the class object of the required chunk type.
Returns:
a reference to a chunk factory for the given chunk type.

createChunk

<T extends AbstractChunk<T>> T createChunk(ChunkFactoryReference<T> chunkFactory)
Creates a chunk using the chunk factory referenced by the given reference.

Type Parameters:
T - the chunk type.
Parameters:
chunkFactory - a chunk factory reference.
Returns:
a chunk instance of the given type.
Throws:
InvalidReference - if the given chunk factory reference is invalid.

deleteChunk

void deleteChunk(AbstractChunk<?> chunk)
Deletes the given chunk.

Parameters:
chunk - the chunk to delete.
Throws:
InvalidReference - if the given chunk is invalid.

cloneChunk

<T extends AbstractChunk<T>> T cloneChunk(T chunk)
Clones the given chunk.

Type Parameters:
T - the type of the chunk to clone.
Parameters:
chunk - the chunk to clone.
Returns:
the cloned chunk.
Throws:
InvalidReference - if the given chunk is invalid.

isEmpty

boolean isEmpty(Message message)
Returns true if the message is empty (ie. contains no chunk and no sub message).

Parameters:
message - the reference of a message
Returns:
true if the message is empty.
Throws:
InvalidReference - if the given message reference is invalid.

getChunk

AbstractChunk getChunk(Message message,
                       String chunkName)
Returns the chunk in the given message with the given name.

Parameters:
message - the reference of the message
chunkName - the name of the chunk.
Returns:
a chunk of the type specified by the chunk name, or null if no chunk can be found.
Throws:
InvalidReference - if the given message reference is invalid.

addChunk

void addChunk(Message message,
              String chunkName,
              AbstractChunk chunk)
Adds a chunk in the given message. If chunk with the given name already exist in the message, a ChunkAlreadyExistException is thrown.

Parameters:
message - the reference of the message in which the chunk will be added.
chunkName - the name of the chunk.
chunk - the chunk to add
Throws:
InvalidReference - if the given message reference is invalid.
ChunkAlreadyExistException - if a chunk with the same name already exist in the given message.

addOrReplaceChunk

AbstractChunk addOrReplaceChunk(Message message,
                                String chunkName,
                                AbstractChunk chunk)
Adds a chunk in the given message. If a chunk with the given name already exist in the message, it is replaced and returned.

Parameters:
message - the reference of the message in which the message will be added.
chunkName - the name of the chunk.
chunk - the chunk to add
Returns:
the previous chunk with the given name, or null.
Throws:
InvalidReference - if the given message reference is invalid.

removeChunk

AbstractChunk removeChunk(Message message,
                          String chunkName)
Removes a chunk from the given message. If no chunk with the given name can be found in the message, a UnknownChunkException is thrown.

Parameters:
message - the reference of the message from which the chunk will be removed.
chunkName - the name of the chunk.
Returns:
the removed chunk.
Throws:
InvalidReference - if the given message reference is invalid.
UnknownChunkException - if no chunk with the given name can be found in the message.

getChunkNameIterator

Iterator<String> getChunkNameIterator(Message message)
Returns an iterator over the chunk names of the given message.

Parameters:
message - a message reference.
Returns:
an iterator over the chunk names of the given message.
Throws:
InvalidReference - if the given message reference is invalid.

addSubMessage

void addSubMessage(Message message,
                   Message subMessage)
Adds a sub message to a message.

Parameters:
message - the message where the sub message will be added.
subMessage - the sub message.
Throws:
InvalidReference - if the given message reference or sub message reference are invalid.
IllegalArgumentException - if this operation may creates a cycle (if message is already a sub message of subMessage). Since this check is expensive, some implementations may not perform it.

removeSubMessage

void removeSubMessage(Message message,
                      Message subMessage)
Removes a sub message from a message.

Parameters:
message - the message from which the sub message will be removed.
subMessage - the sub message.
Throws:
InvalidReference - if the given message reference or sub message reference are invalid.
IllegalArgumentException - if subMessage is not a sub message of message.

getSubMessageIterator

Iterator<Message> getSubMessageIterator(Message message)
Returns an iterator over sub messages of the given message.

Parameters:
message - a message reference.
Returns:
an iterator over the sub messages of the given message.
Throws:
InvalidReference - if the given message reference or sub message reference are invalid.


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