/** * Adds an already instantiated element. * * @param elem the SQLElement to add. */ public final synchronized void addSQLElement(SQLElement elem) { this.elements.put(elem.getTable(), elem); this.tableNames.put(elem.getTable().getName(), elem.getTable()); this.byClass.put(elem.getClass(), elem.getTable()); for (final DirectoryListener dl : this.listeners) { dl.elementAdded(elem); } }
/** * Remove the element for the passed table. * * @param t the table to remove. * @return the removed element, can be <code>null</code>. */ public synchronized SQLElement removeSQLElement(SQLTable t) { final SQLElement elem = this.elements.remove(t); if (elem != null) { this.tableNames.remove(elem.getTable().getName(), elem.getTable()); this.byClass.remove(elem.getClass(), elem.getTable()); // MAYBE only reset neighbours. for (final SQLElement otherElem : this.elements.values()) otherElem.resetRelationships(); for (final DirectoryListener dl : this.listeners) { dl.elementRemoved(elem); } } return elem; }
public final synchronized void putAll(SQLElementDirectory o) { for (final SQLElement elem : o.getElements()) { if (!this.contains(elem.getTable())) this.addSQLElement(elem); } }
/** * Remove the passed instance. NOTE: this method only remove the specific instance passed, so it's * a conditional <code>removeSQLElement(elem.getTable())</code>. * * @param elem the instance to remove. * @see #removeSQLElement(SQLTable) */ public synchronized void removeSQLElement(SQLElement elem) { if (this.getElement(elem.getTable()) == elem) this.removeSQLElement(elem.getTable()); }