1 7 8 package com.sun.corba.se.impl.ior.iiop ; 9 10 import org.omg.CORBA.BAD_PARAM ; 11 12 import org.omg.CORBA_2_3.portable.InputStream ; 13 import org.omg.CORBA_2_3.portable.OutputStream ; 14 15 import com.sun.corba.se.spi.ior.iiop.IIOPAddress ; 16 17 20 abstract class IIOPAddressBase implements IIOPAddress 21 { 22 protected short intToShort( int value ) 29 { 30 if (value > 32767) 31 return (short)(value - 65536) ; 32 return (short)value ; 33 } 34 35 protected int shortToInt( short value ) 36 { 37 if (value < 0) 38 return value + 65536 ; 39 return value ; 40 } 41 42 public void write( OutputStream os ) 43 { 44 os.write_string( getHost() ) ; 45 int port = getPort() ; 46 os.write_short( intToShort( port ) ) ; 47 } 48 49 public boolean equals( Object obj ) 50 { 51 if (!(obj instanceof IIOPAddress)) 52 return false ; 53 54 IIOPAddress other = (IIOPAddress)obj ; 55 56 return getHost().equals(other.getHost()) && 57 (getPort() == other.getPort()) ; 58 } 59 60 public int hashCode() 61 { 62 return getHost().hashCode() ^ getPort() ; 63 } 64 65 public String toString() 66 { 67 return "IIOPAddress[" + getHost() + "," + getPort() + "]" ; 68 } 69 } 70 | Popular Tags |