Purple Code

com.purpletech.util
Class EntryList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--com.purpletech.util.EntryList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable
Direct Known Subclasses:
XMLEntryList

public class EntryList
extends java.util.ArrayList

A List that acts like a cross between a List and a Map. It's full of Map.Entry records, so each value has a key.

get(int) returns the entry. get(object) returns the first value matching the given key (like a Map does). getAll(object) returns a List of values for the given key. Note that it can't actually implement Map because some idiot at Sun defined remove(Object)'s return value inconsistently between Map and List.

Implements PropertyChange pattern for JavaBeans support.

See Also:
Serialized Form

Nested Class Summary
protected static class EntryList.Entry
          Lifted from java/util/HashMap.java
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
EntryList()
           
EntryList(EntryList list)
           
 
Method Summary
 void add(java.lang.Object key, java.lang.Object value)
          Add the name-value pair to the list.
 void addAll(java.lang.Object key, java.util.List values)
          Add all the given values to this list under the given key
 void addPropertyChangeListener(java.beans.PropertyChangeListener p)
           
static java.lang.String fix(java.lang.String s)
           
 java.lang.Object get(java.lang.Object key)
          Get the first value corresponding to the given key
 java.util.List getAll(java.lang.Object key)
          Get all the values matching the given key
 java.util.List getAllEntries(java.lang.Object key)
          Get all the entries (name-value pairs) matching the given key
 java.util.Date getDate(java.lang.Object key)
          Get as a date.
 java.util.Map.Entry getEntry(int i)
          get an item as a Map.Entry
 java.util.Map.Entry getEntry(java.lang.Object key)
          Get the first entry corresponding to the given key
static void main(java.lang.String[] args)
           
 void printXml(java.io.PrintWriter out)
           
 void printXml(java.io.PrintWriter out, int indent)
           
 void put(java.lang.Object key, java.lang.Object value)
          Replace the current value, or add it if it doesn't exist.
 void remove(java.lang.Object key, java.lang.Object value)
          remove the given key-value pair
 void removeEntries(java.lang.Object key, java.lang.Object value)
          remove all the entries with the given value
 void removePropertyChangeListener(java.beans.PropertyChangeListener p)
           
 void set(EntryList list)
          Copy all the values from the given entrylist.
 void set(java.util.Map map)
          Copy all the name-value pairs from the given map.
 java.lang.String toString()
           
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Constructor Detail

EntryList

public EntryList()

EntryList

public EntryList(EntryList list)
Method Detail

add

public void add(java.lang.Object key,
                java.lang.Object value)
Add the name-value pair to the list.

Fires a PropertyChange event with the new value. Note that the semantics are a little flaky since the "old" value may still be present in the list as well as the new value.


addAll

public void addAll(java.lang.Object key,
                   java.util.List values)
Add all the given values to this list under the given key


put

public void put(java.lang.Object key,
                java.lang.Object value)
Replace the current value, or add it if it doesn't exist. Fires a PropertyChangeEvent.


get

public java.lang.Object get(java.lang.Object key)
Get the first value corresponding to the given key


getEntry

public java.util.Map.Entry getEntry(java.lang.Object key)
Get the first entry corresponding to the given key


getEntry

public java.util.Map.Entry getEntry(int i)
get an item as a Map.Entry


getAll

public java.util.List getAll(java.lang.Object key)
Get all the values matching the given key


getAllEntries

public java.util.List getAllEntries(java.lang.Object key)
Get all the entries (name-value pairs) matching the given key


removeEntries

public void removeEntries(java.lang.Object key,
                          java.lang.Object value)
remove all the entries with the given value


remove

public void remove(java.lang.Object key,
                   java.lang.Object value)
remove the given key-value pair


set

public void set(EntryList list)
Copy all the values from the given entrylist. Basically make this object into a shallow copy of the given list. Deletes all existing values. It copies the entries, but not the objects the entries point to. That way you can fiddle with the original list's entries without messing up this one.


set

public void set(java.util.Map map)
Copy all the name-value pairs from the given map. Replaces existing values, but doesn't delete existing entries (unless there's one with the same key in the map).


getDate

public java.util.Date getDate(java.lang.Object key)
Get as a date. If it's a string, parse it according to several different formats.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener p)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener p)

printXml

public void printXml(java.io.PrintWriter out)

printXml

public void printXml(java.io.PrintWriter out,
                     int indent)

fix

public static java.lang.String fix(java.lang.String s)

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection

main

public static void main(java.lang.String[] args)

Documentation generated March 5 2003