import DatabaseEntry;
import Artist;
import Art;
import Bidder;
import EntryList;
import Address;
import Person;
import ObjectType;

/**
 * Class Database
 * Date: May 3, 1999
 * @author Oleksiy Andriychenko
 * @author Khondker Rumman Akhter
 * @author Shekhar Shah
 *
 * This is the database class. It provides the data structure to store the 
 * objects of the Art, Artist, and Client classes It also provides the 
 * common methods to perform general operations on the data structure.
 */

// Class declaration
public class Database 
    implements DB_Interface{

// +--------+------------------------------------------------------------
// | Fields |
// +--------+

    protected Art[] ArtData;
    protected Artist[] ArtistData;
    protected Bidder[] BidderData;
    protected int ArtLength;
    protected int ArtistLength;
    protected int BidderLength;

// +--------------+------------------------------------------------------
// | Constructors |
// +--------------+

   
    /** Default Constructor
     *  Pre: There is enough memory to create three arrays totalling
     *       11000 elements.
     *  Post: Creates the three arrays.
     *  Post: Initializes the three array lengths to 0.
     */
    public Database(){
        this.ArtData = new Art[5000];
        this.ArtistData = new Artist[1000];
        this.BidderData = new Bidder[5000];
        this.ArtLength = 0;
        this.ArtistLength = 0;
        this.BidderLength = 0;
    }//Database()
    
    
// +-----------+---------------------------------------------------------
// |  Methods  |
// +-----------+

    /** Method delete(String key)
     *  Pre: The database is initialized.
     *  Pre: The contents of the Array at the index corresponding to the
     *       key is not null.
     *  Post: Replaces the Object at the index corresponding to the
     *        key with the null value.
     *  Post: Returns the deleted object.
     *  Post: Decreases appropriate length by one.
     */  
    public DatabaseEntry delete(String key)
        throws Exception{
        
        Integer BigIntKey = new Integer(key);
        int intKey = BigIntKey.intValue();

        if (intKey < 20000){
            int index = (intKey - 10000);
            try{
                DatabaseEntry tmp = ArtData[index];
                ArtData[index] = null;
                return tmp;
            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch
        }//if
        
        else if (intKey < 30000){
            int index = (intKey - 20000);
            try{
                DatabaseEntry tmp = ArtistData[index];
                ArtistData[index] = null;
                return  tmp;

            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch        
        }//else if
        
        else if (intKey < 40000){
            int index = (intKey - 30000);
            try{
                DatabaseEntry tmp = BidderData[index];
                BidderData[index] = null;
                return tmp;
            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch
        }//else if

        else {
            throw new Exception("Unable to lookup entry.");
        }//else  
    }// delete(String key)
    
    
    /** Method update(DatabaseEntry newValues);
     *  Pre: The data base has been initialized
     *  Pre: The object is complete (all fields, in particular the key) are 
     *       initialized
     *  Pre: the key is in the proper format
     *  Post: returns nothing
     *  Post: The database is changed
     */
    public void update(DatabaseEntry newValues) 
        throws Exception{
        Integer key = new Integer(newValues.getKey());
        int intKey = key.intValue();

        if (intKey < 20000){
            int index = (intKey - 10000);
            try{
                ArtData[index] = (Art) newValues;
            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch
        }//if
        
        else if (intKey < 30000){
            int index = (intKey - 20000);
            try{
                ArtistData[index] = (Artist) newValues;
            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch        
        }//else if
        
        else if (intKey < 40000){
            int index = (intKey - 30000);
            try{
                BidderData[index] = (Bidder) newValues;
            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch
        }//else if
        else {
            throw new Exception("Unable to update entry.");
        }//else
    }//update(DatabaseEntry newValues)
        

    /** Method lookup(String key)
     *  Pre: There exists an Object in the relevant database with the key 
     *       passed on as a parameter
     *  Pre: the key is in the proper format (see the note above about the key)
     *  Post: returns the Object with the given key
     *  Post: The database is not changed
     */    
    public DatabaseEntry lookUp (String key)
        throws Exception{

        Integer BigIntKey = new Integer(key);
        int intKey = BigIntKey.intValue();

        if (intKey < 20000){
            int index = (intKey - 10000);
            try{
                return ArtData[index];
            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch
        }//if
        
        else if (intKey < 30000){
            int index = (intKey - 20000);
            try{
                return ArtistData[index];
            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch        
        }//else if
        
        else if (intKey < 40000){
            int index = (intKey - 30000);
            try{
                return BidderData[index];
            }//try
            catch(Exception e) {
                throw new Exception("Error in key.");
            }//catch
        }//else if
        else {
            throw new Exception("Unable to lookup entry.");
        }//else
    }//lookUp(String key)
    
    /** Method EntryList listByField(int objectType,  String fieldName, 
     *                               String pattern)
     * objectType: field in the objectType class
     *           ObjectType.ARTIST, for example.
     * pattern : #* words starting with letter #
     *         : other strings = exact match
     *
     *  Pre: The database is initialized.
     *  Post: Returns an Entrylist triplets of name, id, and key of all the matches.
     *  Post: If there is no match, the length of the output list is 0.
     */    

    public EntryList listByField(int objectType,
                                 String fieldName,
                                 String pattern)
        throws Exception{
        EntryList list = new EntryList();
        fieldName = fieldName.toLowerCase();
        
        switch(objectType){
                
        case ObjectType.ART:                        
            for (int i = 0; i < ArtLength; ++i) {
                    
                if (ArtData[i] == null){
                }//if null
                    
                else {
                    DatabaseEntry tmp = ArtData[i];
                    Art Arttmp = (Art)tmp;
                        
                    if (fieldName.equals("name")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1); 
                            if (tmp.getName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getName() == pattern){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "Name"

                    else if (fieldName.equals("firstname")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1); 
                            if (Arttmp.getFname().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getFname().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "firstname"

                    else if (fieldName.equals("lastname")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1); 
                            if (Arttmp.getLname().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getLname().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "lastname"
                        
                    else if (fieldName.equals("medium")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1); 
                            if (Arttmp.getMed().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getMed().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "medium"
                        
                    else if (fieldName.equals("size")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1); 
                            if (Arttmp.getSize().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getSize().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "size"
                        
                    else if (fieldName.equals("id")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getId().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getId().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "id"

                    else if (fieldName.equals("artist")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Arttmp.getArtkey().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getArtkey().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "artist"

                    else if (fieldName.equals("minbid")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getMin();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getMin();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no * 
                    }//if "minbid"

                    else if (fieldName.equals("title")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getTitle();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getTitle();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no * 
                    }//if "title"

                    else if (fieldName.equals("genre")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getGenre();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getGenre();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no * 
                    }//if "genre"

                    else if (fieldName.equals("current")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getCurrent();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getCurrent();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *  
                    }//if "currentbid"
                         
                    else if (fieldName.equals("bidrec")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getBidrec();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getBidrec();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *  
                    }//if "numbids"
                         
                    else if (fieldName.equals("numbidders")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getNumbidders();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getNumbidders();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *  
                    }//if "numbidders"

                    else if (fieldName.equals("auctionable")){
                        Boolean auct = new Boolean(Arttmp.getAuctionable());
                        if (auct.toString().equals(pattern)){
                            list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                        }//if match  
                    }//if "auctionable"
                        
                    else if (fieldName.equals("location")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Arttmp.getLocation().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getLocation().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *  
                    }//if "location"
                        
                    else{
                        throw new Exception("Field not supported.");
                    }//else
                }//else if not null
            }//for each element in the ArtData
            return list;
                        
        case ObjectType.ARTIST:
            for (int i = 0; i < ArtistLength; ++i) {
                    
                if (ArtistData[i] == null){
                }//if null
                    
                else {
                    DatabaseEntry tmp = ArtistData[i];
                    Artist Artisttmp = (Artist)tmp;
                    Person Persontmp = (Person)tmp;
                    Address Address = Persontmp.getAddress();
                        
                    if (fieldName.equals("name")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "name"
                        
                    else if (fieldName.equals("firstname")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getFirstName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getFirstName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "firstname"
                        
                    else if (fieldName.equals("lastname")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getLastName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getLastName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "lastname"
                        
                    else if (fieldName.equals("title")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getTitle().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getTitle().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "title"
                        
                    else if (fieldName.equals("suffix")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getSuffix().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getSuffix().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "suffix"
                        
                    else if (fieldName.equals("phone")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getPhone().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getPhone().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "phone"

                    else if (fieldName.equals("fax")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getFax().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getFax().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "fax"
                        
                    else if (fieldName.equals("email")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getEmail().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getEmail().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "email"
                        
                    else if (fieldName.equals("local")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getLocal().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getLocal().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "local"

                    else if (fieldName.equals("id")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getId().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getId().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "id"
                     
                    else if (fieldName.equals("address-0")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-0").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-0").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-0"
                  
                    else if (fieldName.equals("address-1")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-1").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-1").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-1"
                        
                    else if (fieldName.equals("address-2")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-2").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-2").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-2"
                        
                    else if (fieldName.equals("address-3")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-3").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-3").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-3"
                        
                    else if (fieldName.equals("address-4")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-4").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-4").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-4"
                        
                    else if (fieldName.equals("city")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getCity().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getCity().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "city"
                        
                    else if (fieldName.equals("state")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getState().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getState().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "state"
                        
                    else if (fieldName.equals("country")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getCountry().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getCountry().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "country"
                        
                    else if (fieldName.equals("zip")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getZip().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getZip().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "zip"
                        
                    else{
                        throw new Exception("Field not supported.");
                    }//else
                }//else if not null
            }//for each element in the ArtistData
            return list;
                
        case ObjectType.BIDDER:
            for (int i = 0; i < BidderLength; ++i) {
                    
                if (BidderData[i] == null){
                }//if null
                    
                else {
                    DatabaseEntry tmp = BidderData[i];
                    Bidder Biddertmp = (Bidder)tmp;
                    Person Persontmp = (Person)tmp;
                    Address Address = Persontmp.getAddress();

                    if (fieldName.equals("name")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "name"
                        
                    else if (fieldName.equals("firstname")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getFirstName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getFirstName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "firstname" 
                        
                    else if (fieldName.equals("lastname")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getLastName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getLastName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "lastname"

                    else if (fieldName.equals("title")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getTitle().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getTitle().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "title"
                        
                    else if (fieldName.equals("suffix")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getSuffix().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getSuffix().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "suffix"
                        
                    else if (fieldName.equals("phone")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getPhone().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getPhone().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "phone"

                    else if (fieldName.equals("fax")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getFax().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getFax().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "fax"
                        
                    else if (fieldName.equals("email")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getEmail().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getEmail().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "email"
                        
                    else if (fieldName.equals("local")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getLocal().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getLocal().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "local"
                        
                    else if (fieldName.equals("payment")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Biddertmp.getPaymentMethod().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Biddertmp.getPaymentMethod().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "payment"
                        
                    else if (fieldName.equals("hotelroom")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Biddertmp.getHotelRoom().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Biddertmp.getHotelRoom().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "hotelroom"

                    else if (fieldName.equals("localphone")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Biddertmp.getLocalPhone().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Biddertmp.getLocalPhone().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "localphone"
                        
                    else if (fieldName.equals("id")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getId().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getId().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "Id"
                        
                    else if (fieldName.equals("address-0")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-0").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-0").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-0"
                  
                    else if (fieldName.equals("address-1")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-1").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-1").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-1"
                        
                    else if (fieldName.equals("address-2")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-2").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-2").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-2"
                        
                    else if (fieldName.equals("address-3")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-3").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-3").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-3"
                        
                    else if (fieldName.equals("address-4")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-4").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-4").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-4"
                        
                    else if (fieldName.equals("city")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getCity().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getCity().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "city"
                        
                    else if (fieldName.equals("state")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getState().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getState().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "state"
                        
                    else if (fieldName.equals("country")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getCountry().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getCountry().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "country"
                        
                    else if (fieldName.equals("zip")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getZip().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getZip().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *    
                    }//if "zip"
                        
                    else if (fieldName.equals("credit")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            int intNum = Biddertmp.getCredit();
                            Integer IntNum = new Integer(intNum);
                            String stringNum = IntNum.toString();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//if * pattern
                        else {
                            int intNum = Biddertmp.getCredit();
                            Integer IntNum = new Integer(intNum);
                            String stringNum = IntNum.toString();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),"");
                            }//if match
                        }//else if the pattern has no *
                    }//if "credit"

                    else{
                        throw new Exception("Field not supported.");
                    }//else
                }//else if not null
            }//for each element in the BidderData
            return list;
                
        default:
            return new EntryList();    
                
        }//switch
       
    }//listByField(int objectType,String fieldName,String pattern)


    /** Method EntryList listByField(int objectType,  String fieldName, 
     *         String pattern, String displayField);
     * objectType: field in the objectType class
     *           ObjectType.ARTIST, for example.
     *
     * fieldName: Name of the field to search for pattern
     *
     * pattern : #* words starting with letter #
     *         : other strings = exact match
     *
     * displayField: An additional field to return in the EntryList. 
     *
     *  Pre: The database is initialized.
     *  Post: Returns a list triplets of name, id, and key and optional 
     *        displayField for all the Objects in the appropriate array whose 
     *        Field starts with FirstLetter,(if pattern is X*) or completely 
     *        match (if not #* pattern)
     *
     *  Post: If there is no match, the length of the output list is 0.
     */    

    public EntryList listByField(int objectType,
                                 String fieldName,
                                 String pattern,
                                 String displayField)
        throws Exception{
         
        EntryList list = new EntryList();
        fieldName = fieldName.toLowerCase();
        switch(objectType){
                 
        case ObjectType.ART:                        
            for (int i = 0; i < ArtLength; ++i) {
                     
                if (ArtData[i] == null){
                }//if null
                     
                else {
                    DatabaseEntry tmp = ArtData[i];
                    Art Arttmp = (Art)tmp;
                         
                    if (fieldName.equals("name")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getName());
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getName());
                            }//if match
                        }//else if the pattern has no *
                    }//if "name"
                         
                    else if (fieldName.equals("firstname")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Arttmp.getFname().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getFname());
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getFname().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getFname());
                            }//if match
                        }//else if the pattern has no *
                    }//if "firstname"

                    else if (fieldName.equals("lastname")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Arttmp.getLname().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getLname());
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getLname().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getLname());
                            }//if match
                        }//else if the pattern has no *
                    }//if "lastname"

                    else if (fieldName.equals("id")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getId().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getId());
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getId().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getId());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "id"

                    else if (fieldName.equals("artist")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Arttmp.getArtkey().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Arttmp.getArtkey());
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getArtkey().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Arttmp.getArtkey());
                            }//if match
                        }//else if the pattern has no *
                    }//if "artist"
                         
                    else if (fieldName.equals("title")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getTitle();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getTitle());
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getTitle();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getTitle());
                            }//if match
                        }//else if the pattern has no * 
                    }//if "title"

                    else if (fieldName.equals("genre")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getGenre();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getGenre());
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getGenre();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getGenre());
                            }//if match
                        }//else if the pattern has no * 
                    }//if "genre"
                         
                    else if (fieldName.equals("medium")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1); 
                            if (Arttmp.getMed().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getMed());
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getMed().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getMed());
                            }//if match
                        }//else if the pattern has no *
                    }//if "Name"
                        
                    else if (fieldName.equals("size")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1); 
                            if (Arttmp.getSize().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getSize());
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getSize().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getSize());
                            }//if match
                        }//else if the pattern has no *
                    }//if "size"
                         
                    else if (fieldName.equals("minbid")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getMin();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Arttmp.getMin());
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getMin();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Arttmp.getMin());
                            }//if match
                        }//else if the pattern has no * 
                    }//if "minbid"
                         
                    else if (fieldName.equals("current")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getCurrent();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Arttmp.getCurrent());
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getCurrent();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Arttmp.getCurrent());
                            }//if match
                        }//else if the pattern has no *
                    }//if "currentbid"
                         
                    else if (fieldName.equals("bidrec")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getBidrec();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Arttmp.getBidrec());
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getBidrec();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Arttmp.getBidrec());
                            }//if match
                        }//else if the pattern has no *  
                    }//if "numbids"
                         
                    else if (fieldName.equals("numbidders")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            String stringNum = Arttmp.getNumbidders();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Arttmp.getNumbidders());
                            }//if match
                        }//if * pattern
                        else {
                            String stringNum = Arttmp.getNumbidders();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Arttmp.getNumbidders());
                            }//if match
                        }//else if the pattern has no *  
                    }//if "numBidders"
                         
                    else if (fieldName.equals("auctionable")){
                        Boolean auct = new Boolean(Arttmp.getAuctionable());
                        if (auct.toString().equals(pattern)){
                            list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                     ""+Arttmp.getAuctionable());
                        }//if match  
                    }//if "auctionable"
                         
                    else if (fieldName.equals("location")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Arttmp.getLocation().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Arttmp.getLocation());
                            }//if match
                        }//if * pattern
                        else {
                            if (Arttmp.getLocation().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Arttmp.getLocation());
                            }//if match
                        }//else if the pattern has no *  
                    }//if "location"
                         
                    else{
                        throw new Exception("Field not supported");
                    }//else
                }//else if not null
            }//for each element in the ArtData
            return list;
                 
        case ObjectType.ARTIST:
            for (int i = 0; i < ArtistLength; ++i) {
                     
                if (ArtistData[i] == null){
                }//if null
                     
                else {
                    DatabaseEntry tmp = ArtistData[i];
                    Person Persontmp = (Person)tmp;
                    Address Address = Persontmp.getAddress();
                         
                    if (fieldName.equals("name")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),tmp.getName());
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),tmp.getName());
                            }//if match
                        }//else if the pattern has no *
                    }//if "Name"
                         
                    else if (fieldName.equals("firstname")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getFirstName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getFirstName());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getFirstName());
                            }//if match
                        }//else if the pattern has no *
                    }//if "firstname"
                         
                    else if (fieldName.equals("lastname")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getLastName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getLastName());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getFirstName());
                            }//if match
                        }//else if the pattern has no *
                    }//if "lastname"

                    else if (fieldName.equals("title")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getTitle().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getTitle());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getTitle().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getTitle());
                            }//if match
                        }//else if the pattern has no *
                    }//if "title"
                        
                    else if (fieldName.equals("suffix")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getSuffix().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getSuffix());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getSuffix().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getSuffix());
                            }//if match
                        }//else if the pattern has no *
                    }//if "suffix"
                        
                    else if (fieldName.equals("phone")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getPhone().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getPhone());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getPhone().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getPhone());
                            }//if match
                        }//else if the pattern has no *
                    }//if "phone"

                    else if (fieldName.equals("fax")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getFax().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getFax());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getFax().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getFax());
                            }//if match
                        }//else if the pattern has no *
                    }//if "fax"
                        
                    else if (fieldName.equals("email")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getEmail().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getEmail());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getEmail().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getEmail());
                            }//if match
                        }//else if the pattern has no *
                    }//if "email"
                        
                    else if (fieldName.equals("local")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getLocal().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getLocal());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getLocal().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getLocal());
                            }//if match
                        }//else if the pattern has no *
                    }//if "local"
                         
                    else if (fieldName.equals("id")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getId().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),tmp.getId());
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getId().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),tmp.getId());
                            }//if match
                        }//else if the pattern has no *
                    }//if "Id"
                         
                    else if (fieldName.equals("address-0")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-0").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-0"));
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-0").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-0"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-0"
                  
                    else if (fieldName.equals("address-1")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-1").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-1") );
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-1").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-1"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-1"
                        
                    else if (fieldName.equals("address-2")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-2").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-2"));
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-2").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-2"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-2"
                        
                    else if (fieldName.equals("address-3")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-3").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-3"));
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-3").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-3"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-3"
                        
                    else if (fieldName.equals("address-4")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-4").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-4"));
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-4").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-4"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-4"
                         
                    else if (fieldName.equals("city")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getCity().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getCity());
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getCity().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getCity());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "city"
                        
                    else if (fieldName.equals("state")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getState().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getState());
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getState().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getState());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "state"
                        
                    else if (fieldName.equals("country")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getCountry().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getCountry());
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getCountry().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getCountry());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "country"
                        
                    else if (fieldName.equals("zip")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getZip().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getZip());
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getZip().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getZip());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "zip"
                         
                    else{
                        throw new Exception("Field not supported.");
                    }//else
                }//else if not null
            }//for each element in the ArtistData
            return list;
                 
        case ObjectType.BIDDER:
            for (int i = 0; i < BidderLength; ++i) {
                     
                if (BidderData[i] == null){
                }//if null
                     
                else {
                    DatabaseEntry tmp = BidderData[i];
                    Bidder Biddertmp = (Bidder)tmp;
                    Person Persontmp = (Person)tmp;
                    Address Address = Persontmp.getAddress();

                    if (fieldName.equals("name")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getName());
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getName());
                            }//if match
                        }//else if the pattern has no *
                    }//if "name"
                         
                    else if (fieldName.equals("firstname")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getFirstName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getFirstName());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getFirstName());
                            }//if match
                        }//else if the pattern has no *
                    }//if "firstname"
                         
                    else if (fieldName.equals("lastname")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getLastName().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getLastName());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getName().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getFirstName());
                            }//if match
                        }//else if the pattern has no *
                    }//if "lastname"

                    else if (fieldName.equals("title")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getTitle().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getTitle());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getTitle().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getTitle());
                            }//if match
                        }//else if the pattern has no *
                    }//if "title"
                        
                    else if (fieldName.equals("suffix")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getSuffix().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getSuffix());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getSuffix().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getSuffix());
                            }//if match
                        }//else if the pattern has no *
                    }//if "suffix"
                        
                    else if (fieldName.equals("phone")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getPhone().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getPhone());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getPhone().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getPhone());
                            }//if match
                        }//else if the pattern has no *
                    }//if "phone"

                    else if (fieldName.equals("fax")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getFax().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getFax());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getFax().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getFax());
                            }//if match
                        }//else if the pattern has no *
                    }//if "fax"
                        
                    else if (fieldName.equals("email")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getEmail().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getEmail());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getEmail().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getEmail());
                            }//if match
                        }//else if the pattern has no *
                    }//if "email"
                        
                    else if (fieldName.equals("local")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getLocal().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getLocal());
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getLocal().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),Persontmp.getLocal());
                            }//if match
                        }//else if the pattern has no *
                    }//if "local"
                         
                    else if (fieldName.equals("id")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (tmp.getId().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getId());
                            }//if match
                        }//if * pattern
                        else {
                            if (tmp.getId().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getId());
                            }//if match
                        }//else if the pattern has no *
                    }//if "id"
                         
                    else if (fieldName.equals("payment")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Biddertmp.getPaymentMethod().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Biddertmp.getPaymentMethod());
                            }//if match
                        }//if * pattern
                        else {
                            if (Biddertmp.getPaymentMethod().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Biddertmp.getPaymentMethod());
                            }//if match
                        }//else if the pattern has no *
                    }//if "payment"
                         
                    else if (fieldName.equals("hotelroom")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Biddertmp.getHotelRoom().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Biddertmp.getHotelRoom());
                            }//if match
                        }//if * pattern
                        else {
                            if (Biddertmp.getHotelRoom().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Biddertmp.getHotelRoom());
                            }//if match
                        }//else if the pattern has no *
                    }//if "hotelroom"

                    else if (fieldName.equals("localphone")) {
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Biddertmp.getLocalPhone().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Biddertmp.getLocalPhone());
                            }//if match
                        }//if * pattern
                        else {
                            if (Biddertmp.getLocalPhone().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Biddertmp.getLocalPhone());
                            }//if match
                        }//else if the pattern has no *
                    }//if "localphone"

                    else if (fieldName.equals("address-0")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-0").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-0"));
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-0").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-0"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-0"
                  
                    else if (fieldName.equals("address-1")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-1").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-1") );
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-1").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-1"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-1"
                        
                    else if (fieldName.equals("address-2")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-2").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-2"));
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-2").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-2"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-2"
                        
                    else if (fieldName.equals("address-3")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-3").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-3"));
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-3").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-3"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-3"
                        
                    else if (fieldName.equals("address-4")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Persontmp.getField("address-4").startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-4"));
                            }//if match
                        }//if * pattern
                        else {
                            if (Persontmp.getField("address-4").equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Persontmp.getField("address-4"));
                            }//if match
                        }//else if the pattern has no *
                    }//if "address-4"

                    else if (fieldName.equals("city")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getCity().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Address.getCity());
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getCity().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         Address.getCity());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "city"
                        
                    else if (fieldName.equals("state")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getState().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getState());
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getState().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getState());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "state"
                        
                    else if (fieldName.equals("country")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getCountry().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getCountry());
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getCountry().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getCountry());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "country"
                        
                    else if (fieldName.equals("zip")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            if (Address.getZip().startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getZip());
                            }//if match
                        }//if * pattern
                        else {
                            if (Address.getZip().equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                         Address.getZip());
                            }//if match
                        }//else if the pattern has no *    
                    }//if "zip"
                         
                    else if (fieldName.equals("credit")){
                        if (pattern.endsWith("*")){
                            String first = pattern.substring(0,1);
                            int intNum = Biddertmp.getCredit();
                            Integer IntNum = new Integer(intNum);
                            String stringNum = IntNum.toString();
                            if (stringNum.startsWith(first)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         ""+Biddertmp.getCredit());
                            }//if match
                        }//if * pattern
                        else {
                            int intNum = Biddertmp.getCredit();
                            Integer IntNum = new Integer(intNum);
                            String stringNum = IntNum.toString();
                            if (stringNum.equals(pattern)){
                                list.add(tmp.getName(), tmp.getId(), tmp.getKey(),
                                         ""+Biddertmp.getCredit());
                            }//if match
                        }//else if the pattern has no *
                    }//if "credit"
                         
                    else{
                        throw new Exception("Field not supported");
                    }//else
                }//else if not null
            }//for each element in the BidderData
            return list;
    
        default:
            return new EntryList();    
                
        }//switch
    }//listByField(int objectType,String fieldName,String pattern,String displayField)



    /** Method EntryList listAll(int objectType, String fieldName);
     *  Pre: The database is initialized.
     *  Post: Returns an array-based list of triplets for every object in the 
     *        array. The length of the list will be zero, if there are no
     *        object stored in the array as indicated by type.
     *  Note: no works as a displayField for the Artist object
     */    
    public EntryList listAll(int objectType, String fieldName)
        throws Exception{

        EntryList list = new EntryList();
        fieldName = fieldName.toLowerCase();

        switch(objectType){
            
        case ObjectType.ART:                        
            for (int i = 0; i < ArtLength; ++i) {
                
                if (ArtData[i] == null){
                }//if null
                
                else {
                    DatabaseEntry tmp = ArtData[i];
                    Art Arttmp = (Art)tmp;
                    
                    if (fieldName.equals("name")) {
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getName());
                    }//if "name"
                        
                    else if(fieldName.equals("firstname")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getFname());
                    }//else if "firstname"
                        
                    else if(fieldName.equals("lastname")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getLname());
                    }//else if "lastname"

                    else if(fieldName.equals("id")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getId());
                    }//else if "id"
                        
                    else if(fieldName.equals("artist")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getArtkey());
                    }//else if "artist"

                    else if(fieldName.equals("genre")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getGenre());
                    }//else if "genre"
                        
                    else if(fieldName.equals("title")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getTitle());
                    }//else if "title"
                        
                    else if(fieldName.equals("medium")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getMed());
                    }//else if "medium"

                    else if(fieldName.equals("size")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getSize());
                    }//else if "size"

                    else if(fieldName.equals("minbid")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getMin());
                    }//else if "minbid"

                    else if(fieldName.equals("current")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getCurrent());
                    }//else if "currentbid"

                    else if(fieldName.equals("bidrec")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getBidrec());
                    }//else if "numbids"

                    else if(fieldName.equals("numbidders")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getNumbidders());
                    }//else if "numbidders"

                    else if(fieldName.equals("auctionable")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), ""+Arttmp.getAuctionable());
                    }//else if "auctionable"
                        
                    else if(fieldName.equals("location")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Arttmp.getLocation());
                    }//else if "location"

                    else{
                        throw new Exception("Field not supported");
                    }//else
                }//else
            }//for
            return list;
            
        case ObjectType.ARTIST:
            for (int i = 0; i < ArtistLength; ++i) {
                    
                if (ArtistData[i] == null){
                }//if null
                    
                else {
                    DatabaseEntry tmp = ArtistData[i];
                    Artist Artisttmp = (Artist)tmp;
                    Person Persontmp = (Person)tmp;
                    Address Address = Persontmp.getAddress();
                    
                    if (fieldName.equals("name")) {
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getName());
                    }//if "name"

                    else if(fieldName.equals("id")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getId());
                    }//else if "id"
                        
                    else if(fieldName.equals("firstname")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getFirstName());
                    }//else if "firstname"
                        
                    else if(fieldName.equals("lastname")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getLastName());
                    }//else if "lastname"

                    else if(fieldName.equals("suffix")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getSuffix());
                    }//else if "suffix"

                    else if(fieldName.equals("title")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getTitle());
                    }//else if "title"

                    else if(fieldName.equals("phone")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getPhone());
                    }//else if "phone"

                    else if(fieldName.equals("fax")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getFax());
                    }//else if "fax"

                    else if(fieldName.equals("email")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getEmail());
                    }//else if "email"

                    else if(fieldName.equals("local")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getLocal());
                    }//else if "local"
                        
                    else if(fieldName.equals("address-0")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-0"));
                    }//else if "address-0"
                        
                    else if(fieldName.equals("address-1")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-1"));
                    }//else if "address-1"
                        
                    else if(fieldName.equals("address-2")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-2"));
                    }//else if "address-2"
                        
                    else if(fieldName.equals("address-3")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-3"));
                    }//else if "address-3"
                        
                    else if(fieldName.equals("address-4")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-4"));
                    }//else if "address-4"

                    else if(fieldName.equals("city")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Address.getCity());
                    }//else if "city"
                        
                    else if(fieldName.equals("state")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Address.getState());
                    }//else if "state"
                        
                    else if(fieldName.equals("country")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Address.getCountry());
                    }//else if "country"
                        
                    else if(fieldName.equals("zip")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Address.getZip());
                    }//else if "zip"
                        
                    else {
                        throw new Exception("Field not supported.");
                    }//else
                }//else
            }//for
            return list;
            
        case ObjectType.BIDDER:
            for (int i = 0; i < BidderLength; ++i) {
                    
                if (BidderData[i] == null){
                }//if null
                    
                else {
                    DatabaseEntry tmp = BidderData[i];
                    Bidder Biddertmp = (Bidder)tmp;
                    Person Persontmp = (Person)tmp;
                    Address Address = Persontmp.getAddress();

                    if (fieldName.equals("name")) {
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getName());
                    }//if "name"
                        
                    else if(fieldName.equals("firstname")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getFirstName());
                    }//else if "firstname"
                        
                    else if(fieldName.equals("lastname")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getLastName());
                    }//else if "lastname"

                    else if(fieldName.equals("suffix")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getSuffix());
                    }//else if "suffix"

                    else if(fieldName.equals("title")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getTitle());
                    }//else if "title"

                    else if(fieldName.equals("phone")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getPhone());
                    }//else if "phone"

                    else if(fieldName.equals("fax")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getFax());
                    }//else if "fax"

                    else if(fieldName.equals("email")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getEmail());
                    }//else if "email"

                    else if(fieldName.equals("local")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Persontmp.getLocal());
                    }//else if "local"
                        
                    else if(fieldName.equals("id")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), tmp.getId());
                    }//else if "id"
                        
                    else if(fieldName.equals("address-0")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-0"));
                    }//else if "address-0"
                        
                    else if(fieldName.equals("address-1")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-1"));
                    }//else if "address-1"
                        
                    else if(fieldName.equals("address-2")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-2"));
                    }//else if "address-2"
                        
                    else if(fieldName.equals("address-3")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-3"));
                    }//else if "address-3"
                        
                    else if(fieldName.equals("address-4")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), 
                                 Persontmp.getField("address-4"));
                    }//else if "address-4"

                    else if(fieldName.equals("city")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Address.getCity());
                    }//else if "city"
                        
                    else if(fieldName.equals("state")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Address.getState());
                    }//else if "state"
                        
                    else if(fieldName.equals("country")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Address.getCountry());
                    }//else if "country"
                        
                    else if(fieldName.equals("zip")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), Address.getZip());
                    }//else if "zip"
                        
                    else if(fieldName.equals("credit")){
                        list.add(tmp.getName(), tmp.getId(), tmp.getKey(), ""+Biddertmp.getCredit());
                    }//else if "credit"
                        
                    else {
                        throw new Exception("Field not supported.");
                    }//else
                        
                }//else
            }//for
            return list;
                
        default:
            return new EntryList();
        }//switch
    }//listAll(int objectType, String fieldName)

    /** Method String add (int objectType, DatabaseEntry newObject)
     *  Pre: The database is initialized.
     *  Pre: The newObject is complete except for lacking a Database Key.
     *  Post: Adds the new object to the database.
     *  Post: Returns the key as confirmation of success.
     *  Post: Returns empty string to denote key collision, or other failure.
     */    
    public String add(int objectType, DatabaseEntry newObject)
        
        throws Exception{
        Integer key = new Integer(0);
        
        try{
            switch(objectType){
            
            case ObjectType.ART:                        
                key = new Integer(ArtLength + 10000);
                newObject.setKey(key.toString());
                ArtData[ArtLength] = (Art) newObject;
                ++ArtLength;
                return key.toString();
            
            case ObjectType.ARTIST:            
                key = new Integer(ArtistLength + 20000);
                newObject.setKey(key.toString());
                ArtistData[ArtistLength] = (Artist) newObject;
                ++ArtistLength;
                return key.toString();
            
            case ObjectType.BIDDER:
                key = new Integer(BidderLength + 30000);
                newObject.setKey(key.toString());
                BidderData[BidderLength] = (Bidder) newObject;
                ++BidderLength;
                return key.toString();
            
            default:
                return "";
            }//switch
            
        }//try
        
        catch(Exception e) {
            throw new Exception("Cannot add new entry, try differently.");
        }//catch
        
    }//add(int objectType, DatabaseEntry newObject)
    
}//class Database



