1 package xdoclet.modules.ojb.model; 2 3 17 18 import java.util.ArrayList ; 19 20 25 public class ForeignkeyDef extends DefBase 26 { 27 28 private ArrayList _localColumns = new ArrayList (); 29 30 private ArrayList _remoteColumns = new ArrayList (); 31 32 38 public ForeignkeyDef(String name, String tableName) 39 { 40 super(name == null ? "" : name); 41 setProperty(PropertyHelper.TORQUE_PROPERTY_FOREIGNTABLE, tableName); 42 } 43 44 49 public String getTableName() 50 { 51 return getProperty(PropertyHelper.TORQUE_PROPERTY_FOREIGNTABLE); 52 } 53 54 60 public void addColumnPair(String localColumn, String remoteColumn) 61 { 62 if (!_localColumns.contains(localColumn)) 63 { 64 _localColumns.add(localColumn); 65 } 66 if (!_remoteColumns.contains(remoteColumn)) 67 { 68 _remoteColumns.add(remoteColumn); 69 } 70 } 71 72 77 public int getNumColumnPairs() 78 { 79 return _localColumns.size(); 80 } 81 82 88 public String getLocalColumn(int idx) 89 { 90 return (String )_localColumns.get(idx); 91 } 92 93 99 public String getRemoteColumn(int idx) 100 { 101 return (String )_remoteColumns.get(idx); 102 } 103 104 107 public boolean equals(Object obj) 108 { 109 if (!(obj instanceof ForeignkeyDef)) 110 { 111 return false; 112 } 113 114 ForeignkeyDef otherForeignkeyDef = (ForeignkeyDef)obj; 115 116 if (!getTableName().equals(otherForeignkeyDef.getTableName())) 117 { 118 return false; 119 } 120 if (!_localColumns.equals(otherForeignkeyDef._localColumns)) 121 { 122 return false; 123 } 124 if (!_remoteColumns.equals(otherForeignkeyDef._remoteColumns)) 125 { 126 return false; 127 } 128 return true; 129 } 130 131 134 public int hashCode() 135 { 136 StringBuffer textRep = new StringBuffer (); 137 138 textRep.append(getTableName()); 139 textRep.append(" "); 140 textRep.append(_localColumns.toString()); 141 textRep.append(" "); 142 textRep.append(_remoteColumns.toString()); 143 144 return textRep.toString().hashCode(); 145 } 146 } 147 | Popular Tags |