1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class SlotFactory 38 { 39 private java.util.Hashtable _values; private SlotImpl[] _slots; private int _default_length; 43 private int _default_increment; 44 private int _slot_number; 45 46 public 48 SlotFactory() 49 { 50 _values = new java.util.Hashtable (); 51 52 _default_length = 10; 53 _default_increment = 10; 54 _slot_number = 0; 55 _slots = new SlotImpl[_default_length]; 56 } 57 58 public 60 SlotFactory(int dl, int di) 61 { 62 _values = new java.util.Hashtable (); 63 64 _default_length = dl; 65 _default_increment = di; 66 _slot_number = 0; 67 _slots = new SlotImpl[_default_length]; 68 } 69 70 74 private void 75 reallocateSlotTable() 76 { 77 SlotImpl[] ntable = new SlotImpl[_slots.length+_default_increment]; 78 79 System.arraycopy(_slots, 0, ntable, 0, _slots.length); 81 _slots = ntable; 82 } 83 84 private void 85 setSlot(int sid, SlotImpl slot) 86 { 87 if (sid>=_slots.length) { 89 reallocateSlotTable(); 90 } 91 92 _slots[sid] = slot; 93 } 94 95 99 final public int 100 allocateSlotId() 101 { 102 setSlot(_slot_number, null); 104 105 return _slot_number; 107 } 108 109 final public SlotImpl 110 getSlot(int sid) 111 { 112 if (_slots[sid]!=null) { 114 return _slots[sid]; 115 } 116 117 SlotImpl slot = new SlotImpl(_values, sid); 119 _slots[sid] = slot; 120 121 return slot; 122 } 123 } 124 | Popular Tags |