/*****************************************************************************/
/* File name: ProgramHashtable.java                                          */
/* Purpose: to keep VersionHashtable objects according                       */
/*          to the programNumber key of their mappings                       */
/*                                                                           */
/* Last modified: 04.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*                                                                           */
/* This program is distributed in the hope that it will be useful, but       */
/* WITHOUT ANY WARRANTY; without even the implied warranty of                */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General */
/* Public License for more details.                                          */
/*                                                                           */
/* This software is distributed under the terms                              */
/* of the GNU General Public License as published                            */
/* by the Free Software Foundation; either version 2, or (at your option)    */
/* any later version.                                                        */
/* See file COPYING for your rights (GNU GPL)                                */
/*****************************************************************************/


package pm;


import java.util.*;


public
class

ProgramHashtable
                  extends Hashtable
{

  private final static String RCSID = "$Header: /d/NFS/pm/RCS/ProgramHashtable.java,v 1.1 1999/06/05 16:00:21 vklimov Exp $";


  public

  ProgramHashtable()
/*****************************************************************************/
/* Function name: ProgramHashtable                                           */
/* File name: ProgramHashtable.java                                          */
/* Purpose: constructor for the ProgramHashtable class                       */
/* Parameters:                                                               */
/* Returns:                                                                  */
/* Last modified: 04.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
                                                    /* ProgramHashtable */
/*---------------------------------------------------------------------------*/

    }
/*end of ProgramHashtable*/


  public
  int

  hashCode()
/*****************************************************************************/
/* Function name: hashCode                                                   */
/* File name: ProgramHashtable.java                                          */
/* Purpose: to return hash code (based on programNumber of mapping contained */
/*          in ProtocolHashtable in VersionHashtable object)                 */
/* Parameters:                                                               */
/* Returns: the hash code                                                    */
/* Last modified: 04.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      int result;
      Long l;
      Enumeration elements;
      Enumeration elementsProtocolHashtable;
      VersionHashtable versionHashtable;
      ProtocolHashtable protocolHashtable;
      Mapping mapping;
                                                           /* hashCode */
/*---------------------------------------------------------------------------*/

      if (isEmpty())
        return Constants.HASHCODE_FOR_EMPTY;                /* return ! */
      else
        ;
    /*end of if*/

      elements = elements();

      versionHashtable = (VersionHashtable) elements.nextElement();
      elements = versionHashtable.elements();
      protocolHashtable = (ProtocolHashtable) elements.nextElement();
      elementsProtocolHashtable = protocolHashtable.elements();

      mapping = (Mapping) elementsProtocolHashtable.nextElement();

      l = new Long( mapping.programNumber );
      result = l.hashCode();

      return result;

    }
/*end of hashCode*/


  public
  boolean

  equals( ProgramHashtable programHashtable )
/*****************************************************************************/
/* Function name: equals                                                     */
/* File name: ProgramHashtable.java                                          */
/* Purpose: to check whether this hashtable is equal to the argument         */
/*          the hashtables are equal if they contain VersionHashtable        */
/*          objects, that have ProtocolHashtable objects that contain        */
/*          mappings with the same programNumber                             */
/* Parameters: programHashtable                                              */
/* Returns: true - if the hashtables are equal, false - otherwise            */
/* Last modified: 04.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      int result;
      Long l;
      Enumeration elements;
      Enumeration elementsArgument;
      VersionHashtable versionHashtable;
      VersionHashtable versionHashtableArgument;
      ProtocolHashtable protocolHashtable;
      ProtocolHashtable protocolHashtableArgument;
      Mapping mapping;
      Mapping mappingArgument;
                                                           /* equals */
/*---------------------------------------------------------------------------*/

      if (isEmpty() &&
          programHashtable.isEmpty() )
        return true;                                   /* return ! */
      else
        ;
    /*end of if*/

      elements = elements();
      elementsArgument = programHashtable.elements();

      versionHashtable = (VersionHashtable)
        elements.nextElement();
      versionHashtableArgument = (VersionHashtable)
        elementsArgument.nextElement();

      elements = versionHashtable.elements();
      elementsArgument = versionHashtableArgument.elements();

      protocolHashtable = (ProtocolHashtable)
        elements.nextElement();
      protocolHashtableArgument = (ProtocolHashtable)
        elementsArgument.nextElement();

      elements = protocolHashtable.elements();
      elementsArgument = protocolHashtableArgument.elements();

      mapping = (Mapping) elements.nextElement();
      mappingArgument = (Mapping) elementsArgument.nextElement();

      if (mapping.programNumber ==
          mappingArgument.programNumber)
        return true;
      else
        return false;
    /*end of if*/

    }
/*end of equals*/


} /* end of ProgramHashtable class */

/*****************************************************************************/
/* End of file: ProgramHashtable.java                                        */
/*****************************************************************************/
