bea Systems, Inc.

theory.smart.axiom.messaging
Class MailboxImpl

java.lang.Object
  |
  +--theory.smart.foundation.EntityImpl
        |
        +--theory.smart.axiom.messaging.MailboxImpl

public class MailboxImpl
extends EntityImpl

A simple message collection with some specialized message handling methods. The Mailbox is managed by the PostOffice

 Primary Key = theory.smart.axiom.messaging.MailboxPk
 

See Also:
Mailbox, MailboxHome, MailboxValue, Serialized Form

Field Summary
 com.sun.java.util.collections.LinkedList messages
           message (List) [Mailbox] <*>------> [theory.smart.axiom.messaging.Message] 0..*
 int nextId
           nextId [Mailbox] <*>------> [int]
 java.lang.String ownerId
           ownerId [Mailbox] <*>------> [String] (Primary Key)
 
Fields inherited from class theory.smart.foundation.EntityImpl
ctx, isDirty, isLoaded
 
Constructor Summary
MailboxImpl()
           
 
Method Summary
 void addFirstMessage(Message message)
          Inserts the given message at the beginning of the message list.
 void addLastMessage(Message message)
          Appends the given message to the end of the message list.
 void addMessage(int index, Message message)
          Inserts the specified message at the specified position in the message list.
 boolean addMessage(Message message)
          Appends the specified message to the end of the message list.
 void addMessage(java.lang.String body)
          Create a new nessage with the nextId and increment the nextId.
 boolean addMessages(int index, com.sun.java.util.collections.LinkedList messages)
          Inserts all of the messages in the specified collection into this list, starting at the specified position.
 boolean addMessages(com.sun.java.util.collections.LinkedList messages)
          Appends all of the messages in the specified collection to the end of the message list, in the order that they are returned by the specified collection's iterator.
 boolean containsMessage(Message message)
          Returns true if the message list contains the specified element.
 void ejbActivate()
          ejbActivate method.
 MailboxPk ejbCreate(MailboxPk mailboxPk)
           
protected  void ejbCreateInitVars(MailboxPk mailboxPk)
           
 java.util.Enumeration ejbFindAll()
           
 MailboxPk ejbFindByPrimaryKey(MailboxPk pk)
           
 void ejbLoad()
          ejbLoad method.
 void ejbPassivate()
          ejbPassivate method.
 void ejbPostCreate(MailboxPk mailboxPk)
           
 void ejbRemove()
          ejbRemove method.
 void ejbStore()
          ejbStore method.
 Message getFirstMessage()
          Returns the first message in the message list.
 Message getLastMessage()
          Returns the last message in the message list.
 MailboxValue getMailboxByValue()
          Get all of Mailbox's attributes.
 Message getMessage(int index)
          Returns the message at the specified position in the message list.
 com.sun.java.util.collections.LinkedList getMessages()
          Returns all of the messages in the message list.
 com.sun.java.util.collections.LinkedList getMessages(int fromIndex, int toIndex)
          Returns a view of the portion of the message list between fromIndex, inclusive, and toIndex, exclusive.
 int getNextId()
          Get the value of nextId
 int getNumberOfMessages()
          Returns the number of messages in the message list.
 java.lang.String getOwnerId()
           
 int indexOfMessage(Message message)
          Returns the index in the message list of the first occurrence of the specified element, or -1 if the message list does not contain this element.
 boolean isMessagesEmtpy()
          Returns true if the message list contains no messages.
 int lastIndexOfMessage(Message message)
          Returns the index in the message list of the last occurrence of the specified element, or -1 if the message list does not contain this element.
 void removeAllMessages()
          Removes all of the messages from the message list.
 Message removeFirstMessage()
          Removes and returns the first message from the message list.
 Message removeLastMessage()
          Removes and returns the last message from the message list.
 Message removeMessage(int index)
          Removes the message at the specified position in the message list.
 boolean removeMessage(Message message)
          Removes the first occurrence of the specified message in the message list.
 void setEntityContext(EntityContext ctx)
          setEntityContext method.
 void setMailboxByValue(MailboxValue value)
          Set all of Mailbox's attributes to the passed in value.
 Message setMessage(int index, Message message)
          Replaces the message at the specified position in the message list with the specified element.
 void setNextId(int nextId)
          Set the value of nextId
 void unsetEntityContext()
          unsetEntityContext method.
 
