/** {@inheritDoc} */ public boolean remove(String name) { if (!objects.containsKey(name)) { return false; } IPersistable object = objects.remove(name); object.setPersistent(false); return true; }
/** {@inheritDoc} */ public boolean save(IPersistable object) { final String key = getObjectId(object); objects.put(key, object); object.setPersistent(true); return true; }
/** * Get object id * * @param object Persistable object whose id is asked for * @return Given persistable object id */ protected String getObjectId(IPersistable object) { // The format of the object id is <type>/<path>/<objectName> String result = object.getType(); if (object.getPath().charAt(0) != '/') { result += '/'; } result += object.getPath(); if (!result.endsWith("/")) { result += '/'; } String name = object.getName(); if (name == null) { name = PERSISTENCE_NO_NAME; } if (name.charAt(0) == '/') { // "result" already ends with a slash name = name.substring(1); } return result + name; }
/** {@inheritDoc} */ public boolean load(IPersistable obj) { return obj.isPersistent(); }