1. /*
  2. * @(#)ObjectKeyImpl.java 1.17 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 org.omg.CORBA_2_3.portable.OutputStream ;
  9. import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ;
  10. import com.sun.corba.se.spi.orb.ORB ;
  11. import com.sun.corba.se.spi.ior.ObjectId ;
  12. import com.sun.corba.se.spi.ior.ObjectKey ;
  13. import com.sun.corba.se.spi.ior.ObjectKeyTemplate ;
  14. import com.sun.corba.se.impl.encoding.EncapsOutputStream ;
  15. /**
  16. * @author
  17. */
  18. public class ObjectKeyImpl implements ObjectKey
  19. {
  20. private ObjectKeyTemplate oktemp;
  21. private ObjectId id;
  22. public boolean equals( Object obj )
  23. {
  24. if (obj == null)
  25. return false ;
  26. if (!(obj instanceof ObjectKeyImpl))
  27. return false ;
  28. ObjectKeyImpl other = (ObjectKeyImpl)obj ;
  29. return oktemp.equals( other.oktemp ) &&
  30. id.equals( other.id ) ;
  31. }
  32. public int hashCode()
  33. {
  34. return oktemp.hashCode() ^ id.hashCode() ;
  35. }
  36. public ObjectKeyTemplate getTemplate()
  37. {
  38. return oktemp ;
  39. }
  40. public ObjectId getId()
  41. {
  42. return id ;
  43. }
  44. public ObjectKeyImpl( ObjectKeyTemplate oktemp, ObjectId id )
  45. {
  46. this.oktemp = oktemp ;
  47. this.id = id ;
  48. }
  49. public void write( OutputStream os )
  50. {
  51. oktemp.write( id, os ) ;
  52. }
  53. public byte[] getBytes( org.omg.CORBA.ORB orb )
  54. {
  55. EncapsOutputStream os = new EncapsOutputStream( (ORB)orb ) ;
  56. write( os ) ;
  57. return os.toByteArray() ;
  58. }
  59. public CorbaServerRequestDispatcher getServerRequestDispatcher( ORB orb )
  60. {
  61. return oktemp.getServerRequestDispatcher( orb, id ) ;
  62. }
  63. }