1 package xdoclet.modules.ojb.model; 2 3 import java.util.Iterator ; 4 5 import xdoclet.modules.ojb.CommaListIterator; 6 7 21 22 27 public class CollectionDescriptorDef extends FeatureDescriptorDef 28 { 29 34 public CollectionDescriptorDef(String name) 35 { 36 super(name); 37 } 38 39 45 public CollectionDescriptorDef(CollectionDescriptorDef src, String prefix) 46 { 47 super(src, prefix); 48 } 49 50 55 public CollectionDescriptorDef getRemoteCollection() 56 { 57 if (!hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE)) 58 { 59 return null; 60 } 61 ModelDef modelDef = (ModelDef)getOwner().getOwner(); 62 String elementClassName = getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF); 63 ClassDescriptorDef elementClass = modelDef.getClass(elementClassName); 64 String indirTable = getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE); 65 boolean hasRemoteKey = hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY); 66 String remoteKey = getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY); 67 CollectionDescriptorDef remoteCollDef = null; 68 69 for (Iterator it = elementClass.getCollections(); it.hasNext();) 71 { 72 remoteCollDef = (CollectionDescriptorDef)it.next(); 73 if (indirTable.equals(remoteCollDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE)) && 74 (this != remoteCollDef) && 75 (!hasRemoteKey || CommaListIterator.sameLists(remoteKey, remoteCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY)))) 76 { 77 return remoteCollDef; 78 } 79 } 80 return null; 81 } 82 } 83 | Popular Tags |