1. /*
  2. * @(#)GenericIdEncapsulation.java 1.16 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. //Source file: J:/ws/serveractivation/src/share/classes/com.sun.corba.se.internal.ior/GenericIdEncapsulation.java
  8. package com.sun.corba.se.internal.ior;
  9. import java.util.Arrays ;
  10. import org.omg.CORBA.ORB;
  11. import org.omg.CORBA_2_3.portable.InputStream;
  12. import org.omg.CORBA_2_3.portable.OutputStream;
  13. /**
  14. * @author
  15. * This is used for unknown components and profiles. A TAG_MULTICOMPONENT_PROFILE will be represented this way.
  16. */
  17. public abstract class GenericIdEncapsulation implements IdEncapsulation
  18. {
  19. private int id;
  20. private byte data[];
  21. /**
  22. * @param arg0
  23. * @param arg1
  24. * @return
  25. * @exception
  26. * @author
  27. * @roseuid 3910984C00C0
  28. */
  29. public GenericIdEncapsulation(int id, InputStream is)
  30. {
  31. this.id = id ;
  32. data = IdEncapsulationBase.readOctets( is ) ;
  33. }
  34. /**
  35. * @return int
  36. * @exception
  37. * @author
  38. * @roseuid 3910984C00C5
  39. */
  40. public int getId()
  41. {
  42. return id ;
  43. }
  44. /**
  45. * @param arg0
  46. * @return void
  47. * @exception
  48. * @author
  49. * @roseuid 3910984C00C6
  50. */
  51. public void write(OutputStream os)
  52. {
  53. os.write_ulong( data.length ) ;
  54. os.write_octet_array( data, 0, data.length ) ;
  55. }
  56. /**
  57. * @return String
  58. * @exception
  59. * @author
  60. * @roseuid 3980750400B1
  61. */
  62. public String toString()
  63. {
  64. return "GenericIdEncapsulation[id=" + getId() + "]" ;
  65. }
  66. /**
  67. * @param obj
  68. * @return boolean
  69. * @exception
  70. * @author
  71. * @roseuid 3980750400BB
  72. */
  73. public boolean equals(Object obj)
  74. {
  75. if (obj == null)
  76. return false ;
  77. if (!(obj instanceof GenericIdEncapsulation))
  78. return false ;
  79. GenericIdEncapsulation encaps = (GenericIdEncapsulation)obj ;
  80. return (getId() == encaps.getId()) &&
  81. Arrays.equals( getData(), encaps.getData() ) ;
  82. }
  83. /**
  84. * @param id
  85. * @param data
  86. * @return
  87. * @exception
  88. * @author
  89. * @roseuid 3980750400CF
  90. */
  91. public GenericIdEncapsulation(int id, byte[] data)
  92. {
  93. this.id = id ;
  94. this.data = (byte[])(data.clone()) ;
  95. }
  96. /**
  97. * @return byte[]
  98. * @exception
  99. * @author
  100. * @roseuid 39807504011F
  101. */
  102. public byte[] getData()
  103. {
  104. return data ;
  105. }
  106. }