1 19 package org.netbeans.mdr.handlers.gen; 20 21 import java.util.*; 22 import org.netbeans.mdr.util.*; 23 import org.netbeans.mdr.storagemodel.*; 24 25 30 public class ContainsIterator implements java.util.Iterator { 31 32 protected Iterator iterator; 33 34 35 public ContainsIterator(StorableObject element) { 36 ArrayList elements = new ArrayList(); 37 retrieveContent(element, elements); 38 iterator = elements.iterator(); 39 } 40 41 private void retrieveContent(StorableObject element, ArrayList elements) { 42 try { 43 for (Iterator it = ((List)element.getReference(MOFConstants.SH_MODEL_GENERALIZABLE_ELEMENT_SUPERTYPES)).iterator(); it.hasNext();) 44 retrieveContent((StorableObject)it.next(), elements); 45 for (Iterator it = ((List)element.getReference(MOFConstants.SH_MODEL_NAMESPACE_CONTENTS)).iterator(); it.hasNext();) { 46 StorableObject obj = (StorableObject)it.next(); 47 if (!elements.contains(obj)) 48 elements.add(obj); 49 } 50 } catch(Exception e) { 51 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e); 52 } 53 } 54 55 public boolean hasNext() { 56 return iterator.hasNext(); 57 } 58 59 public java.lang.Object next() throws NoSuchElementException { 60 return iterator.next(); 61 } 62 63 public void remove() throws UnsupportedOperationException , IllegalStateException { 64 throw new UnsupportedOperationException (); 65 } 66 } 67 | Popular Tags |