Package com.sleepycat.bind.serial

## Class StoredClassCatalog

- java.lang.Object
- - com.sleepycat.bind.serial.StoredClassCatalog

- All Implemented Interfaces:
    `ClassCatalog`

      public class StoredClassCatalog
      extends java.lang.Object
      implements ClassCatalog

  A `ClassCatalog` that is stored in a `Database`.

  A single `StoredClassCatalog` object is normally used along with a set of databases that stored serialized objects.

  See Also:
    Class Evolution

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `StoredClassCatalog​(Database database)` | Creates a catalog based on a given database.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Close a catalog database and release any cached resources.
    `java.io.ObjectStreamClass` | `getClassFormat​(byte[] classID)` | Return the ObjectStreamClass for the given class ID.
    `byte[]` | `getClassID​(java.io.ObjectStreamClass classFormat)` | Return the class ID for the current version of the given class description.
    `java.lang.ClassLoader` | `getClassLoader()` | For BDB JE, returns the ClassLoader property of the catalog database environment.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StoredClassCatalog

          public StoredClassCatalog​(Database database)
                             throws DatabaseException,
                                    java.lang.IllegalArgumentException

      Creates a catalog based on a given database. To save resources, only a single catalog object should be used for each unique catalog database.
      Parameters:
        `database` - an open database to use as the class catalog. It must be a BTREE database and must not allow duplicates.
      Throws:
        `DatabaseException` - if an error occurs accessing the database.
        `java.lang.IllegalArgumentException` - if the database is not a BTREE database or if it configured to allow duplicates.

  - ### Method Detail

    - #### close

          public void close()
                     throws DatabaseException

      Description copied from interface: `ClassCatalog`
      Close a catalog database and release any cached resources.
      Specified by:
        `close` in interface `ClassCatalog`
      Throws:
        `DatabaseException` - if an error occurs closing the catalog database.

    - #### getClassID

          public byte[] getClassID​(java.io.ObjectStreamClass classFormat)
                            throws DatabaseException,
                                   java.lang.ClassNotFoundException

      Description copied from interface: `ClassCatalog`
      Return the class ID for the current version of the given class description. This is used for storing in serialization streams in place of a full class descriptor, since it is much more compact. To get back the ObjectStreamClass for a class ID, call `ClassCatalog.getClassFormat(byte[])`. This function causes a new class ID to be assigned if the class description has changed.
      Specified by:
        `getClassID` in interface `ClassCatalog`
      Parameters:
        `classFormat` - The class description for which to return the class ID.
      Returns:
        The class ID for the current version of the class.
      Throws:
        `DatabaseException` - if an error occurs accessing the catalog database.
        `java.lang.ClassNotFoundException` - if the class does not exist.

    - #### getClassFormat

          public java.io.ObjectStreamClass getClassFormat​(byte[] classID)
                                                   throws DatabaseException,
                                                          java.lang.ClassNotFoundException

      Description copied from interface: `ClassCatalog`
      Return the ObjectStreamClass for the given class ID. This may or may not be the current class format, depending on whether the class has changed since the class ID was generated.
      Specified by:
        `getClassFormat` in interface `ClassCatalog`
      Parameters:
        `classID` - The class ID for which to return the class format.
      Returns:
        The class format for the given class ID, which may or may not represent the current version of the class.
      Throws:
        `DatabaseException` - if an error occurs accessing the catalog database.
        `java.lang.ClassNotFoundException` - if the class does not exist.

    - #### getClassLoader

          public java.lang.ClassLoader getClassLoader()

      For BDB JE, returns the ClassLoader property of the catalog database environment. This ensures that the Environment's ClassLoader property is used for loading all user-supplied classes.

      For BDB, this method returns null because no Environment ClassLoader property is available. This method may be overridden to return a ClassLoader.

      Specified by:
        `getClassLoader` in interface `ClassCatalog`
      Returns:
        the ClassLoader or null.

Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.