1 23 24 29 30 package com.sun.jdo.spi.persistence.support.sqlstore; 31 32 import com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException; 33 import com.sun.jdo.api.persistence.support.JDOUserException; 34 import com.sun.jdo.spi.persistence.utility.I18NHelper; 35 import com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager; 36 import com.sun.jdo.api.persistence.model.Model; 37 38 import java.util.Collection ; 39 import java.util.Iterator ; 40 import java.util.ResourceBundle ; 41 42 47 public class ExtentCollection 48 implements Collection { 49 52 protected PersistenceManager pm; 53 54 57 protected Class persistenceCapableClass; 58 59 62 private final static ResourceBundle messages = I18NHelper.loadBundle( 63 ExtentCollection.class); 64 65 70 public ExtentCollection(PersistenceManager pm, Class persistenceCapableClass, boolean subclasses) { 71 this.pm = pm; 72 this.persistenceCapableClass = persistenceCapableClass; 73 74 if (persistenceCapableClass == null) 76 throw new JDOUserException( 77 I18NHelper.getMessage(messages, "jdo.extentcollection.constructor.invalidclass", "null")); if (Model.RUNTIME.getMappingClass(persistenceCapableClass.getName(), 80 persistenceCapableClass.getClassLoader()) == null) 81 throw new JDOUserException( 82 I18NHelper.getMessage(messages, "jdo.extentcollection.constructor.nonpc", persistenceCapableClass.getName())); 84 85 if (subclasses) 87 throw new JDOUnsupportedOptionException( 88 I18NHelper.getMessage(messages, "jdo.extentcollection.constructor.subclasses")); } 90 91 94 public Class getPersistenceCapableClass() { 95 return persistenceCapableClass; 96 } 97 98 101 public int size() { 102 throw new JDOUnsupportedOptionException( 103 I18NHelper.getMessage(messages, "jdo.extentcollection.methodnotsupported", "size")); } 105 106 109 public boolean isEmpty() { 110 throw new JDOUnsupportedOptionException( 111 I18NHelper.getMessage(messages, "jdo.extentcollection.methodnotsupported", "isEmpty")); } 113 114 117 public boolean contains(Object o) { 118 throw new JDOUnsupportedOptionException( 119 I18NHelper.getMessage(messages, "jdo.extentcollection.methodnotsupported", "contains")); } 121 122 125 public Iterator iterator() { 126 RetrieveDesc rd = pm.getRetrieveDesc(persistenceCapableClass); 127 return ((Collection )pm.retrieve(rd)).iterator(); 128 } 129 130 133 public Object [] toArray() { 134 throw new JDOUnsupportedOptionException( 135 I18NHelper.getMessage(messages, "jdo.extentcollection.methodnotsupported", "toArray")); } 137 138 141 public Object [] toArray(Object a[]) { 142 throw new JDOUnsupportedOptionException( 143 I18NHelper.getMessage(messages, "jdo.extentcollection.methodnotsupported", "toArray")); } 145 146 149 public boolean add(Object o) { 150 throw new UnsupportedOperationException ( 151 I18NHelper.getMessage(messages, "jdo.extentcollection.illegalmodification", persistenceCapableClass.getName())); 153 } 154 155 158 public boolean remove(Object o) { 159 throw new UnsupportedOperationException ( 160 I18NHelper.getMessage(messages, "jdo.extentcollection.illegalmodification", persistenceCapableClass.getName())); 162 } 163 164 167 public boolean containsAll(Collection c) { 168 throw new JDOUnsupportedOptionException( 169 I18NHelper.getMessage(messages, "jdo.extentcollection.methodnotsupported", "containsAll")); } 171 172 175 public boolean addAll(Collection c) { 176 throw new UnsupportedOperationException ( 177 I18NHelper.getMessage(messages, "jdo.extentcollection.illegalmodification", persistenceCapableClass.getName())); 179 } 180 181 184 public boolean removeAll(Collection c) { 185 throw new UnsupportedOperationException ( 186 I18NHelper.getMessage(messages, "jdo.extentcollection.illegalmodification", persistenceCapableClass.getName())); 188 } 189 190 193 public boolean retainAll(Collection c) { 194 throw new UnsupportedOperationException ( 195 I18NHelper.getMessage(messages, "jdo.extentcollection.illegalmodification", persistenceCapableClass.getName())); 197 } 198 199 202 public void clear() { 203 throw new UnsupportedOperationException ( 204 I18NHelper.getMessage(messages, "jdo.extentcollection.illegalmodification", persistenceCapableClass.getName())); 206 } 207 208 211 public boolean equals(Object o) { 212 if (o == this) 213 return true; 214 if (o instanceof ExtentCollection) { 215 String otherClassName = ((ExtentCollection) o).persistenceCapableClass.getName(); 216 return persistenceCapableClass.getName().equals(otherClassName); 217 } 218 return false; 219 } 220 221 224 public int hashCode() { 225 return persistenceCapableClass.getName().hashCode(); 226 } 227 } 228 | Popular Tags |