FileDocCategorySizeDatePackage
CDCatalog.javaAPI DocExample3960Wed Sep 19 09:33:08 BST 2001javaxml2

CDCatalog

public class CDCatalog extends Object

CDCatalog is a standalone Java class that stores CDs. It allows addition, retrieval, and listing of CDs. In this case, it is intended to be used as a web service, although no special coding considerations were taken with this in mind.

Fields Summary
private Hashtable
catalog
The CDs, by title
Constructors Summary
public CDCatalog()

Default constructor to initialize storage.

        catalog = new Hashtable();

        // Seed the catalog
        addCD(new CD("Nickel Creek", "Nickel Creek", "Sugar Hill"));
        addCD(new CD("Let it Fall", "Sean Watkins", "Sugar Hill"));
        addCD(new CD("Aerial Boundaries", "Michael Hedges", "Windham Hill"));
        addCD(new CD("Taproot", "Michael Hedges", "Windham Hill"));
    
Methods Summary
public voidaddCD(CD cd)

This adds a new {@link CD} to the catalog.

param
cd CD to add.

        if (cd == null) {
            throw new IllegalArgumentException("The CD object cannot be null.");
        }
        catalog.put(cd.getTitle(), cd);        
    
public CDgetCD(java.lang.String title)

This will retrieve the {@link CD} with the supplied title, or null if no such CD is found.

param
title the CD title to retrieve.
return
CD - the CD with the supplied title.

        if (title == null) {
            throw new IllegalArgumentException("Title cannot be null.");
        }

        // Return the requested CD
        return (CD)catalog.get(title);
    
public java.util.Hashtablelist()

This returns a listing of all CDs in this catalog.

return
Hashtable - all CDs, with the title as the key.

        return catalog;