Debian Codegraph @

lang/java/src/com/sleepycat/persist/impl/NonPersistentFormat.java

raw
1 /*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002, 2013 Oracle and/or its affiliates. All rights reserved.
5 *
6 */
7
8 package com.sleepycat.persist.impl;
9
10 import java.lang.reflect.Array;
11 import java.util.Map;
12
13 import com.sleepycat.compat.DbCompat;
14 import com.sleepycat.persist.model.EntityModel;
15
16 /**
17 * Format for a non-persistent class that is only used for declared field
18 * types and arrays. Currently used only for Object and interface types.
19 *
20 * @author Mark Hayes
21 */
22 class NonPersistentFormat extends Format {
23
24 private static final long serialVersionUID = -7488355830875148784L;
25
26 NonPersistentFormat(Catalog catalog, Class type) {
27 super(catalog, type);
28 }
29
30 @Override
31 void initialize(Catalog catalog, EntityModel model, int initVersion) {
32 }
33
34 @Override
35 void collectRelatedFormats(Catalog catalog,
36 Map<String, Format> newFormats) {
37 }
38
39 @Override
40 Object newArray(int len) {
41 return Array.newInstance(getType(), len);
42 }
43
44 @Override
45 public Object newInstance(EntityInput input, boolean rawAccess) {
46 throw DbCompat.unexpectedState
47 ("Cannot instantiate non-persistent class: " + getClassName());
48 }
49
50 @Override
51 public Object readObject(Object o, EntityInput input, boolean rawAccess) {
52 throw DbCompat.unexpectedState();
53 }
54
55 @Override
56 void writeObject(Object o, EntityOutput output, boolean rawAccess) {
57 throw DbCompat.unexpectedState();
58 }
59
60 @Override
61 void skipContents(RecordInput input) {
62 throw DbCompat.unexpectedState();
63 }
64
65 @Override
66 boolean evolve(Format newFormat, Evolver evolver) {
67 evolver.useOldFormat(this, newFormat);
68 return true;
69 }
70 }