com.sap.tc.cmi.util

Class CMIAbstractObservableList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended bycom.sap.tc.cmi.util.CMIAbstractObservableList
All Implemented Interfaces:
Collection, ICMIObservableList, List

public abstract class CMIAbstractObservableList
extends 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.

Type Classification Type Classification:

This class is part of the Common Model Interface and is intended to be subclassed by applications.


Field Summary
 
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, Object element)
           
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 int addAllSilently(int index, Collection c)
           
 void addChangeListener(ICMIObservableListChangeListener listener)
          registeres the given listener.
 void addSilently(int index, 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(Object o, int index)
          fire an element added event for the given element and index
protected  void fireElementChanged(Object o, int index)
          fire an element changed event for the given element and index
protected  void fireElementRemoved(Object o, int index)
          fire an element removed event for the given element and index
 Object remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 void removeChangeListener(ICMIObservableListChangeListener listener)
          registeres the given listener.
protected  void removeRange(int fromIndex, int toIndex)
           
 void removeRangeSilently(int fromIndex, int toIndex)
           
 Object removeSilently(int index)
           
 boolean retainAll(Collection c)
           
 Object set(int index, Object element)
           
 Object setSilently(int index, 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(Object o,
                                        int index)
fire an element changed event for the given element and index


fireElementAdded

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


fireElementRemoved

protected final void fireElementRemoved(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,
                Object element)
Specified by:
add in interface List
See Also:
List.add(int, Object)

add

public boolean add(Object o)
Specified by:
add in interface List
See Also:
Collection.add(Object)

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface List
See Also:
Collection.addAll(Collection)

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List
See Also:
List.addAll(int, Collection)

clear

public void clear()
Specified by:
clear in interface List
See Also:
Collection.clear()

remove

public Object remove(int index)
Specified by:
remove in interface List
See Also:
List.remove(int)

remove

public boolean remove(Object o)
Specified by:
remove in interface List
See Also:
Collection.remove(Object)

removeRange

protected void removeRange(int fromIndex,
                           int toIndex)

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface List
See Also:
Collection.removeAll(Collection)

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface List
See Also:
Collection.retainAll(Collection)

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List
See Also:
List.set(int, Object)

setSilently

public Object setSilently(int index,
                          Object element)

addSilently

public void addSilently(int index,
                        Object element)

removeSilently

public Object removeSilently(int index)

addAllSilently

public int addAllSilently(int index,
                          Collection c)

removeRangeSilently

public void removeRangeSilently(int fromIndex,
                                int toIndex)


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.