agentland.device.intelliCD
Class SCollection

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--agentland.device.intelliCD.SongContainer
                          |
                          +--agentland.device.intelliCD.SCollection
All Implemented Interfaces:
Cloneable, Collection, List, Serializable, SongContainerElement
Direct Known Subclasses:
SQLCollection

public class SCollection
extends SongContainer

The SCollection is a SongContainer with some hashtables for fast lookups.

See Also:
SongContainer, Song, Serialized Form

Fields inherited from class agentland.device.intelliCD.SongContainer
author, id, parent, title
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SCollection()
           
 
Method Summary
 void addContainer(SongContainer sc)
          Adds a song container to the collection.
 void addContainer(SongContainer sc, SongContainer parent)
          Inserts the given song into the collection with the given parent, but does not descend through the SongContainer adding songs by itself.
 void addSong(Song s, SongContainer parent)
          Inserts the given song into the collection with the given parent.
 Iterator containerIterator()
          Returns an iterator for looping through all the SongContainers in the SCollection.
 SongContainer lookupContainer(long l)
          Looks up the SongContainer given an id number.
 Song lookupSong(Song s)
          Looks up the given song.
 int prune()
          Prunes off any empty containers.
 Iterator songIterator()
          Returns an iterator for looping through all the Songs in the SCollection.
 
Methods inherited from class agentland.device.intelliCD.SongContainer
add, add, addFromContainer, copyParent, copyParentTree, copySubtree, equals, getAuthor, getElement, getID, getName, getParent, getSCE, getSongsRecursive, getTitle, hashCode, iconName, init, lightweightCopy, lookup, lookupContainer, printWithPrefix, remove, set, setAuthor, setID, setParent, setTitle, shallowCopy, toString
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, firstElement, get, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

SCollection

public SCollection()
Method Detail

addContainer

public void addContainer(SongContainer sc)
Adds a song container to the collection.

lookupSong

public Song lookupSong(Song s)
Looks up the given song. This method exists so that a song `placeholder' consisting only of an ID can get the full details from the SCollection.
Overrides:
lookupSong in class SongContainer

lookupContainer

public SongContainer lookupContainer(long l)
Looks up the SongContainer given an id number.
Overrides:
lookupContainer in class SongContainer

containerIterator

public Iterator containerIterator()
Returns an iterator for looping through all the SongContainers in the SCollection.

songIterator

public Iterator songIterator()
Returns an iterator for looping through all the Songs in the SCollection.

addSong

public void addSong(Song s,
                    SongContainer parent)
             throws IllegalArgumentException
Inserts the given song into the collection with the given parent. If the parent container is null, then the song is inserted into the top level of the collection. Otherwise, the container must be present in the collection, or an exception will be thrown.
Parameters:
s - The song to add.
parent - The parent container.
Throws:
IllegalArgumentException - if the container argument is an object that is not present in the collection.

addContainer

public void addContainer(SongContainer sc,
                         SongContainer parent)
                  throws IllegalArgumentException
Inserts the given song into the collection with the given parent, but does not descend through the SongContainer adding songs by itself. If the parent container is null, then the container is inserted into the top level of the collection. Otherwise, the container must be present in the collection, or an exception will be thrown.
Parameters:
sc - The song container to add.
parent - The parent container.
Throws:
IllegalArgumentException - if the container argument is an object that is not present in the collection.

prune

public int prune()
Prunes off any empty containers. This is just to clean up the collection a bit.
Returns:
The number of removed containers.