1. /*
  2. * @(#)IIOPProfileTemplate.java 1.18 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/IIOPProfileTemplate.java
  8. package com.sun.corba.se.internal.ior;
  9. import java.util.LinkedList ;
  10. import org.omg.IOP.TAG_INTERNET_IOP ;
  11. import org.omg.CORBA_2_3.portable.OutputStream ;
  12. import com.sun.corba.se.internal.ior.TaggedProfileTemplate ;
  13. import com.sun.corba.se.internal.ior.ObjectKeyTemplate ;
  14. import com.sun.corba.se.internal.ior.IIOPAddress ;
  15. import com.sun.corba.se.internal.ior.ObjectId ;
  16. import com.sun.corba.se.internal.ior.IdEncapsulationBase ;
  17. import com.sun.corba.se.internal.corba.EncapsOutputStream ;
  18. import com.sun.corba.se.internal.iiop.CDROutputStream ;
  19. import com.sun.corba.se.internal.core.GIOPVersion ;
  20. /**
  21. * @author
  22. * If getMinorVersion==0, this does not contain any tagged components
  23. */
  24. public class IIOPProfileTemplate extends IdEncapsulationContainerBase
  25. implements TaggedProfileTemplate
  26. {
  27. private byte major;
  28. private byte minor;
  29. private IIOPAddress primary ;
  30. private ObjectKeyTemplate okeyTemplate;
  31. public boolean equals( Object obj )
  32. {
  33. if (obj == null)
  34. return false ;
  35. if (!(obj instanceof IIOPProfileTemplate))
  36. return false ;
  37. IIOPProfileTemplate other = (IIOPProfileTemplate)obj ;
  38. return super.equals( obj ) &&
  39. (major == other.major) && (minor == other.minor) &&
  40. primary.equals( other.primary ) &&
  41. okeyTemplate.equals( other.okeyTemplate ) ;
  42. }
  43. public TaggedProfile create( ObjectId id )
  44. {
  45. return new IIOPProfile( id, this ) ;
  46. }
  47. public byte getMajorVersion()
  48. {
  49. return major ;
  50. }
  51. public byte getMinorVersion()
  52. {
  53. return minor ;
  54. }
  55. public IIOPAddress getPrimaryAddress()
  56. {
  57. return primary ;
  58. }
  59. public ObjectKeyTemplate getObjectKeyTemplate()
  60. {
  61. return okeyTemplate ;
  62. }
  63. public IIOPProfileTemplate( byte major, byte minor,
  64. IIOPAddress primary, ObjectKeyTemplate template )
  65. {
  66. this.major = major ;
  67. this.minor = minor ;
  68. this.primary = primary ;
  69. this.okeyTemplate = template ;
  70. if (minor == 0)
  71. makeImmutable() ;
  72. }
  73. /**
  74. * @param location
  75. * @param id
  76. * @param os
  77. * @return void
  78. * @exception
  79. * @author
  80. * @roseuid 3911D7170126
  81. */
  82. public void write( ObjectId id, OutputStream os)
  83. {
  84. os.write_octet( major ) ;
  85. os.write_octet( minor ) ;
  86. primary.write( os ) ;
  87. // Note that this is NOT an encapsulation: do not marshal
  88. // the endianness flag. However, the length is required.
  89. // Note that this cannot be accomplished with a codec!
  90. // Use the byte order of the given stream
  91. OutputStream kos
  92. = new EncapsOutputStream( os.orb(),
  93. ((CDROutputStream)os).isLittleEndian() ) ;
  94. okeyTemplate.write( id, kos ) ;
  95. IdEncapsulationBase.writeOutputStream(
  96. (CDROutputStream)kos, os ) ;
  97. if (minor > 0)
  98. writeIdEncapsulationSequence( os ) ;
  99. }
  100. /**
  101. * @return int
  102. * @exception
  103. * @author
  104. * @roseuid 39132884035F
  105. */
  106. public int getId()
  107. {
  108. return TAG_INTERNET_IOP.value ;
  109. }
  110. public boolean isEquivalent( IIOPProfileTemplate temp )
  111. {
  112. return primary.equals( temp.primary ) &&
  113. okeyTemplate.equals( temp.okeyTemplate ) ;
  114. }
  115. }