1 26 27 package org.objectweb.openccm.ast.lib; 28 29 51 52 public class ListBaseImpl 53 extends ObjectBase 54 implements org.objectweb.openccm.ast.api.List 55 { 56 62 63 private java.util.List elements_; 64 65 71 74 public 75 ListBaseImpl() 76 { 77 super(); 79 80 elements_ = new java.util.ArrayList (); 82 } 83 84 90 96 101 public Object 102 get(int index) 103 { 104 return elements_.get(index); 105 }; 106 107 112 public void 113 addObject(Object element) 114 { 115 if (element != null) 116 { 117 elements_.add(element); 118 } 119 }; 120 121 128 public Object [] 129 toArray(Object [] emptyArray) 130 { 131 return elements_.toArray(emptyArray); 132 }; 133 134 139 public java.util.List 140 toList() 141 { 142 return elements_; 143 }; 144 145 150 public java.util.Iterator 151 iterator() 152 { 153 return elements_.iterator(); 154 } 155 156 163 public boolean 164 contains(Object obj) 165 { 166 for(int i=0; i<getSize(); i++) 167 { 168 Object obj_i = get(i); 169 if( obj_i == obj ) 170 return true; 171 } 172 return false; 173 } 174 175 181 public int 182 checkSameItem() 183 { 184 for(int i=0; i<getSize(); i++) 185 { 186 Object obj_i = get(i); 187 188 for(int j=i+1; j<getSize(); j++) 189 { 190 Object obj_j = get(j); 191 192 if( obj_i == obj_j ) 193 return i; 194 } 195 } 196 return -1; 197 } 198 199 205 210 public int 211 getSize() 212 { 213 return elements_.size(); 214 }; 215 } 216 | Popular Tags |