/** testEndObjectStates */ public void testEndObjectStates() { // create object and configure it Schema schema = new Schema(); SchemaObject state = schema.createObject(); String propertyName = "myProperty"; state.addProperty(propertyName, "String"); // build tests List<EventResult> goodList = this.createGoodList( // EnumSet.of(SchemaEventType.END_OBJECT, SchemaEventType.START_OBJECT_ENTRY), // propertyName // ); // build initializer used before each test runs StateInitializer initializer = new StateInitializer() { public void initialize(IState state) { state.enter(); state.transition(_context, SchemaEventType.START_OBJECT, null); } }; this.testStates(state, initializer, goodList.toArray(new EventResult[goodList.size()])); }
/** * 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); }
/** * 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); }