|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.metamatrix.api.core.message.MessageList
public class MessageList
An ordered collection of Message
instances.
This class implements List
and thus can be used in the same
exact manner as a List
. However, there are additional methods
on this class that provide various mechanisms for finding or removing Message instances that
match particular categories, such as those that apply to a specific target or
those with one of a set of message types.
This class contains a Statistics
object that maintains
by message type the counts of Message instances contained by this object. Note that
these statistics do reflect changes to the MessageList object.
Nested Class Summary | |
---|---|
class |
MessageList.Statistics
Class that maintains statistics for the MessageList's Message instances categorized by various types. |
Constructor Summary | |
---|---|
MessageList()
Construct an object with no Message instances. |
|
MessageList(java.util.Collection messages)
Construct an object and add all of the Message instances in the specified collection. |
Method Summary | |
---|---|
void |
add(int index,
java.lang.Object message)
Overrides the implementation of List |
boolean |
add(java.lang.Object message)
Overrides the implementation of List |
boolean |
addAll(java.util.Collection messages)
Overrides the implementation of List |
boolean |
addAll(int index,
java.util.Collection messages)
Overrides the implementation of List |
void |
clear()
Overrides the implementation of List |
boolean |
contains(java.lang.Object message)
Overrides the implementation of List |
boolean |
containsAll(java.util.Collection messages)
Overrides the implementation of List |
java.lang.Object |
get(int index)
Overrides the implementation of List |
MessageList.Statistics |
getStatistics()
Return the Statistics instance that contains a breakdown by MessageType of the number of Message instances in this object. |
int |
indexOf(java.lang.Object message)
Overrides the implementation of List |
boolean |
isEmpty()
Overrides the implementation of List |
java.util.Iterator |
iterator()
Overrides the implementation of List |
java.util.Iterator |
iteratorByTarget(java.lang.Object target)
Return an iterator over the Message instances that have the specified Object as the message target. |
java.util.Iterator |
iteratorByType(int messageType)
Return an iterator over the Message instances that have the specified message type. |
java.util.Iterator |
iteratorByType(int[] messageTypes)
Return an iterator over the Message instances that have a message type included in the provided set. |
int |
lastIndexOf(java.lang.Object message)
Overrides the implementation of List |
java.util.ListIterator |
listIterator()
Overrides the implementation of List |
java.util.ListIterator |
listIterator(int index)
Overrides the implementation of List |
protected static boolean |
matchesTarget(Message msg,
java.lang.Object target)
Helper method to determine whether the supplied message has a target that is exactly the same as the supplied object. |
protected static boolean |
matchesType(Message msg,
int messageType)
Helper method to determine whether the supplied message has a type that is exactly the same object as the supplied type. |
protected static boolean |
matchesType(Message msg,
int[] messageTypes)
Helper method to determine whether the supplied message has a type that is exactly the same as one of the the supplied types. |
protected void |
messageAdded(Message message)
Can be overridden by subclasses to do specific work on a message when it is being added. |
protected void |
messageRemoved(Message message)
Can be overridden by subclasses to do specific work on a message when it is being removed. |
protected void |
messagesCleared()
Can be overridden by subclasses to do specific work when this list is being cleared. |
java.lang.Object |
remove(int index)
Overrides the implementation of List |
boolean |
remove(java.lang.Object message)
Overrides the implementation of List |
boolean |
removeAll(java.util.Collection messages)
Overrides the implementation of List |
boolean |
removeByClass(java.lang.Class messageClass)
Remove all Message instances that are instances of the specified Class. |
boolean |
removeByTarget(java.lang.Object messageTarget)
Remove all Message instances that have the specified target |
boolean |
removeByType(int messageType)
Remove all Message instances that have the specified type |
boolean |
removeByType(int[] messageTypes)
Remove all Message instances that have the specified type |
protected static boolean |
removeMessagesWithTarget(java.util.List messages,
java.lang.Object target)
Helper method to remove all instances from the List of Message objects where the message target matches (using matchesTarget(Message, Object) ) the supplied
target. |
boolean |
retainAll(java.util.Collection messages)
Overrides the implementation of List |
java.lang.Object |
set(int index,
java.lang.Object message)
Overrides the implementation of List |
int |
size()
Overrides the implementation of List |
java.util.List |
subList(int fromIndex,
int toIndex)
Overrides the implementation of List |
java.util.List |
subListByTarget(java.lang.Object messageTarget)
Returns a sublist of the Message instances that have the appropriate message types. |
java.util.List |
subListByType(int messageType)
Returns a sublist of the Message instances that have the appropriate message types. |
java.util.List |
subListByType(int[] messageTypes)
Returns a sublist of the Message instances that have the appropriate message types. |
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this list in proper sequence. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array. |
protected static void |
verifyMessage(java.lang.Object obj)
Helper method to verify that the object is an instance of Message . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
equals, hashCode |
Constructor Detail |
---|
public MessageList()
public MessageList(java.util.Collection messages)
messages
- the collection of Message instances that this object is to contain; if
null, this object will be empty.Method Detail |
---|
public MessageList.Statistics getStatistics()
public boolean removeByTarget(java.lang.Object messageTarget)
messageTarget
- the target for which messages are to be removed from this container.
public boolean removeByClass(java.lang.Class messageClass)
messageClass
- the Class whose instances are to be removed from this list.
public boolean removeByType(int messageType)
messageType
- the type for which messages are to be removed from this container.
public boolean removeByType(int[] messageTypes)
messageTypes
- the types for which messages are to be removed from this container.
public java.util.Iterator iteratorByTarget(java.lang.Object target)
target
- the message target
public java.util.Iterator iteratorByType(int messageType)
messageType
- the message type
public java.util.Iterator iteratorByType(int[] messageTypes)
messageTypes
- the array of message types over which this iterator
is to expose
public java.util.List subListByTarget(java.lang.Object messageTarget)
messageTarget
- the message target
public java.util.List subListByType(int messageType)
messageType
- the message type
public java.util.List subListByType(int[] messageTypes)
messageTypes
- the array of message types
protected static boolean removeMessagesWithTarget(java.util.List messages, java.lang.Object target)
matchesTarget(Message, Object)
) the supplied
target.
messages
- the list of messages; may not be nulltarget
- the target
protected static boolean matchesTarget(Message msg, java.lang.Object target)
msg
- the messagetarget
- the target
protected static boolean matchesType(Message msg, int[] messageTypes)
msg
- the list of messages; may not be nullmessageTypes
- the types
protected static boolean matchesType(Message msg, int messageType)
msg
- the list of messages; may not be nullmessageType
- the type
protected static void verifyMessage(java.lang.Object obj)
Message
.
obj
- the Object that is to be verified
java.lang.IllegalArgumentException
- if the object is not null and the object
is not an instance of Message
public void add(int index, java.lang.Object message)
List
add
in interface java.util.List
index
- the indexmessage
- the message
java.lang.IllegalArgumentException
- if the messsage is not an instance of Message
List.add(int, Object)
public boolean add(java.lang.Object message)
List
add
in interface java.util.Collection
add
in interface java.util.List
message
- the message
java.lang.IllegalArgumentException
- if the messsage is not an instance of Message
Collection.add(Object)
public boolean addAll(java.util.Collection messages)
List
addAll
in interface java.util.Collection
addAll
in interface java.util.List
messages
- the messages to be added
java.lang.IllegalArgumentException
- if the collection contains instances other than
Message
Collection.addAll(Collection)
public boolean addAll(int index, java.util.Collection messages)
List
addAll
in interface java.util.List
index
- the indexmessages
- the messages to be added
java.lang.IllegalArgumentException
- if the collection contains instances other than
Message
List.addAll(int, Collection)
public void clear()
List
clear
in interface java.util.Collection
clear
in interface java.util.List
Collection.clear()
public boolean contains(java.lang.Object message)
List
contains
in interface java.util.Collection
contains
in interface java.util.List
message
- the message
Collection.contains(Object)
public boolean containsAll(java.util.Collection messages)
List
containsAll
in interface java.util.Collection
containsAll
in interface java.util.List
messages
- the messages
Collection.containsAll(Collection)
public java.lang.Object get(int index)
List
get
in interface java.util.List
index
- the index at which the Message instance is to be returned
List.get(int)
public int indexOf(java.lang.Object message)
List
indexOf
in interface java.util.List
message
- the message
List.indexOf(Object)
public boolean isEmpty()
List
isEmpty
in interface java.util.Collection
isEmpty
in interface java.util.List
Collection.isEmpty()
public java.util.Iterator iterator()
List
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in interface java.util.List
Collection.iterator()
public int lastIndexOf(java.lang.Object message)
List
lastIndexOf
in interface java.util.List
message
- the Message object
List.lastIndexOf(Object)
public java.util.ListIterator listIterator()
List
listIterator
in interface java.util.List
List.listIterator()
public java.util.ListIterator listIterator(int index)
List
listIterator
in interface java.util.List
index
- the index at which the iterator is to begin
List.listIterator(int)
protected void messageRemoved(Message message)
message
- the message being removedprotected void messageAdded(Message message)
message
- the message being addedprotected void messagesCleared()
public java.lang.Object remove(int index)
List
remove
in interface java.util.List
index
- the index
List.remove(int)
public boolean remove(java.lang.Object message)
List
remove
in interface java.util.Collection
remove
in interface java.util.List
message
- the Message to be removed
Collection.remove(Object)
public boolean removeAll(java.util.Collection messages)
List
removeAll
in interface java.util.Collection
removeAll
in interface java.util.List
messages
- the Message instances to be removed
Collection.removeAll(Collection)
public boolean retainAll(java.util.Collection messages)
List
retainAll
in interface java.util.Collection
retainAll
in interface java.util.List
messages
- the Message instances to be removed
Collection.retainAll(Collection)
public java.lang.Object set(int index, java.lang.Object message)
List
set
in interface java.util.List
index
- the indexmessage
- the Message
List.set(int, Object)
public int size()
List
size
in interface java.util.Collection
size
in interface java.util.List
Collection.size()
public java.util.List subList(int fromIndex, int toIndex)
List
subList
in interface java.util.List
fromIndex
- the starting index (inclusive)toIndex
- the ending index (exclusive)
List.subList(int, int)
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
toArray
in interface java.util.List
Collection.toArray()
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection
toArray
in interface java.util.List
a
- the array into which the elements of this list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
java.lang.ArrayStoreException
- if the runtime type of the specified array
is not a supertype of the runtime type of every element in
this list.Collection.toArray(Object[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |