com.isti.util.gui
Class FifoHashListModel

java.lang.Object
  extended byjavax.swing.AbstractListModel
      extended bycom.isti.util.gui.FifoHashListModel
All Implemented Interfaces:
javax.swing.ListModel, java.io.Serializable

public class FifoHashListModel
extends javax.swing.AbstractListModel

Class FifoHashListModel encasulates an 'UnsyncFifoHashtable' object and uses it in a 'ListModel' implementation suitable for use in a 'JList'. Methods are not thread synchronized.

See Also:
Serialized Form

Field Summary
protected  UnsyncFifoHashtable hashtableObj
           
protected  boolean listenersEnabledFlag
           
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
FifoHashListModel()
           
 
Method Summary
 void clear()
          Clears the hashtable data.
 boolean contains(java.lang.Object value)
          Tests if some key maps into the specified value in the hashtable data.
 boolean containsKey(java.lang.Object key)
          Tests if the specified object is a key in the hashtable data.
 boolean containsValue(java.lang.Object value)
          Returns true if the hashtable data maps one or more keys to this value.
 java.util.Enumeration elements()
          Returns an enumeration of the values in the hashtable data.
 void fireContentsChanged()
          Fires a contents-changed event.
protected  void fireItemPut(int preIdx, java.lang.Object key)
          Notifies listeners of a 'put' operation.
 java.lang.Object get(java.lang.Object key)
          Returns the value to which the hashtable data maps the specified key.
 java.lang.Object getElementAt(int indexVal)
          Returns the element at the given index value.
 int getSize()
          Returns the current size of the hashtable table data held by this object.
 java.util.Vector getValuesVector()
          Returns a new Vector containing the values in the hashtable data.
 int indexOf(java.lang.Object obj)
          Searches for the first occurrence of the given argument, testing for equality using the equals method.
 int indexOfKey(java.lang.Object obj)
          Searches for the first occurrence of the given key, testing for equality using the equals method.
 java.lang.Object keyAt(int idx)
          Returns the key at the specified index in the hashtable data.
 int lastIndexOf(java.lang.Object obj)
          Searches for the last occurrence of the given argument, testing for equality using the equals method.
 int lastIndexOfKey(java.lang.Object obj)
          Searches for the last occurrence of the given key, testing for equality using the equals method.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Associates the specified value with the specified key in the hashtable data.
 void putAll(java.util.Map mapObj)
          Copies all of the mappings from the specified map into the table.
 java.lang.Object putSort(java.lang.Object key, java.lang.Object value, boolean sortDirFlag)
          Adds a key/value pair to the hashtable data, placing it in sorted order according to the key.
 java.lang.Object putSort(java.lang.Object key, java.lang.Object value, boolean sortDirFlag, java.util.Comparator compObj)
          Adds a key/value pair to the hashtable table, placing it in sorted order according to the key.
 java.lang.Object putSort(java.lang.Object key, java.lang.Object value, boolean sortDirFlag, int sortType)
          Adds a key/value pair to the hashtable data, placing it in sorted order according to the key.
 void putSortAll(java.util.Map mapObj, boolean sortDirFlag)
          Copies all of the mappings from the specified map into the table, placing them in sorted order according to the keys.
 void putSortAll(java.util.Map mapObj, boolean sortDirFlag, java.util.Comparator compObj)
          Copies all of the mappings from the specified map into the table, placing them in sorted order according to the keys.
 void putSortAll(java.util.Map mapObj, boolean sortDirFlag, int sortType)
          Copies all of the mappings from the specified map into the table, placing them in sorted order according to the keys.
 java.lang.Object putSortByValue(java.lang.Object key, java.lang.Object value, boolean sortDirFlag)
          Adds a key/value pair to the hashtable data, placing it in sorted order according to the value.
 java.lang.Object putSortByValue(java.lang.Object key, java.lang.Object value, boolean sortDirFlag, java.util.Comparator compObj)
          Adds a key/value pair to the hashtable, placing it in sorted order according to the value.
 java.lang.Object putSortByValue(java.lang.Object key, java.lang.Object value, boolean sortDirFlag, int sortType)
          Adds a key/value pair to the hashtable data, placing it in sorted order according to the value.
 void putSortByValueAll(java.util.Map mapObj, boolean sortDirFlag)
          Copies all of the mappings from the specified map into the table, placing them in sorted order according to the values.
 void putSortByValueAll(java.util.Map mapObj, boolean sortDirFlag, java.util.Comparator compObj)
          Copies all of the mappings from the specified map into the table, placing them in sorted order according to the values.
 void putSortByValueAll(java.util.Map mapObj, boolean sortDirFlag, int sortType)
          Copies all of the mappings from the specified map into the table, placing them in sorted order according to the values.
 void removeElementAt(int indexVal)
          Removes the entry at the specified index in the hashtable data.
 java.lang.Object removeKey(java.lang.Object key)
          Removes the mapping for the given key from this hashtable if present.
 java.lang.Object removeValue(java.lang.Object obj)
          Removes the value and its key from this hashtable data if present.
 void reSortList(boolean sortDirFlag, int sortType)
          Resorts the list with the specified direction and type.
 void setListenersEnabled(boolean flgVal)
          Sets whether or not attached 'ListDataListener' objects are called when changes occur.
 java.util.Collection values()
          Returns a read-only collection view of the values contained in the hashtable data.
 
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

hashtableObj

protected final UnsyncFifoHashtable hashtableObj

listenersEnabledFlag

protected boolean listenersEnabledFlag
Constructor Detail

FifoHashListModel

public FifoHashListModel()
Method Detail

getSize

public int getSize()
Returns the current size of the hashtable table data held by this object.

Returns:
The size value.

getElementAt

public java.lang.Object getElementAt(int indexVal)
Returns the element at the given index value.

Parameters:
indexVal - the index value to use.
Returns:
The element object.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is negative or not less than the current size of the hashtable data.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Associates the specified value with the specified key in the hashtable data. If the hashtable previously contained a mapping for this key, the old value is replaced.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.

putAll

public void putAll(java.util.Map mapObj)
Copies all of the mappings from the specified map into the table. These mappings replace any mappings that this table had for any of the keys currently in the specified Map.

Parameters:
mapObj - mappings to be stored in this map.

putSort

public java.lang.Object putSort(java.lang.Object key,
                                java.lang.Object value,
                                boolean sortDirFlag)
Adds a key/value pair to the hashtable data, placing it in sorted order according to the key. The key should implement the Comparable interface. Associates the specified value with the specified key in this hashtable. If the table previously contained a mapping for this key, the old value is replaced.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
sortDirFlag - true for ascending sort order, false for descending.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.

putSort

public java.lang.Object putSort(java.lang.Object key,
                                java.lang.Object value,
                                boolean sortDirFlag,
                                int sortType)
Adds a key/value pair to the hashtable data, placing it in sorted order according to the key. The key should implement the Comparable interface. Associates the specified value with the specified key in this hashtable. If the table previously contained a mapping for this key, the old value is replaced.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
sortDirFlag - true for ascending sort order, false for descending.
sortType - the sort type.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.

putSort

public java.lang.Object putSort(java.lang.Object key,
                                java.lang.Object value,
                                boolean sortDirFlag,
                                java.util.Comparator compObj)
Adds a key/value pair to the hashtable table, placing it in sorted order according to the key. The key should implement the Comparable interface. Associates the specified value with the specified key in this hashtable. If the table previously contained a mapping for this key, the old value is replaced.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
sortDirFlag - true for ascending sort order, false for descending.
compObj - the comparator to use for sorting the 'key' objects, or null to use the "natural" sort order.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.

putSortAll

public void putSortAll(java.util.Map mapObj,
                       boolean sortDirFlag)
Copies all of the mappings from the specified map into the table, placing them in sorted order according to the keys. The keys should implement the Comparable interface. These mappings replace any mappings that this table had for any of the keys currently in the specified Map.

Parameters:
mapObj - mappings to be stored in this map.
sortDirFlag - true for ascending sort order, false for descending.

putSortAll

public void putSortAll(java.util.Map mapObj,
                       boolean sortDirFlag,
                       int sortType)
Copies all of the mappings from the specified map into the table, placing them in sorted order according to the keys. The keys should implement the Comparable interface. These mappings replace any mappings that this table had for any of the keys currently in the specified Map.

Parameters:
mapObj - mappings to be stored in this map.
sortDirFlag - true for ascending sort order, false for descending.
sortType - the sort type.

putSortAll

public void putSortAll(java.util.Map mapObj,
                       boolean sortDirFlag,
                       java.util.Comparator compObj)
Copies all of the mappings from the specified map into the table, placing them in sorted order according to the keys. The keys should implement the Comparable interface. These mappings replace any mappings that this table had for any of the keys currently in the specified Map.

Parameters:
mapObj - mappings to be stored in this map.
sortDirFlag - true for ascending sort order, false for descending.
compObj - the comparator to use for sorting the 'key' objects, or null to use the "natural" sort order.

putSortByValue

public java.lang.Object putSortByValue(java.lang.Object key,
                                       java.lang.Object value,
                                       boolean sortDirFlag)
Adds a key/value pair to the hashtable data, placing it in sorted order according to the value. The value should implement the Comparable interface. Associates the specified value with the specified key in this hashtable. If the table previously contained a mapping for this key, the old value is deleted and the new value is placed in proper sort order.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
sortDirFlag - true for ascending sort order, false for descending.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.

putSortByValue

public java.lang.Object putSortByValue(java.lang.Object key,
                                       java.lang.Object value,
                                       boolean sortDirFlag,
                                       int sortType)
Adds a key/value pair to the hashtable data, placing it in sorted order according to the value. The value should implement the Comparable interface. Associates the specified value with the specified key in this hashtable. If the table previously contained a mapping for this key, the old value is deleted and the new value is placed in proper sort order.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
sortDirFlag - true for ascending sort order, false for descending.
sortType - the sort type.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.

putSortByValue

public java.lang.Object putSortByValue(java.lang.Object key,
                                       java.lang.Object value,
                                       boolean sortDirFlag,
                                       java.util.Comparator compObj)
Adds a key/value pair to the hashtable, placing it in sorted order according to the value. The value should implement the Comparable interface. Associates the specified value with the specified key in this hashtable. If the table previously contained a mapping for this key, the old value is deleted and the new value is placed in proper sort order.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
sortDirFlag - true for ascending sort order, false for descending.
compObj - the comparator to use for sorting the 'key' objects, or null to use the "natural" sort order.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.

putSortByValueAll

public void putSortByValueAll(java.util.Map mapObj,
                              boolean sortDirFlag)
Copies all of the mappings from the specified map into the table, placing them in sorted order according to the values. The values should implement the Comparable interface. These mappings replace any mappings that this table had for any of the keys currently in the specified Map.

Parameters:
mapObj - mappings to be stored in this map.
sortDirFlag - true for ascending sort order, false for descending.

putSortByValueAll

public void putSortByValueAll(java.util.Map mapObj,
                              boolean sortDirFlag,
                              int sortType)
Copies all of the mappings from the specified map into the table, placing them in sorted order according to the values. The values should implement the Comparable interface. These mappings replace any mappings that this table had for any of the keys currently in the specified Map.

Parameters:
mapObj - mappings to be stored in this map.
sortDirFlag - true for ascending sort order, false for descending.
sortType - the sort type.

putSortByValueAll

public void putSortByValueAll(java.util.Map mapObj,
                              boolean sortDirFlag,
                              java.util.Comparator compObj)
Copies all of the mappings from the specified map into the table, placing them in sorted order according to the values. The values should implement the Comparable interface. These mappings replace any mappings that this table had for any of the keys currently in the specified Map.

Parameters:
mapObj - mappings to be stored in this map.
sortDirFlag - true for ascending sort order, false for descending.
compObj - the comparator to use for sorting the 'value' objects, or null to use the "natural" sort order.

get

public java.lang.Object get(java.lang.Object key)
Returns the value to which the hashtable data maps the specified key. Returns null if the hashtable contains no mapping for this key. A return value of null does not necessarily indicate that the hashtable contains no mapping for the key; it's also possible that the hashtable explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters:
key - key whose associated value is to be returned.
Returns:
the value to which this hashtable maps the specified key.

removeKey

public java.lang.Object removeKey(java.lang.Object key)
Removes the mapping for the given key from this hashtable if present.

Parameters:
key - key whose mapping is to be removed from the hashtable.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the hashtable previously associated null with the specified key.

removeValue

public java.lang.Object removeValue(java.lang.Object obj)
Removes the value and its key from this hashtable data if present.

Parameters:
obj - value to be removed from the hashtable.
Returns:
previous key associated with specified value, or null if the value was not found. A null return can also indicate that the hashtable previously associated null with the specified value.

removeElementAt

public void removeElementAt(int indexVal)
Removes the entry at the specified index in the hashtable data. Each entry in the table with an index greater than the specified index is shifted downward to have an index one smaller than it had previously. The size of the table is decreased by 1.

Parameters:
indexVal - the specified index; must be greater than or equal to zero and less than the size of the table.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is negative or not less than the current size of the table.

reSortList

public void reSortList(boolean sortDirFlag,
                       int sortType)
Resorts the list with the specified direction and type.

Parameters:
sortDirFlag - true for ascending sort order, false for descending.
sortType - the sort type.

containsKey

public boolean containsKey(java.lang.Object key)
Tests if the specified object is a key in the hashtable data.

Parameters:
key - possible key.
Returns:
true if and only if the specified object is a key in the hashtable data, as determined by the equals method; false otherwise.

containsValue

public boolean containsValue(java.lang.Object value)
Returns true if the hashtable data maps one or more keys to this value. This operation is more expensive than the 'containsKey()' method. Note that this method is identical in functionality to 'contains()' (which predates the Map interface).

Parameters:
value - the value to use.
Returns:
true if and only if some key maps to the value argument in the hashtable data as determined by the equals method; false otherwise.

contains

public boolean contains(java.lang.Object value)
Tests if some key maps into the specified value in the hashtable data. This operation is more expensive than the 'containsKey()' method. Note that this method is identical in functionality to 'containsValue()' (which is part of the Map interface in the collections framework).

Parameters:
value - the value to use.
Returns:
true if and only if some key maps to the value argument in the hashtable data as determined by the equals method; false otherwise.

indexOf

public int indexOf(java.lang.Object obj)
Searches for the first occurrence of the given argument, testing for equality using the equals method.

Parameters:
obj - the object to find.
Returns:
The index of the first occurrence of the argument in the hashtable data; returns -1 if the object is not found.

lastIndexOf

public int lastIndexOf(java.lang.Object obj)
Searches for the last occurrence of the given argument, testing for equality using the equals method.

Parameters:
obj - the object to find.
Returns:
The index of the last occurrence of the argument in the hashtable data; returns -1 if the object is not found.

indexOfKey

public int indexOfKey(java.lang.Object obj)
Searches for the first occurrence of the given key, testing for equality using the equals method.

Parameters:
obj - the key to find.
Returns:
The index of the first occurrence of the key in the hashtable data; returns -1 if the object is not found.

lastIndexOfKey

public int lastIndexOfKey(java.lang.Object obj)
Searches for the last occurrence of the given key, testing for equality using the equals method.

Parameters:
obj - the key to find.
Returns:
The index of the last occurrence of the key in the hashtable data; returns -1 if the object is not found.

keyAt

public java.lang.Object keyAt(int idx)
Returns the key at the specified index in the hashtable data.

Parameters:
idx - the index value to use.
Returns:
the key object associated with the given index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is negative or not less than the current size of the hashtable data.

clear

public void clear()
Clears the hashtable data.


elements

public java.util.Enumeration elements()
Returns an enumeration of the values in the hashtable data. The values will be enumerated in same order as they were added to the table. The data referenced by the the returned enumeration will not be affected by later modifications to the hashtable.

Returns:
An enumeration of the values in the hashtable data.

getValuesVector

public java.util.Vector getValuesVector()
Returns a new Vector containing the values in the hashtable data. The values will enumerated in same order as they were added to the table. The data in the the returned Vector will not be affected by later modifications to the hashtable, and the hashtable will not be affected by modifications to the returned Vector.

Returns:
A new Vector containing the values in the hashtable data.

values

public java.util.Collection values()
Returns a read-only collection view of the values contained in the hashtable data. The collection does not support any add or remove operations.

Returns:
A collection view of the values contained in this map.

setListenersEnabled

public void setListenersEnabled(boolean flgVal)
Sets whether or not attached 'ListDataListener' objects are called when changes occur.

Parameters:
flgVal - true to enable calling of 'ListDataListener' objects, false to disable.

fireContentsChanged

public void fireContentsChanged()
Fires a contents-changed event.


fireItemPut

protected void fireItemPut(int preIdx,
                           java.lang.Object key)
Notifies listeners of a 'put' operation. If the index of the given key has changed then 'removed' and 'added' change events are fired.

Parameters:
preIdx - the previous index of the given key (before the 'put' operation) or -1 if not previously in table.
key - the key object to use.