• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/java/src/com/sleepycat/db/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1999-2009 Oracle.  All rights reserved.
5 *
6 * $Id$
7 */
8package com.sleepycat.db;
9
10import com.sleepycat.db.internal.DbEnv;
11
12/**
13This exception is thrown when a {@link com.sleepycat.db.DatabaseEntry DatabaseEntry}
14passed to a {@link com.sleepycat.db.Database Database} or {@link com.sleepycat.db.Cursor Cursor} method is not large
15enough to hold a value being returned.  This only applies to
16{@link com.sleepycat.db.DatabaseEntry DatabaseEntry} objects configured with the
17{@link com.sleepycat.db.DatabaseEntry#setUserBuffer DatabaseEntry.setUserBuffer} method.
18In a Java Virtual Machine, there are usually separate heaps for memory
19allocated by native code and for objects allocated in Java code.  If the
20Java heap is exhausted, the JVM will throw an
21{@link java.lang.OutOfMemoryError}, so you may see that exception
22rather than this one.
23*/
24public class MemoryException extends DatabaseException {
25    private DatabaseEntry dbt = null;
26    private String message;
27
28    /* package */ MemoryException(final String s,
29                              final DatabaseEntry dbt,
30                              final int errno,
31                              final DbEnv dbenv) {
32        super(s, errno, dbenv);
33        this.message = s;
34        this.dbt = dbt;
35    }
36
37    /**
38    Returns the {@link com.sleepycat.db.DatabaseEntry DatabaseEntry} object with insufficient memory
39    to complete the operation to complete the operation.
40    */
41    public DatabaseEntry getDatabaseEntry() {
42        return dbt;
43    }
44
45    /** {@inheritDoc} */
46    public String toString() {
47        return message;
48    }
49
50    void updateDatabaseEntry(final DatabaseEntry newEntry) {
51        if (this.dbt == null) {
52            this.message = "DatabaseEntry not large enough for available data";
53            this.dbt = newEntry;
54        }
55    }
56}
57