• 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/persist/impl/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002-2009 Oracle.  All rights reserved.
5 *
6 * $Id$
7 */
8
9package com.sleepycat.persist.impl;
10
11import java.util.IdentityHashMap;
12import java.util.Map;
13
14import com.sleepycat.persist.raw.RawObject;
15
16/**
17 * Catalog operation interface used by format classes.
18 *
19 * @see PersistCatalog
20 * @see SimpleCatalog
21 * @see ReadOnlyCatalog
22 *
23 * @author Mark Hayes
24 */
25interface Catalog {
26
27    /*
28     * The catalog version is returned by getInitVersion and is the version of
29     * the serialized format classes loaded from the stored catalog.  When a
30     * field is added, for example, the version can be checked to determine how
31     * to initialize the field in Format.initialize.
32     *
33     * -1: The version is considered to be -1 when reading the beta version of
34     * the catalog data.  At this point no version field was stored, but we can
35     * distinguish the beta stored format.  See PersistCatalog.
36     *
37     * 0: The first released version of the catalog data, after beta.  At this
38     * point no version field was stored, but it is initialized to zero when
39     * the PersistCatalog.Data object is de-serialized.
40     *
41     * 1: Add the ComplexFormat.ConvertFieldReader.oldFieldNum field. [#15797]
42     */
43    static final int BETA_VERSION = -1;
44    static final int CURRENT_VERSION = 1;
45
46    /**
47     * See above.
48     */
49    int getInitVersion(Format format, boolean forReader);
50
51    /**
52     * Returns a format for a given ID, or throws an exception.  This method is
53     * used when reading an object from the byte array format.
54     *
55     * @throws IllegalStateException if the formatId does not correspond to a
56     * persistent class.  This is an internal consistency error.
57     */
58    Format getFormat(int formatId);
59
60    /**
61     * Returns a format for a given class, or throws an exception.  This method
62     * is used when writing an object that was passed in by the user.
63     *
64     * @param checkEntitySubclassIndexes is true if we're expecting this format
65     * to be an entity subclass and therefore subclass secondary indexes should
66     * be opened.
67     *
68     * @throws IllegalArgumentException if the class is not persistent.  This
69     * is a user error.
70     */
71    Format getFormat(Class cls, boolean checkEntitySubclassIndexes);
72
73    /**
74     * Returns a format by class name.  Unlike {@link #getFormat(Class)}, the
75     * format will not be created if it is not already known.
76     */
77    Format getFormat(String className);
78
79    /**
80     * @see PersistCatalog#createFormat
81     */
82    Format createFormat(String clsName, Map<String,Format> newFormats);
83
84    /**
85     * @see PersistCatalog#createFormat
86     */
87    Format createFormat(Class type, Map<String,Format> newFormats);
88
89    /**
90     * @see PersistCatalog#isRawAccess
91     */
92    boolean isRawAccess();
93
94    /**
95     * @see PersistCatalog#convertRawObject
96     */
97    Object convertRawObject(RawObject o, IdentityHashMap converted);
98}
99