1. /*
  2. * @(#)IdentifiableContainerBase.java 1.5 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.TaggedComponent ;
  14. import com.sun.corba.se.internal.ior.Identifiable ;
  15. /**
  16. * @author
  17. */
  18. public class IdentifiableContainerBase extends FreezableList
  19. {
  20. /** This class simply holds some static utility methods.
  21. * @return
  22. * @exception
  23. * @author
  24. * @roseuid 3910984C0305
  25. */
  26. public IdentifiableContainerBase()
  27. {
  28. super( new LinkedList() ) ;
  29. }
  30. /**
  31. * @param id
  32. * @return Iterator
  33. * @exception
  34. * @author
  35. * @roseuid 3911CA0D039D
  36. */
  37. public Iterator iteratorById( final int id)
  38. {
  39. return new Iterator() {
  40. Iterator iter = IdentifiableContainerBase.this.iterator() ;
  41. Object current = advance() ;
  42. private Object advance()
  43. {
  44. while (iter.hasNext()) {
  45. Identifiable ide = (Identifiable)(iter.next()) ;
  46. if (ide.getId() == id)
  47. return ide ;
  48. }
  49. return null ;
  50. }
  51. public boolean hasNext()
  52. {
  53. return current != null ;
  54. }
  55. public Object next()
  56. {
  57. Object result = current ;
  58. current = advance() ;
  59. return result ;
  60. }
  61. public void remove()
  62. {
  63. iter.remove() ;
  64. }
  65. } ;
  66. }
  67. }