1 19 20 package org.netbeans.modules.dbschema; 21 22 24 public final class UniqueKeyElement extends KeyElement { 25 26 private IndexElement _associatedIndex; 27 28 30 public UniqueKeyElement() { 31 this(new Memory(), null, null); 32 } 33 34 39 public UniqueKeyElement(Impl impl, TableElement declaringTable, IndexElement associatedIndex) { 40 super(impl, declaringTable); 41 42 _associatedIndex = associatedIndex; 43 } 44 45 48 final Impl getUniqueKeyImpl() { 49 return (Impl)getElementImpl(); 50 } 51 52 56 public IndexElement getAssociatedIndex() { 57 return _associatedIndex; 58 } 59 60 64 public void setAssociatedIndex(IndexElement index) throws DBException { 65 _associatedIndex = index; 66 } 67 68 71 public boolean isPrimaryKey() { 72 return getUniqueKeyImpl().isPrimaryKey(); 73 } 74 75 79 public void setPrimaryKey (boolean flag) throws DBException { 80 getUniqueKeyImpl().setPrimaryKey(flag); 81 } 82 83 86 public interface Impl extends KeyElement.Impl { 87 90 public boolean isPrimaryKey (); 91 92 96 public void setPrimaryKey (boolean flag) throws DBException; 97 } 98 99 static class Memory extends KeyElement.Memory implements Impl { 100 101 private boolean _pk; 102 103 105 Memory () { 106 _pk = false; 107 } 108 109 112 Memory (UniqueKeyElement key) { 113 super(key); 114 _pk = key.isPrimaryKey(); 115 } 116 117 120 public boolean isPrimaryKey() { 121 return _pk; 122 } 123 124 128 public void setPrimaryKey (boolean flag) throws DBException { 129 boolean old = _pk; 130 131 _pk = flag; 132 firePropertyChange(PROP_PK, Boolean.valueOf(old), Boolean.valueOf(flag)); 133 } 134 } 135 } 136 | Popular Tags |