1. /*
  2. * @(#)IdEncapsulationContainerBase.java 1.21 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/ContainerBase.java
  8. package com.sun.corba.se.internal.ior;
  9. import java.util.List;
  10. import java.util.LinkedList;
  11. import java.util.Iterator;
  12. import com.sun.corba.se.internal.ior.FreezableList ;
  13. import com.sun.corba.se.internal.ior.IdentifiableContainerBase ;
  14. import com.sun.corba.se.internal.ior.TaggedComponent ;
  15. import com.sun.corba.se.internal.ior.IdEncapsulationFactoryFinder ;
  16. import com.sun.corba.se.internal.ior.IdEncapsulation ;
  17. import org.omg.IOP.TAG_INTERNET_IOP ;
  18. import org.omg.CORBA_2_3.portable.OutputStream ;
  19. import org.omg.CORBA_2_3.portable.InputStream ;
  20. /**
  21. * @author
  22. */
  23. public class IdEncapsulationContainerBase extends IdentifiableContainerBase
  24. {
  25. /** Read the count from is, then read count IdEncapsulations from
  26. * is using the factory. Add each constructed IdEncapsulation to list.
  27. * @param arg0
  28. * @param arg1
  29. * @return void
  30. * @exception
  31. * @author
  32. * @roseuid 3910984C0306
  33. */
  34. public void readIdEncapsulationSequence(
  35. IdEncapsulationFactoryFinder finder, InputStream istr)
  36. {
  37. int count = istr.read_long() ;
  38. for (int ctr = 0; ctr<count; ctr++) {
  39. int id = istr.read_long() ;
  40. IdEncapsulation obj = finder.create( id, istr ) ;
  41. add( obj ) ;
  42. }
  43. }
  44. /** Write all IdEncapsulations that we contain to os. The total
  45. * length must be written before this method is called.
  46. * @param arg0
  47. * @return void
  48. * @exception
  49. * @author
  50. * @roseuid 3910984C030E
  51. */
  52. public void writeIdEncapsulationSequence( OutputStream os)
  53. {
  54. os.write_long( size() ) ;
  55. Iterator iter = iterator() ;
  56. while (iter.hasNext()) {
  57. IdEncapsulation obj = (IdEncapsulation)( iter.next() ) ;
  58. os.write_long( obj.getId() ) ;
  59. obj.write( os ) ;
  60. }
  61. }
  62. }