Methods inherited from class theory.smart.foundation.EntityImpl
ejbCreate, ejbCreateInitVars, ejbPostCreate, getEntityContext, isModified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ownerId

public java.lang.String ownerId
                  ownerId
 [Mailbox] <*>------> [String] (Primary Key)

 

nextId

public int nextId
                  nextId
 [Mailbox] <*>------> [int] 

 

messages

public com.sun.java.util.collections.LinkedList messages
                  message (List)
 [Mailbox] <*>------> [theory.smart.axiom.messaging.Message] 
                     0..*
 
Constructor Detail

MailboxImpl

public MailboxImpl()
            throws CreateException
Method Detail

getMailboxByValue

public MailboxValue getMailboxByValue()
                               throws java.rmi.RemoteException
Get all of Mailbox's attributes.
Returns:
MailboxValue the Mailbox value object

setMailboxByValue

public void setMailboxByValue(MailboxValue value)
                       throws java.rmi.RemoteException
Set all of Mailbox's attributes to the passed in value. Note: Primary key attributes are not set.
Parameters:
MailboxValue - the Mailbox value object

ejbCreate

public MailboxPk ejbCreate(MailboxPk mailboxPk)
                    throws CreateException,
                           java.rmi.RemoteException

ejbCreateInitVars

protected void ejbCreateInitVars(MailboxPk mailboxPk)
                          throws CreateException,
                                 java.rmi.RemoteException

ejbPostCreate

public void ejbPostCreate(MailboxPk mailboxPk)
                   throws CreateException,
                          java.rmi.RemoteException

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbLoad method.
Overrides:
ejbLoad in class EntityImpl

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbStore method.
Overrides:
ejbStore in class EntityImpl

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      RemoveException
Description copied from class: EntityImpl
ejbRemove method.
Overrides:
ejbRemove in class EntityImpl

ejbActivate

public void ejbActivate()
                 throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbActivate method.
Overrides:
ejbActivate in class EntityImpl

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbPassivate method.
Overrides:
ejbPassivate in class EntityImpl

setEntityContext

public void setEntityContext(EntityContext ctx)
                      throws java.rmi.RemoteException
Description copied from class: EntityImpl
setEntityContext method.
Overrides:
setEntityContext in class EntityImpl

unsetEntityContext

public void unsetEntityContext()
                        throws java.rmi.RemoteException
Description copied from class: EntityImpl
unsetEntityContext method.
Overrides:
unsetEntityContext in class EntityImpl

ejbFindByPrimaryKey

public MailboxPk ejbFindByPrimaryKey(MailboxPk pk)
                              throws FinderException,
                                     java.rmi.RemoteException

ejbFindAll

public java.util.Enumeration ejbFindAll()
                                 throws FinderException,
                                        java.rmi.RemoteException

getOwnerId

public java.lang.String getOwnerId()
                            throws java.rmi.RemoteException

getNextId

public int getNextId()
              throws java.rmi.RemoteException
Get the value of nextId
Returns:
nextId.

setNextId

public void setNextId(int nextId)
               throws java.rmi.RemoteException
Set the value of nextId
Parameters:
nextId - nextId to be added

addMessage

public void addMessage(int index,
                       Message message)
Inserts the specified message at the specified position in the message list. Shifts the message currently at that position (if any) and any subsequent messages to the right (adds one to their indices).
Parameters:
index - index at which the specified message is to be inserted.
message - message to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addMessage

public boolean addMessage(Message message)
Appends the specified message to the end of the message list.
Parameters:
message - message to be appended to the message list.
Returns:
true (as per the general contract of Collection.add).

addMessages

public boolean addMessages(int index,
                           com.sun.java.util.collections.LinkedList messages)
Inserts all of the messages in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent messages to the right (increases their indices). The new messages will appear in the message list in the order that they are returned by the specified collection's iterator.
Parameters:
index - index at which to insert first element from the specified collection.
messages - messages to be inserted into the message list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addMessages

public boolean addMessages(com.sun.java.util.collections.LinkedList messages)
Appends all of the messages in the specified collection to the end of the message list, in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is the message list, and the message list is nonempty.)
Parameters:
messages - messages to be inserted into the message list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addFirstMessage

