1 19 20 package org.netbeans.modules.dbschema.jdbcimpl; 21 22 import java.util.*; 23 24 import org.netbeans.modules.dbschema.*; 25 26 public abstract class KeyElementImpl extends DBMemberElementImpl implements KeyElement.Impl { 27 private DBElementsCollection columns; 28 29 30 public KeyElementImpl() { 31 } 32 33 34 public KeyElementImpl (String name) { 35 super(name); 36 columns = initializeCollection(); 37 38 Object hc = String.valueOf(columns.hashCode()); 41 while (DBElementsCollection.instances.contains(hc)) { 42 columns = initializeCollection(); 43 hc = String.valueOf(columns.hashCode()); 44 } 45 DBElementsCollection.instances.add(hc); 46 } 47 48 protected DBElementsCollection initializeCollection() { 49 return new DBElementsCollection(this, new ColumnElement[0]); 50 } 51 52 57 public void changeColumns(ColumnElement[] elems,int action) throws DBException { 58 columns.changeElements(elems, action); 59 } 60 61 64 public ColumnElement[] getColumns() { 65 DBElement[] dbe = columns.getElements(); 66 return (ColumnElement[]) Arrays.asList(dbe).toArray(new ColumnElement[dbe.length]); 67 } 68 69 73 public ColumnElement getColumn(DBIdentifier name) { 74 return (ColumnElement) columns.find(name); 75 } 76 77 81 public DBElementsCollection getColumnCollection () { 82 return columns; 83 } 84 85 90 public void setColumnCollection (DBElementsCollection collection) { 91 columns = collection; 92 } 93 } 94 | Popular Tags |