• 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: StoredModel.java,v 1.1 2008/02/07 17:12:27 mark Exp $
7 */
8
9package com.sleepycat.persist.impl;
10
11import java.util.Set;
12
13import com.sleepycat.persist.model.ClassMetadata;
14import com.sleepycat.persist.model.EntityMetadata;
15import com.sleepycat.persist.model.EntityModel;
16
17/**
18 * The EntityModel used when a RawStore is opened.  The metadata and raw type
19 * information comes from the catalog directly, without using the current
20 * class definitions.
21 *
22 * @author Mark Hayes
23 */
24class StoredModel extends EntityModel {
25
26    private PersistCatalog catalog;
27    private Set<String> knownClasses;
28
29    StoredModel(PersistCatalog catalog) {
30        this.catalog = catalog;
31    }
32
33    @Override
34    public ClassMetadata getClassMetadata(String className) {
35        ClassMetadata metadata = null;
36        Format format = catalog.getFormat(className);
37        if (format != null && format.isCurrentVersion()) {
38            metadata = format.getClassMetadata();
39        }
40        return metadata;
41    }
42
43    @Override
44    public EntityMetadata getEntityMetadata(String className) {
45        EntityMetadata metadata = null;
46        Format format = catalog.getFormat(className);
47        if (format != null && format.isCurrentVersion()) {
48            metadata = format.getEntityMetadata();
49        }
50        return metadata;
51    }
52
53    @Override
54    public Set<String> getKnownClasses() {
55        if (knownClasses == null) {
56            knownClasses = catalog.getModelClasses();
57        }
58        return knownClasses;
59    }
60}
61