public void addFirstMessage(Message message)
Inserts the given message at the beginning of the message list.

addLastMessage

public void addLastMessage(Message message)
Appends the given message to the end of the message list. (Identical in function to the add method; included only for consistency.)

containsMessage

public boolean containsMessage(Message message)
Returns true if the message list contains the specified element. More formally, returns true if and only if the message list contains at least one message e such that (o==null ? e==null : o.equals(e)).
Parameters:
message - message whose presence in the message list is to be tested.
Returns:
true if the message list contains the specified element.

getMessage

public Message getMessage(int index)
Returns the message at the specified position in the message list.
Parameters:
index - index of message to return.
Returns:
the message at the specified position in the message list.
Throws:
IndexOutOfBoundsException - if the specified index is is out of range (index < 0 || index >= size()).

getMessages

public com.sun.java.util.collections.LinkedList getMessages(int fromIndex,
                                                            int toIndex)
Returns a view of the portion of the message list between fromIndex, inclusive, and toIndex, exclusive.
Parameters:
fromIndex - low endpoint (inclusive) of the subList.
toKey - high endpoint (exclusive) of the subList.
Returns:
a view of the specified range within the message list.
Throws:
IndexOutOfBoundsException - endpoint index value out of range (fromIndex < 0 || toIndex > size)
java.lang.IllegalArgumentException - endpoint indices out of order (fromIndex > toIndex)

getMessages

public com.sun.java.util.collections.LinkedList getMessages()
Returns all of the messages in the message list.
Returns:
all of the messages in the message list.

getFirstMessage

public Message getFirstMessage()
Returns the first message in the message list.
Returns:
the first message in the message list.

getLastMessage

public Message getLastMessage()
Returns the last message in the message list.
Returns:
the last message in the message list.
Throws:
NoSuchElementException - if the message list is empty.

getNumberOfMessages

public int getNumberOfMessages()
Returns the number of messages in the message list.
Returns:
the number of messages in the message list.

indexOfMessage

public int indexOfMessage(Message message)
Returns the index in the message list of the first occurrence of the specified element, or -1 if the message list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Parameters:
message - message to search for.
Returns:
the index in the message list of the first occurrence of the specified element, or -1 if the message list does not contain this element.

isMessagesEmtpy

public boolean isMessagesEmtpy()
Returns true if the message list contains no messages.

Returns:
true if the message list contains no messages.

lastIndexOfMessage

public int lastIndexOfMessage(Message message)
Returns the index in the message list of the last occurrence of the specified element, or -1 if the message list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Parameters:
message - message to search for.
Returns:
the index in the message list of the last occurrence of the specified element, or -1 if the message list does not contain this element.

removeAllMessages

public void removeAllMessages()
Removes all of the messages from the message list.

removeMessage

public Message removeMessage(int index)
Removes the message at the specified position in the message list. Shifts any subsequent messages to the left (subtracts one from their indices). Returns the message that was removed from the message list.
Parameters:
index - the index of the message to removed.
Returns:
the message previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

removeMessage

public boolean removeMessage(Message message)
Removes the first occurrence of the specified message in the message list. If the message list does not contain the element, it is unchanged. More formally, removes the message with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an message exists).
Parameters:
message - message to be removed from the message list, if present.
Returns:
true if the message list contained the specified element.

removeFirstMessage

public Message removeFirstMessage()
Removes and returns the first message from the message list.
Returns:
the first message from the message list.
Throws:
NoSuchElementException - if the message list is empty.

removeLastMessage

public Message removeLastMessage()
Removes and returns the last message from the message list.
Returns:
the last message from the message list.
Throws:
NoSuchElementException - if the message list is empty.

setMessage

public Message setMessage(int index,
                          Message message)
Replaces the message at the specified position in the message list with the specified element.
Parameters:
index - index of message to replace.
message - message to be stored at the specified position.
Returns:
the message previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

addMessage

public void addMessage(java.lang.String body)
                throws java.rmi.RemoteException
Create a new nessage with the nextId and increment the nextId. Add the message to the end of the list.

bea Systems, Inc.

© Copyright 2000 bea Systems, Inc. All rights reserved.