/** * Rename an object. * * @param obj the object to rename * @param newName the new name */ public void rename(SchemaObject obj, String newName) { DbObjectType type = obj.getType(); HashMap<String, SchemaObject> map = getMap(type); if (SysProperties.CHECK) { if (!map.containsKey(obj.getName())) { DbException.throwInternalError("not found: " + obj.getName()); } if (obj.getName().equals(newName) || map.containsKey(newName)) { DbException.throwInternalError("object already exists: " + newName); } } obj.checkRename(); map.remove(obj.getName()); freeUniqueName(obj.getName()); obj.rename(newName); map.put(newName, obj); freeUniqueName(newName); }
/** * Remove an object from this schema. * * @param obj the object to remove */ public void remove(SchemaObject obj) { String objName = obj.getName(); HashMap<String, SchemaObject> map = getMap(obj.getType()); if (SysProperties.CHECK && !map.containsKey(objName)) { DbException.throwInternalError("not found: " + objName); } map.remove(objName); freeUniqueName(objName); }
/** * Add an object to this schema. This method must not be called within CreateSchemaObject; use * Database.addSchemaObject() instead * * @param obj the object to add */ public void add(SchemaObject obj) { if (SysProperties.CHECK && obj.getSchema() != this) { DbException.throwInternalError("wrong schema"); } String name = obj.getName(); HashMap<String, SchemaObject> map = getMap(obj.getType()); if (SysProperties.CHECK && map.get(name) != null) { DbException.throwInternalError("object already exists: " + name); } map.put(name, obj); freeUniqueName(name); }