1 7 8 package com.sun.corba.se.impl.ior ; 9 10 import java.util.Iterator ; 11 12 import org.omg.CORBA_2_3.portable.OutputStream ; 13 14 import com.sun.corba.se.spi.ior.ObjectAdapterId ; 15 16 abstract class ObjectAdapterIdBase implements ObjectAdapterId { 17 public boolean equals( Object other ) 18 { 19 if (!(other instanceof ObjectAdapterId)) 20 return false ; 21 22 ObjectAdapterId theOther = (ObjectAdapterId)other ; 23 24 Iterator iter1 = iterator() ; 25 Iterator iter2 = theOther.iterator() ; 26 27 while (iter1.hasNext() && iter2.hasNext()) { 28 String str1 = (String )(iter1.next()) ; 29 String str2 = (String )(iter2.next()) ; 30 31 if (!str1.equals( str2 )) 32 return false ; 33 } 34 35 return iter1.hasNext() == iter2.hasNext() ; 36 } 37 38 public int hashCode() 39 { 40 int result = 17 ; 41 Iterator iter = iterator() ; 42 while (iter.hasNext()) { 43 String str = (String )(iter.next()) ; 44 result = 37*result + str.hashCode() ; 45 } 46 return result ; 47 } 48 49 public String toString() 50 { 51 StringBuffer buff = new StringBuffer () ; 52 buff.append( "ObjectAdapterID[" ) ; 53 Iterator iter = iterator() ; 54 boolean first = true ; 55 while (iter.hasNext()) { 56 String str = (String )(iter.next()) ; 57 58 if (first) 59 first = false ; 60 else 61 buff.append( "/" ) ; 62 63 buff.append( str ) ; 64 } 65 66 buff.append( "]" ) ; 67 68 return buff.toString() ; 69 } 70 71 public void write( OutputStream os ) 72 { 73 os.write_long( getNumLevels() ) ; 74 Iterator iter = iterator() ; 75 while (iter.hasNext()) { 76 String str = (String )(iter.next()) ; 77 os.write_string( str ) ; 78 } 79 } 80 } 81 | Popular Tags |