@Override public boolean visit(long record) throws IndexException { result.add(new DBProperty(db, record).getKey().getString()); return true; // There should never be duplicates. } });
/** * Deletes all properties, does not delete the record associated with the object itself * - that is it can be re-populated. * @throws IndexException */ public void clear() throws IndexException { this.index.accept(new IBTreeVisitor(){ @Override public int compare(long address) throws IndexException { return 0; } @Override public boolean visit(long address) throws IndexException { new DBProperty(DBProperties.this.db, address).delete(); return false; // there should never be duplicates } }); }
/** * Deletes all properties, does not delete the record associated with the object itself * - that is it can be re-populated. * @throws IndexException */ public void clear() throws IndexException { this.index.accept(new IBTreeVisitor(){ @Override public int compare(long address) throws IndexException { return 0; } @Override public boolean visit(long address) throws IndexException { new DBProperty(DBProperties.this.db, address).delete(); return false; // there should never be duplicates } }); }
/** * Deletes a property from this DBProperties object. * @param key * @return whether a property with matching key existed and was removed, or false if the key * was null * @throws IndexException */ public boolean removeProperty(String key) throws IndexException { if (key != null) { DBProperty existing= DBProperty.search(this.db, this.index, key); if (existing != null) { this.index.delete(existing.getRecord()); existing.delete(); return true; } } return false; }
/** * Deletes a property from this DBProperties object. * @param key * @return whether a property with matching key existed and was removed, or false if the key * was null * @throws IndexException */ public boolean removeProperty(String key) throws IndexException { if (key != null) { DBProperty existing= DBProperty.search(this.db, this.index, key); if (existing != null) { this.index.delete(existing.getRecord()); existing.delete(); return true; } } return false; }
/** * Reads the named property from this properties storage. * @param key a case-sensitive identifier for a property, or null * @return the value associated with the key, or null if either no such property is set, * or the specified key was null * @throws IndexException */ public String getProperty(String key) throws IndexException { if (key != null) { DBProperty existing= DBProperty.search(this.db, this.index, key); if (existing != null) { return existing.getValue().getString(); } } return null; }
/** * Reads the named property from this properties storage. * @param key a case-sensitive identifier for a property, or null * @return the value associated with the key, or null if either no such property is set, * or the specified key was null * @throws IndexException */ public String getProperty(String key) throws IndexException { if (key != null) { DBProperty existing= DBProperty.search(this.db, this.index, key); if (existing != null) { return existing.getValue().getString(); } } return null; }
/** * Writes the key, value mapping to the properties. If a mapping for the * same key already exists, it is overwritten. * @param key a non-null property name * @param value a value to associate with the key. may not be null. * @throws IndexException * @throws NullPointerException if key is null */ public void setProperty(String key, String value) throws IndexException { removeProperty(key); DBProperty newProperty= new DBProperty(this.db, key, value); this.index.insert(newProperty.getRecord()); }
/** * Writes the key, value mapping to the properties. If a mapping for the * same key already exists, it is overwritten. * @param key a non-null property name * @param value a value to associate with the key. may not be null. * @throws IndexException * @throws NullPointerException if key is null */ public void setProperty(String key, String value) throws IndexException { removeProperty(key); DBProperty newProperty= new DBProperty(this.db, key, value); this.index.insert(newProperty.getRecord()); }
/** * Creates an object for accessing an existing DBProperties record at the specified location * of the specified database. */ public DBProperties(Nd nd, long record) throws IndexException { Database database = nd.getDB(); this.record= record; this.index= new BTree(nd, record + PROP_INDEX, DBProperty.getComparator()); this.db= database; }
@Override public boolean visit(long record) throws IndexException { result[0] = new DBProperty(db, record); return false; // There should never be duplicates. } });
/** * Returns the Set of property names stored in this object * @return the Set of property names stored in this object * @throws IndexException */ public Set<String> getKeySet() throws IndexException { return DBProperty.getKeySet(this.db, this.index); }
/** * Allocate storage for a new DBProperties record in the specified database */ public DBProperties(Nd nd) throws IndexException { Database database = nd.getDB(); this.record= database.malloc(RECORD_SIZE, Database.POOL_DB_PROPERTIES); this.index= new BTree(nd, this.record + PROP_INDEX, DBProperty.getComparator()); this.db= database; }
@Override public boolean visit(long address) throws IndexException { new DBProperty(DBProperties.this.db, address).delete(); return false; // there should never be duplicates } });
@Override public boolean visit(long record) throws IndexException { result.add(new DBProperty(db, record).getKey().getString()); return true; // There should never be duplicates. } });
/** * Creates an object for accessing an existing DBProperties record at the specified location * of the specified database. */ public DBProperties(Nd nd, long record) throws IndexException { Database database = nd.getDB(); this.record= record; this.index= new BTree(nd, record + PROP_INDEX, DBProperty.getComparator()); this.db= database; }
/** * Allocate storage for a new DBProperties record in the specified database */ public DBProperties(Nd nd) throws IndexException { Database database = nd.getDB(); this.record= database.malloc(RECORD_SIZE, Database.POOL_DB_PROPERTIES); this.index= new BTree(nd, this.record + PROP_INDEX, DBProperty.getComparator()); this.db= database; }
@Override public boolean visit(long record) throws IndexException { result[0] = new DBProperty(db, record); return false; // There should never be duplicates. } });
@Override public boolean visit(long address) throws IndexException { new DBProperty(DBProperties.this.db, address).delete(); return false; // there should never be duplicates } });
/** * Returns the Set of property names stored in this object * @return the Set of property names stored in this object * @throws IndexException */ public Set<String> getKeySet() throws IndexException { return DBProperty.getKeySet(this.db, this.index); }