1 package org.jacorb.naming; 2 3 22 23 28 29 import org.omg.CosNaming.*; 30 31 public class BindingIteratorImpl 32 extends org.omg.CosNaming.BindingIteratorPOA 33 { 34 Binding [] bindings; 35 int iterator_pos = 0; 36 37 public BindingIteratorImpl( Binding [] b ) 38 { 39 bindings = b; 40 if( b.length > 0 ) 41 iterator_pos = 0; 42 } 43 44 public void destroy() 45 { 46 bindings = null; 47 try 48 { 49 finalize(); 50 } catch ( Throwable t ){} 51 } 52 53 public boolean next_n(int how_many, 54 org.omg.CosNaming.BindingListHolder bl) 55 { 56 int diff = bindings.length - iterator_pos; 57 if( diff > 0 ) 58 { 59 Binding [] bndgs = null; 60 if( how_many <= diff ) 61 { 62 bndgs = new Binding[how_many]; 63 System.arraycopy(bindings, iterator_pos, bndgs, 0, how_many); 64 iterator_pos += how_many; 65 } 66 else 67 { 68 bndgs = new Binding[diff]; 69 System.arraycopy(bindings, iterator_pos, bndgs, 0, diff); 70 iterator_pos = bindings.length; 71 } 72 bl.value = bndgs; 73 return true; 74 } 75 else 76 { 77 bl.value = new org.omg.CosNaming.Binding [0]; 78 return false; 79 } 80 } 81 82 public boolean next_one(org.omg.CosNaming.BindingHolder b) 83 { 84 if( iterator_pos < bindings.length ) 85 { 86 b.value = bindings[iterator_pos++]; 87 return true; 88 } 89 else 90 { 91 b.value = new Binding(new org.omg.CosNaming.NameComponent [0], 92 org.omg.CosNaming.BindingType.nobject); 93 return false; 94 } 95 } 96 } 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | Popular Tags |