• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/db-4.7.25.NC/java/src/com/sleepycat/persist/impl/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: Catalog.java,v 1.1 2008/02/07 17:12:27 mark Exp $
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     * @throws IllegalArgumentException if the class is not persistent.  This
65     * is a user error.
66     */
67    Format getFormat(Class cls);
68
69    /**
70     * Returns a format by class name.  Unlike {@link #getFormat(Class)}, the
71     * format will not be created if it is not already known.
72     */
73    Format getFormat(String className);
74
75    /**
76     * @see PersistCatalog#createFormat
77     */
78    Format createFormat(String clsName, Map<String,Format> newFormats);
79
80    /**
81     * @see PersistCatalog#createFormat
82     */
83    Format createFormat(Class type, Map<String,Format> newFormats);
84
85    /**
86     * @see PersistCatalog#isRawAccess
87     */
88    boolean isRawAccess();
89
90    /**
91     * @see PersistCatalog#convertRawObject
92     */
93    Object convertRawObject(RawObject o, IdentityHashMap converted);
94}
95