01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: StoredModel.java,v 1.10.2.2 2008/01/07 15:14:20 cwl Exp $
07: */
08:
09: package com.sleepycat.persist.impl;
10:
11: import java.util.Set;
12:
13: import com.sleepycat.persist.model.ClassMetadata;
14: import com.sleepycat.persist.model.EntityMetadata;
15: import 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: */
24: class 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: }
|