1 19 package org.netbeans.mdr.storagemodel; 20 21 import java.util.*; 22 23 import javax.jmi.reflect.RefObject; 24 import javax.jmi.reflect.DuplicateException; 25 import org.netbeans.mdr.persistence.MOFID; 26 27 import org.netbeans.mdr.persistence.StorageException; 28 29 33 public class AttrSet extends AttrCollection { 34 public AttrSet() { 35 inner = new HashSet(); 36 } 37 38 AttrSet(StorableFeatured mdrObject, StorableClass.AttributeDescriptor desc) throws StorageException { 39 this(mdrObject, desc, null); 40 } 41 42 protected AttrSet(StorableFeatured mdrObject, StorableClass.AttributeDescriptor desc, Collection values) throws StorageException { 43 super(mdrObject, desc, null); 44 45 if (values != null) { 46 checkMaxSize(values.size()); 47 inner = new HashSet(values.size() * 2); 48 for (Iterator it = values.iterator(); it.hasNext();) { 49 Object value = it.next(); 50 checkType(value); 51 if (!inner.add(value)) { 52 throw new DuplicateException(value, getMetaElement()); 53 } 54 if (isRefObject) { 55 setAttribComposite((RefObject) value); 56 } 57 } 58 } else { 59 inner = new HashSet(); 60 } 61 } 62 63 protected void checkUnwrap() { 64 if (needsUnwrap) { 65 HashSet old = (HashSet) inner; 66 inner = new HashSet(); 67 for (Iterator it = old.iterator(); it.hasNext();) { 68 Object temp = it.next(); 69 if (temp instanceof MOFID) { 70 inner.add(mdrObject.getMdrStorage().getRepository().getByMofId((MOFID) temp)); 71 } else { 72 inner.add(temp); 73 } 74 } 75 needsUnwrap = false; 76 } 77 } 78 } 79 | Popular Tags |