org.progeeks.meta
Class AbstractListMutator

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by org.progeeks.meta.AbstractListMutator
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.List, ListMutator, PropertyMutator, ObservableList
Direct Known Subclasses:
DefaultListMutator

public abstract class AbstractListMutator
extends java.util.AbstractList
implements ListMutator

Abstract implementation of ListMutator providing basic functionality for dealing with List values.

Subclasses are required to implement at least the get(int) and size() methods for read-only access.

For a modifiable list, set(int, object) should be overriden and for a resizble list, add(object) and remove(int) should be overridden. Otherwise, these methods throw UnsupportedOperation exception.

To support change notification, subclasses must provide an implementation of the firePropertyChangeEvent() method.

Note: this may eventually move to the meta package and be re-extended here just to provide the ability to do external change notifications.

Version:
$Revision: 1.5 $
Author:
Paul Speed

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
AbstractListMutator()
           
 
Method Summary
 void add(int index, java.lang.Object object)
          Adds the object to the list value at the specified index.
 void clear()
          Clears the contents of the list value.
 void fireElementsInserted(int first, int last, java.util.List original)
          Sends an event to interested listeners that this property has had elements inserted.
 void fireElementsModified(int first, int last, java.util.List original)
          Sends an event to interested listeners that this property has had elements inserted.
 void fireElementsRemoved(int first, int last, java.util.List original)
          Sends an event to interested listeners that this property has had elements inserted.
protected abstract  void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
          Implemented by subclasses to deliver a change event to the appropriately registered listeners.
abstract  java.lang.Object get(int index)
          Returns the object at the specified location.
 java.lang.Object remove(int index)
          Removes the object at the specified location and returns the locations value prior to removal.
 java.lang.Object set(int index, java.lang.Object object)
          Replaces the value at the specified location.
abstract  int size()
          Returns the number of elements in the list value.
 
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.progeeks.meta.PropertyMutator
addPropertyChangeListener, getParentObject, getPropertyInfo, getPropertyName, getValue, removePropertyChangeListener, setValue
 
Methods inherited from interface org.progeeks.util.ObservableList
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface java.util.List
add, addAll, addAll, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, retainAll, subList, toArray, toArray
 

Constructor Detail

AbstractListMutator

public AbstractListMutator()
Method Detail

size

public abstract int size()
Returns the number of elements in the list value.

Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List
Specified by:
size in class java.util.AbstractCollection

get

public abstract java.lang.Object get(int index)
Returns the object at the specified location.

Specified by:
get in interface java.util.List
Specified by:
get in class java.util.AbstractList

add

public void add(int index,
                java.lang.Object object)
Adds the object to the list value at the specified index.

Specified by:
add in interface java.util.List
Overrides:
add in class java.util.AbstractList
Throws:
java.lang.UnsupportedOperationException - if the list value does not support insertions.

set

public java.lang.Object set(int index,
                            java.lang.Object object)
Replaces the value at the specified location.

Specified by:
set in interface java.util.List
Overrides:
set in class java.util.AbstractList
Throws:
java.lang.UnsupportedOperationException - if the list value does not support replacing elements.

remove

public java.lang.Object remove(int index)
Removes the object at the specified location and returns the locations value prior to removal.

Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.AbstractList
Throws:
java.lang.UnsupportedOperationException - if the list value does not support removes.

clear

public void clear()
Clears the contents of the list value.

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List
Overrides:
clear in class java.util.AbstractList
Throws:
java.lang.UnsupportedOperationException - if the list value does not support being cleared.

firePropertyChangeEvent

protected abstract void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
Implemented by subclasses to deliver a change event to the appropriately registered listeners.


fireElementsInserted

public void fireElementsInserted(int first,
                                 int last,
                                 java.util.List original)
Sends an event to interested listeners that this property has had elements inserted. These methods are public so that changes made external to the internal data structures can still cause notifications.


fireElementsModified

public void fireElementsModified(int first,
                                 int last,
                                 java.util.List original)
Sends an event to interested listeners that this property has had elements inserted. These methods are public so that changes made external to the internal data structures can still cause notifications.


fireElementsRemoved

public void fireElementsRemoved(int first,
                                int last,
                                java.util.List original)
Sends an event to interested listeners that this property has had elements inserted. These methods are public so that changes made external to the internal data structures can still cause notifications.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.