1. /*
  2. * @(#)EndPointImpl.java 1.26 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.internal.iiop;
  8. import com.sun.corba.se.connection.EndPointInfo;
  9. import com.sun.corba.se.internal.core.EndPoint;
  10. public class EndPointImpl
  11. implements
  12. EndPoint,
  13. EndPointInfo
  14. {
  15. public EndPointImpl(String type, int port, String hostname) {
  16. this.type = type;
  17. this.port = port;
  18. this.hostname = hostname;
  19. this.locatorPort = -1;
  20. }
  21. public String getType() {
  22. return type;
  23. }
  24. public int getPort() {
  25. return port;
  26. }
  27. public int getLocatorPort ()
  28. {
  29. return locatorPort;
  30. }
  31. public void setLocatorPort (int port)
  32. {
  33. locatorPort = port;
  34. }
  35. public String getHostName() {
  36. return hostname;
  37. }
  38. public String getHost() {
  39. return hostname;
  40. }
  41. public int hashCode() {
  42. return type.hashCode() ^ hostname.hashCode() ^ port;
  43. }
  44. public boolean equals(Object obj) {
  45. if (!(obj instanceof EndPointImpl)) {
  46. return false;
  47. }
  48. EndPointImpl other = (EndPointImpl)obj;
  49. if (type == null) {
  50. if (other.type != null) {
  51. return false;
  52. }
  53. } else if (!type.equals(other.type)) {
  54. return false;
  55. }
  56. if (port != other.port) {
  57. return false;
  58. }
  59. if (!hostname.equals(other.hostname)) {
  60. return false;
  61. }
  62. return true;
  63. }
  64. public String toString ()
  65. {
  66. return
  67. hostname + " " +
  68. port + " " +
  69. type;
  70. }
  71. private String type;
  72. private int port;
  73. private int locatorPort;
  74. private String hostname;
  75. }