⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storedmap.java

📁 嵌入式数据库Berkeley DB-4.5.20源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public Object append(Object value) {        boolean doAutoCommit = beginAutoCommit();        try {            Object[] key = new Object[1];            view.append(value, key, null);            commitAutoCommit(doAutoCommit);            return key[0];        } catch (Exception e) {            throw handleException(e, doAutoCommit);        }    }    /**     * Removes the mapping for this key from this map if present (optional     * operation).  If duplicates are allowed, this method removes all     * duplicates for the given key.  This method conforms to the {@link     * Map#remove} interface.     *     * @throws UnsupportedOperationException if the collection is read-only.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     */    public Object remove(Object key) {        Object[] oldVal = new Object[1];        removeKey(key, oldVal);        return oldVal[0];    }    /**     * Returns true if this map contains the specified key.  This method     * conforms to the {@link Map#containsKey} interface.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     */    public boolean containsKey(Object key) {        return super.containsKey(key);    }    /**     * Returns true if this map contains the specified value.  When an entity     * binding is used, this method returns whether the map contains the     * primary key and value mapping of the entity.  This method conforms to     * the {@link Map#containsValue} interface.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     */    public boolean containsValue(Object value) {        return super.containsValue(value);    }    /**     * Copies all of the mappings from the specified map to this map (optional     * operation).  When duplicates are allowed, the mappings in the specified     * map are effectively appended to the existing mappings in this map, that     * is no previously existing mappings in this map are replaced.  This     * method conforms to the {@link Map#putAll} interface.     *     * @throws UnsupportedOperationException if the collection is read-only, or     * if the collection is indexed.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     */    public void putAll(Map map) {        boolean doAutoCommit = beginAutoCommit();        Iterator i = null;        try {            Collection coll = map.entrySet();            i = storedOrExternalIterator(coll);            while (i.hasNext()) {                Map.Entry entry = (Map.Entry) i.next();                put(entry.getKey(), entry.getValue());            }            StoredIterator.close(i);            commitAutoCommit(doAutoCommit);        } catch (Exception e) {            StoredIterator.close(i);            throw handleException(e, doAutoCommit);        }    }    /**     * Returns a set view of the keys contained in this map.  A {@link     * java.util.SortedSet} is returned if the map is ordered.  The returned     * collection will be read-only if the map is read-only.  This method     * conforms to the {@link Map#keySet()} interface.     *     * <p>Note that the return value is a StoredCollection and must be treated     * as such; for example, its iterators must be explicitly closed.</p>     *     * @return a {@link StoredKeySet} or a {@link StoredSortedKeySet} for this     * map.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     *     * @see #isOrdered     * @see #isWriteAllowed     */    public Set keySet() {        return keySet;    }    /**     * Returns a set view of the mappings contained in this map.  A {@link     * java.util.SortedSet} is returned if the map is ordered.  The returned     * collection will be read-only if the map is read-only.  This method     * conforms to the {@link Map#entrySet()} interface.     *     * <p>Note that the return value is a StoredCollection and must be treated     * as such; for example, its iterators must be explicitly closed.</p>     *     * @return a {@link StoredEntrySet} or a {@link StoredSortedEntrySet} for     * this map.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     *     * @see #isOrdered     * @see #isWriteAllowed     */    public Set entrySet() {        return entrySet;    }    /**     * Returns a collection view of the values contained in this map.  A {@link     * java.util.SortedSet} is returned if the map is ordered and the     * value/entity binding can be used to derive the map's key from its     * value/entity object.  The returned collection will be read-only if the     * map is read-only.  This method conforms to the {@link Map#values()}     * interface.     *     * <p>Note that the return value is a StoredCollection and must be treated     * as such; for example, its iterators must be explicitly closed.</p>     *     * @return a {@link StoredValueSet} or a {@link StoredSortedValueSet} for     * this map.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     *     * @see #isOrdered     * @see #isWriteAllowed     */    public Collection values() {        return valueSet;    }    /**     * Returns a new collection containing the values mapped to the given key     * in this map.  This collection's iterator() method is particularly useful     * for iterating over the duplicates for a given key, since this is not     * supported by the standard Map interface.  This method does not exist in     * the standard {@link Map} interface.     *     * <p>If no mapping for the given key is present, an empty collection is     * returned.  If duplicates are not allowed, at most a single value will be     * in the collection returned.  If duplicates are allowed, the returned     * collection's add() method may be used to add values for the given     * key.</p>     *     * @param key is the key for which values are to be returned.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     */    public Collection duplicates(Object key) {        try {            DataView newView = view.valueSetView(key);            return new StoredValueSet(newView);        } catch (KeyRangeException e) {            return Collections.EMPTY_SET;        } catch (Exception e) {            throw StoredContainer.convertException(e);        }    }    /**     * Returns a new map from primary key to value for the subset of records     * having a given secondary key (duplicates).  This method does not exist     * in the standard {@link Map} interface.     *     * <p>If no mapping for the given key is present, an empty collection is     * returned.  If duplicates are not allowed, at most a single value will be     * in the collection returned.  If duplicates are allowed, the returned     * collection's add() method may be used to add values for the given     * key.</p>     *     * @param secondaryKey is the secondary key for which duplicates values     * will be represented by the returned map.     *     * @param primaryKeyBinding is the binding used for keys in the returned     * map.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     */    public Map duplicatesMap(Object secondaryKey,                             EntryBinding primaryKeyBinding) {        try {            DataView newView =                view.duplicatesView(secondaryKey, primaryKeyBinding);            if (isOrdered()) {                return new StoredSortedMap(newView);            } else {                return new StoredMap(newView);            }        } catch (Exception e) {            throw StoredContainer.convertException(e);        }    }    /**     * Compares the specified object with this map for equality.  A value     * comparison is performed by this method and the stored values are     * compared rather than calling the equals() method of each element.  This     * method conforms to the {@link Map#equals} interface.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     */    public boolean equals(Object other) {        if (other instanceof Map) {            return entrySet().equals(((Map) other).entrySet());        } else {            return false;        }    }    /*     * Add this in to keep FindBugs from whining at us about implementing     * equals(), but not hashCode().     */    public int hashCode() {	return super.hashCode();    }    // Inherit javadoc    public int size() {        return values().size();    }    /**     * Converts the map to a string representation for debugging.  WARNING: All     * mappings will be converted to strings and returned and therefore the     * returned string may be very large.     *     * @return the string representation.     *     * @throws RuntimeExceptionWrapper if a {@link     * com.sleepycat.db.DatabaseException} is thrown.     */    public String toString() {        return entrySet().toString();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -