1 10 11 package com.triactive.jdo.store; 12 13 import javax.jdo.JDOFatalInternalException; 14 15 16 class CandidateKey extends Key 17 { 18 public CandidateKey(BaseTable table) 19 { 20 super(table); 21 } 22 23 24 public void setColumn(int seq, Column col) 25 { 26 assertSameTable(col); 27 28 setMinSize(columns, seq + 1); 29 30 if (columns.get(seq) != null) 31 throw new JDOFatalInternalException("Key part #" + seq + " for " + table + " already set"); 32 33 columns.set(seq, col); 34 } 35 36 37 public void addColumn(Column col) 38 { 39 assertSameTable(col); 40 41 columns.add(col); 42 } 43 44 45 public int size() 46 { 47 return columns.size(); 48 } 49 50 51 public int hashCode() 52 { 53 return columns.hashCode(); 54 } 55 56 57 public boolean equals(Object o) 58 { 59 if (o == this) 60 return true; 61 62 if (!(o instanceof CandidateKey)) 63 return false; 64 65 CandidateKey pk = (CandidateKey)o; 66 67 return columns.equals(pk.columns); 68 } 69 70 71 public String toString() 72 { 73 StringBuffer s = new StringBuffer ("UNIQUE ").append(getColumnList(columns)); 74 75 return s.toString(); 76 } 77 } 78 | Popular Tags |