1. /*
  2. * @(#)ObjectIdImpl.java 1.13 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.impl.ior;
  8. import java.util.Arrays ;
  9. import com.sun.corba.se.spi.ior.ObjectId ;
  10. import org.omg.CORBA_2_3.portable.OutputStream ;
  11. /**
  12. * @author
  13. */
  14. public final class ObjectIdImpl implements ObjectId
  15. {
  16. private byte[] id;
  17. public boolean equals( Object obj )
  18. {
  19. if (!(obj instanceof ObjectIdImpl))
  20. return false ;
  21. ObjectIdImpl other = (ObjectIdImpl)obj ;
  22. return Arrays.equals( this.id, other.id ) ;
  23. }
  24. public int hashCode()
  25. {
  26. int result = 17 ;
  27. for (int ctr=0; ctr<id.length; ctr++)
  28. result = 37*result + id[ctr] ;
  29. return result ;
  30. }
  31. public ObjectIdImpl( byte[] id )
  32. {
  33. this.id = id ;
  34. }
  35. public byte[] getId()
  36. {
  37. return id ;
  38. }
  39. public void write( OutputStream os )
  40. {
  41. os.write_long( id.length ) ;
  42. os.write_octet_array( id, 0, id.length ) ;
  43. }
  44. }