com.anthonyeden.lib.util
Class ListFilter

java.lang.Object
  extended byjavax.swing.AbstractListModel
      extended bycom.anthonyeden.lib.util.ListMap
          extended bycom.anthonyeden.lib.util.ListFilter
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ListDataListener, javax.swing.ListModel, java.io.Serializable
Direct Known Subclasses:
ListMatchFilter

public abstract class ListFilter
extends ListMap

Class for filtering a ListModel.

Author:
Anthony Eden
See Also:
Serialized Form

Field Summary
protected  int[] indexes
           
protected  java.util.ArrayList tempIndexes
           
protected  java.util.ArrayList values
           
 
Fields inherited from class com.anthonyeden.lib.util.ListMap
model
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
ListFilter()
          Construct a new ListFilter.
ListFilter(javax.swing.ListModel model)
          Construct a new ListFilter for the given ListModel.
 
Method Summary
 void contentsChanged(javax.swing.event.ListDataEvent evt)
          Filter the list when the contents change.
abstract  void filter()
          Subclasses should implement this method to execute the filtering.
 void filter(java.util.ArrayList values)
          Set the value list and filter.
 void filter(java.lang.Object value)
          Filter a single value.
 void filter(java.lang.Object[] values)
          Set the value list and filter.
 java.lang.Object getElementAt(int index)
          Get the element at the given index in the list.
 int getSize()
          Get the size of the list.
 java.util.ArrayList getValues()
          Get the values.
 void intervalAdded(javax.swing.event.ListDataEvent evt)
          Filter the list when objects are added.
 void intervalRemoved(javax.swing.event.ListDataEvent evt)
          Filter the list when objects are removed.
 void setListModel(javax.swing.ListModel model)
          Set the list model.
 
Methods inherited from class com.anthonyeden.lib.util.ListMap
getModel, setModel
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tempIndexes

protected java.util.ArrayList tempIndexes

values

protected java.util.ArrayList values

indexes

protected int[] indexes
Constructor Detail

ListFilter

public ListFilter()
Construct a new ListFilter.


ListFilter

public ListFilter(javax.swing.ListModel model)
Construct a new ListFilter for the given ListModel.

Parameters:
model - The ListModel
Method Detail

setListModel

public void setListModel(javax.swing.ListModel model)
Set the list model. Calling this method will set the filtered ListModel and will execute the filter.

Parameters:
model - The ListModel

filter

public abstract void filter()
Subclasses should implement this method to execute the filtering.


intervalAdded

public void intervalAdded(javax.swing.event.ListDataEvent evt)
Filter the list when objects are added.

Specified by:
intervalAdded in interface javax.swing.event.ListDataListener
Overrides:
intervalAdded in class ListMap
Parameters:
evt - The ListDataEvent

intervalRemoved

public void intervalRemoved(javax.swing.event.ListDataEvent evt)
Filter the list when objects are removed.

Specified by:
intervalRemoved in interface javax.swing.event.ListDataListener
Overrides:
intervalRemoved in class ListMap
Parameters:
evt - The ListDataEvent

contentsChanged

public void contentsChanged(javax.swing.event.ListDataEvent evt)
Filter the list when the contents change.

Specified by:
contentsChanged in interface javax.swing.event.ListDataListener
Overrides:
contentsChanged in class ListMap
Parameters:
evt - The ListDataEvent

getSize

public int getSize()
Get the size of the list.

Specified by:
getSize in interface javax.swing.ListModel
Overrides:
getSize in class ListMap
Returns:
The size of the list

getElementAt

public java.lang.Object getElementAt(int index)
Get the element at the given index in the list.

Specified by:
getElementAt in interface javax.swing.ListModel
Overrides:
getElementAt in class ListMap
Parameters:
index - The index
Returns:
The value

filter

public void filter(java.lang.Object value)
Filter a single value.

Parameters:
value - The value

filter

public void filter(java.lang.Object[] values)
Set the value list and filter.

Parameters:
values - An array of Objects

filter

public void filter(java.util.ArrayList values)
Set the value list and filter.

Parameters:
values - The List of values

getValues

public java.util.ArrayList getValues()
Get the values.

Returns:
A List of values


Copyright (c) 2000-2003 Anthony Eden. All Rights Reserved.