1 package org.apache.ojb.broker; 2 3 17 18 import org.apache.ojb.broker.core.proxy.ProxyHelper; 19 import org.apache.ojb.broker.metadata.CollectionDescriptor; 20 21 29 public class MtoNImplementor 30 { 31 private Object leftObject; 32 private Object rightObject; 33 private Class leftClass; 34 private Class rightClass; 35 private CollectionDescriptor leftDescriptor; 36 37 46 public MtoNImplementor(PersistenceBroker pb, CollectionDescriptor leftDescriptor, Object left, Object right) 47 { 48 init(leftDescriptor, left, right); 49 } 50 51 59 public MtoNImplementor(PersistenceBroker pb, String leftFieldName, Object left, Object right) 60 { 61 if(left == null || right == null) 62 { 63 throw new IllegalArgumentException ("both objects must exist"); 64 } 65 CollectionDescriptor cod = pb.getClassDescriptor(ProxyHelper.getRealClass(left)).getCollectionDescriptorByName(leftFieldName); 66 init(cod, left, right); 67 } 68 69 77 public MtoNImplementor(CollectionDescriptor leftDescriptor, Object left, Object right) 78 { 79 init(leftDescriptor, left, right); 80 } 81 82 private void init(CollectionDescriptor leftDescriptor, Object left, Object right) 83 { 84 if(left == null || right == null) 85 { 86 throw new IllegalArgumentException ("both objects must exist"); 87 } 88 this.leftDescriptor = leftDescriptor; 89 leftObject = left; 90 rightObject = right; 91 leftClass = ProxyHelper.getRealClass(leftObject); 92 rightClass = ProxyHelper.getRealClass(rightObject); 93 } 94 95 100 public CollectionDescriptor getLeftDescriptor() 101 { 102 return leftDescriptor; 103 } 104 105 110 public Class getLeftClass() 111 { 112 return leftClass; 113 } 114 115 120 public Class getRightClass() 121 { 122 return rightClass; 123 } 124 125 130 public Object getLeftObject() 131 { 132 return leftObject; 133 } 134 135 140 public Object getRightObject() 141 { 142 return rightObject; 143 } 144 } 145 | Popular Tags |