1 19 package org.netbeans.mdr.storagemodel; 20 21 import java.util.*; 22 import javax.jmi.reflect.*; 23 24 import org.netbeans.mdr.persistence.StorageException; 25 26 30 public class AttrImmutUList extends AttrImmutList { 31 32 public AttrImmutUList() { 33 } 34 35 AttrImmutUList(StorableFeatured mdrObject, StorableClass.AttributeDescriptor desc) throws StorageException { 36 this(mdrObject, desc, null); 37 } 38 39 AttrImmutUList(StorableFeatured mdrObject, StorableClass.AttributeDescriptor desc, Collection values) throws StorageException { 40 Class type = desc.getType(); 41 if (values == null) { 42 data = new Object [0]; 43 } else { 44 data = values.toArray(); 45 Set helperSet = new HashSet(data.length, 1); 46 for (int i = 0; i < data.length; i++) { 47 if (data[i] == null) { 48 throw new NullPointerException (); 49 } 50 if (!type.isInstance(data[i])) { 51 throw new TypeMismatchException(type, data[i], getMetaElement(mdrObject.getMdrStorage(), desc.getMofId())); 52 } 53 if (!helperSet.add(data[i])) { 54 throw new DuplicateException(data[i], getMetaElement(mdrObject.getMdrStorage(), desc.getMofId())); 55 } 56 } 57 } 58 59 if ((data.length < desc.getMinSize()) || ((desc.getMaxSize() > -1) && (data.length > desc.getMaxSize()))) { 60 throw new WrongSizeException(getMetaElement(mdrObject.getMdrStorage(), desc.getMofId())); 61 } 62 63 if (type.isInstance(RefObject.class)) { 64 setAttribComposite(mdrObject.getMofId(), values, desc.getMofId()); 65 } 66 } 67 } 68 | Popular Tags |