CMI documentation

com.sap.tc.cmi.util
Class CMIAbstractObservableList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--com.sap.tc.cmi.util.CMIAbstractObservableList
All Implemented Interfaces:
java.util.Collection, ICMIObservableList, java.util.List

public abstract class CMIAbstractObservableList
extends java.util.AbstractList
implements ICMIObservableList

Abstract implementation of the ICMIObservableList interface.

This class is not at all thread safe (for peformance reasons).

This implementation modifies the contract that AbstractList defines for subclasses.

All modifying methods of the List interface have been overridden using the Template/Hook pattern. The template implementations delegate all changes to hook methods and afterwards send out notification events about the changes made. The hook methods only have to take care about the change itself and must not fire events. To identify them and to better reflect their behavior, the names of the hook methods end in *Silently.

Preferably subclasses should override the hook methods only as these are easier to implement. But if the template implementation of a modifying method doesn't fit, subclasses can override or extend that template method as well. If they override it, they have to implement the notification on their own. If they extend it, they must take care to inform listeners about a change after it has been completed. So calls to super typically will be the last step in an extended method.

In general, subclasses must be careful in their modifier implementations when calling other methods that potentially result in notification events. Listeners usually expect to be notified only once about a single change.

To implement an unmodifiable list, subclasses have to implement the methods size() and get(int index) as introduced by AbstractList.

To implement a modifiable list, subclasses can override the setSilently(int index, Object o) method. If the list is variable-size, they additionally have to override the addSilently(int index, Object element) and removeSilently(int index) methods.

This type can be called or extended by applications or frameworks using CMI.

Version:
$Id: //tc/CommonModelInterface/630_VAL_REL/src/_cmi_api/java/com/sap/tc/cmi/util/CMIAbstractObservableList.java#1 $

Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
protected CMIAbstractObservableList()
          Constructor for CMIAbstractObservableList to be called by subclasses.
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
 int addAllSilently(int index, java.util.Collection c)
           
 void addChangeListener(ICMIObservableListChangeListener listener)
          registeres the given listener.
 void addSilently(int index, java.lang.Object element)
           
 void clear()
           
protected  void fireComplexChange(int fromIndex, int toIndex, int type)
          fire a complex change event of the given type
protected  void fireElementAdded(java.lang.Object o, int index)
          fire an element added event for the given element and index
protected  void fireElementChanged(java.lang.Object o, int index)
          fire an element changed event for the given element and index
protected  void fireElementRemoved(java.lang.Object o, int index)
          fire an element removed event for the given element and index
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 void removeChangeListener(ICMIObservableListChangeListener listener)
          registeres the given listener.
protected  void removeRange(int fromIndex, int toIndex)
           
 void removeRangeSilently(int fromIndex, int toIndex)
           
 java.lang.Object removeSilently(int index)
           
 boolean retainAll(java.util.Collection c)
           
 java.lang.Object set(int index, java.lang.Object element)
           
 java.lang.Object setSilently(int index, java.lang.Object element)
           
 
Methods inherited from class java.util.AbstractList
equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, size, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, size, subList, toArray, toArray
 

Constructor Detail

CMIAbstractObservableList

protected CMIAbstractObservableList()
Constructor for CMIAbstractObservableList to be called by subclasses.
Method Detail

addChangeListener

public void addChangeListener(ICMIObservableListChangeListener listener)
Description copied from interface: ICMIObservableList
registeres the given listener. Thel istener will be notified about any modification of this list.
Specified by:
addChangeListener in interface ICMIObservableList
See Also:
ICMIObservableList.addChangeListener(ICMIObservableListChangeListener)

removeChangeListener

public void removeChangeListener(ICMIObservableListChangeListener listener)
Description copied from interface: ICMIObservableList
registeres the given listener. Thel istener will be notified about any modification of this list.
Specified by:
removeChangeListener in interface ICMIObservableList
See Also:
ICMIObservableList.removeChangeListener(ICMIObservableListChangeListener)

fireElementChanged

protected final void fireElementChanged(java.lang.Object o,
                                        int index)
fire an element changed event for the given element and index

fireElementAdded

protected final void fireElementAdded(java.lang.Object o,
                                      int index)
fire an element added event for the given element and index

fireElementRemoved

protected final void fireElementRemoved(java.lang.Object o,
                                        int index)
fire an element removed event for the given element and index

fireComplexChange

protected final void fireComplexChange(int fromIndex,
                                       int toIndex,
                                       int type)
fire a complex change event of the given type

add

public void add(int index,
                java.lang.Object element)
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.AbstractList
See Also:
List.add(int, Object)

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.AbstractList
See Also:
Collection.add(Object)

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.AbstractCollection
See Also:
Collection.addAll(Collection)

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.AbstractList
See Also:
List.addAll(int, Collection)

clear

public void clear()
Specified by:
clear in interface java.util.List
Overrides:
clear in class java.util.AbstractList
See Also:
Collection.clear()

remove

public java.lang.Object remove(int index)
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.AbstractList
See Also:
List.remove(int)

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.AbstractCollection
See Also:
Collection.remove(Object)

removeRange

protected void removeRange(int fromIndex,
                           int toIndex)
Overrides:
removeRange in class java.util.AbstractList

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.List
Overrides:
removeAll in class java.util.AbstractCollection
See Also:
Collection.removeAll(Collection)

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.List
Overrides:
retainAll in class java.util.AbstractCollection
See Also:
Collection.retainAll(Collection)

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Specified by:
set in interface java.util.List
Overrides:
set in class java.util.AbstractList
See Also:
List.set(int, Object)

setSilently

public java.lang.Object setSilently(int index,
                                    java.lang.Object element)

addSilently

public void addSilently(int index,
                        java.lang.Object element)

removeSilently

public java.lang.Object removeSilently(int index)

addAllSilently

public int addAllSilently(int index,
                          java.util.Collection c)

removeRangeSilently

public void removeRangeSilently(int fromIndex,
                                int toIndex)

CMI documentation

Copyright © 2002 SAP AG. Automatically generated Thu Mar 3 2005, 21:53