/*****************************************************************************/
/* File name: HostNameHashtable.java                                         */
/* Purpose: to keep Entry objects according to the hostName key              */
/*                                                                           */
/* Last modified: 23.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 mount;


import java.util.*;


public
class

HostNameHashtable
                  extends Hashtable
{

  private final static String RCSID = "$Header: /d/NFS/mount/RCS/HostNameHashtable.java,v 1.2 1999/06/23 17:37:09 vklimov Exp $";


  public

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

    }
/*end of HostNameHashtable*/


  public
  int

  hashCode()
/*****************************************************************************/
/* Function name: hashCode                                                   */
/* File name: HostNameHashtable.java                                         */
/* Purpose: to return hash code (based on hostName)                          */
/* Parameters:                                                               */
/* Returns: the hash code                                                    */
/* Last modified: 14.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      int result;
      Enumeration elements;
      Entry mountEntry;
                                                           /* hashCode */
/*---------------------------------------------------------------------------*/

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

      elements = elements();

      mountEntry = (Entry) elements.nextElement();

      result = mountEntry.hashCode();

      return result;

    }
/*end of hashCode*/


  public
  boolean

  equals( HostNameHashtable hostNameHashtable )
/*****************************************************************************/
/* Function name: equals                                                     */
/* File name: HostNameHashtable.java                                         */
/* Purpose: to check whether this hashtable is equal to the argument         */
/*          the hashtables are equal if they contain mount Entry objects     */
/*          with the same hostName                                           */
/* Parameters: hostNameHashtable                                             */
/* Returns: true - if the hashtables are equal, false - otherwise            */
/* Last modified: 23.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      int result;
      Enumeration elements;
      Enumeration elementsArgument;
      Entry mountEntry;
      Entry mountEntryArgument;
                                                                /* equals */
/*---------------------------------------------------------------------------*/

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

      elements = elements();
      elementsArgument = hostNameHashtable.elements();

      mountEntry = (Entry) elements.nextElement();
      mountEntryArgument = (Entry) elementsArgument.nextElement();

      if ( mountEntry.getHostName().equals(
           mountEntryArgument.getHostName() )
         )
        return true;
      else
        return false;
    /*end of if*/

    }
/*end of equals*/


} /* end of HostNameHashtable class */

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