/*****************************************************************************/
/* File name: Mapping.java                                                   */
/* Purpose: to keep mapping tuple data: program, version, protocol, port     */
/*                                                                           */
/* Last modified: 06.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.net.*;
import java.io.*;
import rpc.*;


public
class

Mapping
{

  private final static String RCSID = "$Header: /d/NFS/pm/RCS/Mapping.java,v 1.3 1999/06/07 18:37:24 vklimov Exp $";

  protected long programNumber = 0;
  protected long versionNumber = 0;
  protected long protocolNumber = 0;
  protected long portNumber = 0;


  public

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

    }
/*end of Mapping*/


  public

  Mapping( long programNumber,
           long versionNumber,
           long protocolNumber,
           long portNumber      )
/*****************************************************************************/
/* Function name: Mapping                                                    */
/* File name: Mapping.java                                                   */
/* Purpose: constructor for the Mapping class                                */
/* Parameters:                                                               */
/* Returns:                                                                  */
/* Last modified: 06.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
                                                       /* Mapping */
/*---------------------------------------------------------------------------*/

      this.programNumber  = programNumber;
      this.versionNumber  = versionNumber;
      this.protocolNumber = protocolNumber;
      this.portNumber     = portNumber;

    }
/*end of Mapping*/


  public

  Mapping( rpc.Message rpcMessage )
/*****************************************************************************/
/* Function name: Mapping                                                    */
/* File name: Mapping.java                                                   */
/* Purpose: constructor for the Mapping class                                */
/* Parameters: rpcMessage                                                    */
/* Returns:                                                                  */
/* Last modified: 02.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
                                                       /* Mapping */
/*---------------------------------------------------------------------------*/
      programNumber =
        rpcMessage.
          getUnsignedInteger();
      versionNumber =
        rpcMessage.
          getUnsignedInteger();
      protocolNumber =
        rpcMessage.
          getUnsignedInteger();
      portNumber =
        rpcMessage.
          getUnsignedInteger();

    }
/*end of Mapping*/


  public
  String

  toString()
/*****************************************************************************/
/* Function name: toString                                                   */
/* File name: Mapping.java                                                   */
/* Purpose: to represent this Mapping object as a string                     */
/* Parameters:                                                               */
/* Returns: the string representation of the object                          */
/* Last modified: 02.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      String result;
                                                       /* toString */
/*---------------------------------------------------------------------------*/

      result =
        "programNumber=" + programNumber +
        " versionNumber=" + versionNumber +
        "\nprotocolNumber=" + protocolNumber +
        " portNumber=" + portNumber;

      return result;

    }
/*end of toString*/


  public
  int

  hashCode()
/*****************************************************************************/
/* Function name: hashCode                                                   */
/* File name: Mapping.java                                                   */
/* Purpose: to return hash code (based on protocolNumber)                    */
/*          for this mapping object                                          */
/* Parameters:                                                               */
/* Returns: the hash code                                                    */
/* Last modified: 04.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      int result;
      Long l;
                                                       /* hashCode */
/*---------------------------------------------------------------------------*/

      l = new Long( protocolNumber );
      result = l.hashCode();

      return result;

    }
/*end of hashCode*/


  public
  boolean

  equals( Mapping mapping )
/*****************************************************************************/
/* Function name: equals                                                     */
/* File name: Mapping.java                                                   */
/* Purpose: to check whether this mapping object is equal to the argument    */
/* Parameters: mapping                                                       */
/* Returns: true - if the object are equal, false - otherwise                */
/* Last modified: 04.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
                                                       /* equals */
/*---------------------------------------------------------------------------*/

      if ( (mapping.programNumber == programNumber) &&
           (mapping.versionNumber == versionNumber) &&
           (mapping.protocolNumber == protocolNumber) &&
           (mapping.portNumber == portNumber)
         )
        return true;
      else
        return false;
    /*end of if */

    }
/*end of equals*/


} /* end of Mapping class */

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