1 7 8 package com.sun.corba.se.impl.naming.cosnaming; 9 10 import org.omg.CosNaming.NameComponent ; 11 12 19 public class InternalBindingKey 20 { 21 public NameComponent name; 23 private int idLen; 24 private int kindLen; 25 private int hashVal; 26 27 public InternalBindingKey() {} 29 30 public InternalBindingKey(NameComponent n) 32 { 33 idLen = 0; 34 kindLen = 0; 35 setup(n); 36 } 37 38 protected void setup(NameComponent n) { 40 this.name = n; 41 if( this.name.id != null ) { 43 idLen = this.name.id.length(); 44 } 45 if( this.name.kind != null ) { 46 kindLen = this.name.kind.length(); 47 } 48 hashVal = 0; 49 if (idLen > 0) 50 hashVal += this.name.id.hashCode(); 51 if (kindLen > 0) 52 hashVal += this.name.kind.hashCode(); 53 } 54 55 public boolean equals(java.lang.Object o) { 57 if (o == null) 58 return false; 59 if (o instanceof InternalBindingKey) { 60 InternalBindingKey that = (InternalBindingKey)o; 61 if (this.idLen != that.idLen || this.kindLen != that.kindLen) { 63 return false; 64 } 65 if (this.idLen > 0 && this.name.id.equals(that.name.id) == false) { 67 return false; 68 } 69 if (this.kindLen > 0 && this.name.kind.equals(that.name.kind) == false) { 71 return false; 72 } 73 return true; 75 } else { 76 return false; 77 } 78 } 79 public int hashCode() { 81 return this.hashVal; 82 } 83 } 84 85 | Popular Tags |